mutation.go 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/custom_types"
  19. "wechat-api/ent/employee"
  20. "wechat-api/ent/employeeconfig"
  21. "wechat-api/ent/label"
  22. "wechat-api/ent/labelrelationship"
  23. "wechat-api/ent/labeltagging"
  24. "wechat-api/ent/message"
  25. "wechat-api/ent/messagerecords"
  26. "wechat-api/ent/msg"
  27. "wechat-api/ent/predicate"
  28. "wechat-api/ent/server"
  29. "wechat-api/ent/sopnode"
  30. "wechat-api/ent/sopstage"
  31. "wechat-api/ent/soptask"
  32. "wechat-api/ent/token"
  33. "wechat-api/ent/tutorial"
  34. "wechat-api/ent/usagedetail"
  35. "wechat-api/ent/usagestatisticday"
  36. "wechat-api/ent/usagestatistichour"
  37. "wechat-api/ent/usagestatisticmonth"
  38. "wechat-api/ent/usagetotal"
  39. "wechat-api/ent/workexperience"
  40. "wechat-api/ent/wpchatroom"
  41. "wechat-api/ent/wpchatroommember"
  42. "wechat-api/ent/wx"
  43. "wechat-api/ent/wxcard"
  44. "wechat-api/ent/wxcarduser"
  45. "wechat-api/ent/wxcardvisit"
  46. "entgo.io/ent"
  47. "entgo.io/ent/dialect/sql"
  48. )
  49. const (
  50. // Operation types.
  51. OpCreate = ent.OpCreate
  52. OpDelete = ent.OpDelete
  53. OpDeleteOne = ent.OpDeleteOne
  54. OpUpdate = ent.OpUpdate
  55. OpUpdateOne = ent.OpUpdateOne
  56. // Node types.
  57. TypeAgent = "Agent"
  58. TypeAgentBase = "AgentBase"
  59. TypeAliyunAvatar = "AliyunAvatar"
  60. TypeAllocAgent = "AllocAgent"
  61. TypeBatchMsg = "BatchMsg"
  62. TypeCategory = "Category"
  63. TypeChatRecords = "ChatRecords"
  64. TypeChatSession = "ChatSession"
  65. TypeContact = "Contact"
  66. TypeEmployee = "Employee"
  67. TypeEmployeeConfig = "EmployeeConfig"
  68. TypeLabel = "Label"
  69. TypeLabelRelationship = "LabelRelationship"
  70. TypeLabelTagging = "LabelTagging"
  71. TypeMessage = "Message"
  72. TypeMessageRecords = "MessageRecords"
  73. TypeMsg = "Msg"
  74. TypeServer = "Server"
  75. TypeSopNode = "SopNode"
  76. TypeSopStage = "SopStage"
  77. TypeSopTask = "SopTask"
  78. TypeToken = "Token"
  79. TypeTutorial = "Tutorial"
  80. TypeUsageDetail = "UsageDetail"
  81. TypeUsageStatisticDay = "UsageStatisticDay"
  82. TypeUsageStatisticHour = "UsageStatisticHour"
  83. TypeUsageStatisticMonth = "UsageStatisticMonth"
  84. TypeUsageTotal = "UsageTotal"
  85. TypeWorkExperience = "WorkExperience"
  86. TypeWpChatroom = "WpChatroom"
  87. TypeWpChatroomMember = "WpChatroomMember"
  88. TypeWx = "Wx"
  89. TypeWxCard = "WxCard"
  90. TypeWxCardUser = "WxCardUser"
  91. TypeWxCardVisit = "WxCardVisit"
  92. )
  93. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  94. type AgentMutation struct {
  95. config
  96. op Op
  97. typ string
  98. id *uint64
  99. created_at *time.Time
  100. updated_at *time.Time
  101. deleted_at *time.Time
  102. name *string
  103. role *string
  104. status *int
  105. addstatus *int
  106. background *string
  107. examples *string
  108. organization_id *uint64
  109. addorganization_id *int64
  110. dataset_id *string
  111. collection_id *string
  112. clearedFields map[string]struct{}
  113. wx_agent map[uint64]struct{}
  114. removedwx_agent map[uint64]struct{}
  115. clearedwx_agent bool
  116. token_agent map[uint64]struct{}
  117. removedtoken_agent map[uint64]struct{}
  118. clearedtoken_agent bool
  119. done bool
  120. oldValue func(context.Context) (*Agent, error)
  121. predicates []predicate.Agent
  122. }
  123. var _ ent.Mutation = (*AgentMutation)(nil)
  124. // agentOption allows management of the mutation configuration using functional options.
  125. type agentOption func(*AgentMutation)
  126. // newAgentMutation creates new mutation for the Agent entity.
  127. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  128. m := &AgentMutation{
  129. config: c,
  130. op: op,
  131. typ: TypeAgent,
  132. clearedFields: make(map[string]struct{}),
  133. }
  134. for _, opt := range opts {
  135. opt(m)
  136. }
  137. return m
  138. }
  139. // withAgentID sets the ID field of the mutation.
  140. func withAgentID(id uint64) agentOption {
  141. return func(m *AgentMutation) {
  142. var (
  143. err error
  144. once sync.Once
  145. value *Agent
  146. )
  147. m.oldValue = func(ctx context.Context) (*Agent, error) {
  148. once.Do(func() {
  149. if m.done {
  150. err = errors.New("querying old values post mutation is not allowed")
  151. } else {
  152. value, err = m.Client().Agent.Get(ctx, id)
  153. }
  154. })
  155. return value, err
  156. }
  157. m.id = &id
  158. }
  159. }
  160. // withAgent sets the old Agent of the mutation.
  161. func withAgent(node *Agent) agentOption {
  162. return func(m *AgentMutation) {
  163. m.oldValue = func(context.Context) (*Agent, error) {
  164. return node, nil
  165. }
  166. m.id = &node.ID
  167. }
  168. }
  169. // Client returns a new `ent.Client` from the mutation. If the mutation was
  170. // executed in a transaction (ent.Tx), a transactional client is returned.
  171. func (m AgentMutation) Client() *Client {
  172. client := &Client{config: m.config}
  173. client.init()
  174. return client
  175. }
  176. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  177. // it returns an error otherwise.
  178. func (m AgentMutation) Tx() (*Tx, error) {
  179. if _, ok := m.driver.(*txDriver); !ok {
  180. return nil, errors.New("ent: mutation is not running in a transaction")
  181. }
  182. tx := &Tx{config: m.config}
  183. tx.init()
  184. return tx, nil
  185. }
  186. // SetID sets the value of the id field. Note that this
  187. // operation is only accepted on creation of Agent entities.
  188. func (m *AgentMutation) SetID(id uint64) {
  189. m.id = &id
  190. }
  191. // ID returns the ID value in the mutation. Note that the ID is only available
  192. // if it was provided to the builder or after it was returned from the database.
  193. func (m *AgentMutation) ID() (id uint64, exists bool) {
  194. if m.id == nil {
  195. return
  196. }
  197. return *m.id, true
  198. }
  199. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  200. // That means, if the mutation is applied within a transaction with an isolation level such
  201. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  202. // or updated by the mutation.
  203. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  204. switch {
  205. case m.op.Is(OpUpdateOne | OpDeleteOne):
  206. id, exists := m.ID()
  207. if exists {
  208. return []uint64{id}, nil
  209. }
  210. fallthrough
  211. case m.op.Is(OpUpdate | OpDelete):
  212. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  213. default:
  214. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  215. }
  216. }
  217. // SetCreatedAt sets the "created_at" field.
  218. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  219. m.created_at = &t
  220. }
  221. // CreatedAt returns the value of the "created_at" field in the mutation.
  222. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  223. v := m.created_at
  224. if v == nil {
  225. return
  226. }
  227. return *v, true
  228. }
  229. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  230. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  232. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  233. if !m.op.Is(OpUpdateOne) {
  234. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  235. }
  236. if m.id == nil || m.oldValue == nil {
  237. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  238. }
  239. oldValue, err := m.oldValue(ctx)
  240. if err != nil {
  241. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  242. }
  243. return oldValue.CreatedAt, nil
  244. }
  245. // ResetCreatedAt resets all changes to the "created_at" field.
  246. func (m *AgentMutation) ResetCreatedAt() {
  247. m.created_at = nil
  248. }
  249. // SetUpdatedAt sets the "updated_at" field.
  250. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  251. m.updated_at = &t
  252. }
  253. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  254. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  255. v := m.updated_at
  256. if v == nil {
  257. return
  258. }
  259. return *v, true
  260. }
  261. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  262. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  264. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  265. if !m.op.Is(OpUpdateOne) {
  266. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  267. }
  268. if m.id == nil || m.oldValue == nil {
  269. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  270. }
  271. oldValue, err := m.oldValue(ctx)
  272. if err != nil {
  273. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  274. }
  275. return oldValue.UpdatedAt, nil
  276. }
  277. // ResetUpdatedAt resets all changes to the "updated_at" field.
  278. func (m *AgentMutation) ResetUpdatedAt() {
  279. m.updated_at = nil
  280. }
  281. // SetDeletedAt sets the "deleted_at" field.
  282. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  283. m.deleted_at = &t
  284. }
  285. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  286. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  287. v := m.deleted_at
  288. if v == nil {
  289. return
  290. }
  291. return *v, true
  292. }
  293. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  294. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  296. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  297. if !m.op.Is(OpUpdateOne) {
  298. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  299. }
  300. if m.id == nil || m.oldValue == nil {
  301. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  302. }
  303. oldValue, err := m.oldValue(ctx)
  304. if err != nil {
  305. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  306. }
  307. return oldValue.DeletedAt, nil
  308. }
  309. // ClearDeletedAt clears the value of the "deleted_at" field.
  310. func (m *AgentMutation) ClearDeletedAt() {
  311. m.deleted_at = nil
  312. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  313. }
  314. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  315. func (m *AgentMutation) DeletedAtCleared() bool {
  316. _, ok := m.clearedFields[agent.FieldDeletedAt]
  317. return ok
  318. }
  319. // ResetDeletedAt resets all changes to the "deleted_at" field.
  320. func (m *AgentMutation) ResetDeletedAt() {
  321. m.deleted_at = nil
  322. delete(m.clearedFields, agent.FieldDeletedAt)
  323. }
  324. // SetName sets the "name" field.
  325. func (m *AgentMutation) SetName(s string) {
  326. m.name = &s
  327. }
  328. // Name returns the value of the "name" field in the mutation.
  329. func (m *AgentMutation) Name() (r string, exists bool) {
  330. v := m.name
  331. if v == nil {
  332. return
  333. }
  334. return *v, true
  335. }
  336. // OldName returns the old "name" field's value of the Agent entity.
  337. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  339. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  340. if !m.op.Is(OpUpdateOne) {
  341. return v, errors.New("OldName is only allowed on UpdateOne operations")
  342. }
  343. if m.id == nil || m.oldValue == nil {
  344. return v, errors.New("OldName requires an ID field in the mutation")
  345. }
  346. oldValue, err := m.oldValue(ctx)
  347. if err != nil {
  348. return v, fmt.Errorf("querying old value for OldName: %w", err)
  349. }
  350. return oldValue.Name, nil
  351. }
  352. // ResetName resets all changes to the "name" field.
  353. func (m *AgentMutation) ResetName() {
  354. m.name = nil
  355. }
  356. // SetRole sets the "role" field.
  357. func (m *AgentMutation) SetRole(s string) {
  358. m.role = &s
  359. }
  360. // Role returns the value of the "role" field in the mutation.
  361. func (m *AgentMutation) Role() (r string, exists bool) {
  362. v := m.role
  363. if v == nil {
  364. return
  365. }
  366. return *v, true
  367. }
  368. // OldRole returns the old "role" field's value of the Agent entity.
  369. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  371. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  372. if !m.op.Is(OpUpdateOne) {
  373. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  374. }
  375. if m.id == nil || m.oldValue == nil {
  376. return v, errors.New("OldRole requires an ID field in the mutation")
  377. }
  378. oldValue, err := m.oldValue(ctx)
  379. if err != nil {
  380. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  381. }
  382. return oldValue.Role, nil
  383. }
  384. // ResetRole resets all changes to the "role" field.
  385. func (m *AgentMutation) ResetRole() {
  386. m.role = nil
  387. }
  388. // SetStatus sets the "status" field.
  389. func (m *AgentMutation) SetStatus(i int) {
  390. m.status = &i
  391. m.addstatus = nil
  392. }
  393. // Status returns the value of the "status" field in the mutation.
  394. func (m *AgentMutation) Status() (r int, exists bool) {
  395. v := m.status
  396. if v == nil {
  397. return
  398. }
  399. return *v, true
  400. }
  401. // OldStatus returns the old "status" field's value of the Agent entity.
  402. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  404. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  405. if !m.op.Is(OpUpdateOne) {
  406. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  407. }
  408. if m.id == nil || m.oldValue == nil {
  409. return v, errors.New("OldStatus requires an ID field in the mutation")
  410. }
  411. oldValue, err := m.oldValue(ctx)
  412. if err != nil {
  413. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  414. }
  415. return oldValue.Status, nil
  416. }
  417. // AddStatus adds i to the "status" field.
  418. func (m *AgentMutation) AddStatus(i int) {
  419. if m.addstatus != nil {
  420. *m.addstatus += i
  421. } else {
  422. m.addstatus = &i
  423. }
  424. }
  425. // AddedStatus returns the value that was added to the "status" field in this mutation.
  426. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  427. v := m.addstatus
  428. if v == nil {
  429. return
  430. }
  431. return *v, true
  432. }
  433. // ClearStatus clears the value of the "status" field.
  434. func (m *AgentMutation) ClearStatus() {
  435. m.status = nil
  436. m.addstatus = nil
  437. m.clearedFields[agent.FieldStatus] = struct{}{}
  438. }
  439. // StatusCleared returns if the "status" field was cleared in this mutation.
  440. func (m *AgentMutation) StatusCleared() bool {
  441. _, ok := m.clearedFields[agent.FieldStatus]
  442. return ok
  443. }
  444. // ResetStatus resets all changes to the "status" field.
  445. func (m *AgentMutation) ResetStatus() {
  446. m.status = nil
  447. m.addstatus = nil
  448. delete(m.clearedFields, agent.FieldStatus)
  449. }
  450. // SetBackground sets the "background" field.
  451. func (m *AgentMutation) SetBackground(s string) {
  452. m.background = &s
  453. }
  454. // Background returns the value of the "background" field in the mutation.
  455. func (m *AgentMutation) Background() (r string, exists bool) {
  456. v := m.background
  457. if v == nil {
  458. return
  459. }
  460. return *v, true
  461. }
  462. // OldBackground returns the old "background" field's value of the Agent entity.
  463. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  465. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  466. if !m.op.Is(OpUpdateOne) {
  467. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  468. }
  469. if m.id == nil || m.oldValue == nil {
  470. return v, errors.New("OldBackground requires an ID field in the mutation")
  471. }
  472. oldValue, err := m.oldValue(ctx)
  473. if err != nil {
  474. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  475. }
  476. return oldValue.Background, nil
  477. }
  478. // ClearBackground clears the value of the "background" field.
  479. func (m *AgentMutation) ClearBackground() {
  480. m.background = nil
  481. m.clearedFields[agent.FieldBackground] = struct{}{}
  482. }
  483. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  484. func (m *AgentMutation) BackgroundCleared() bool {
  485. _, ok := m.clearedFields[agent.FieldBackground]
  486. return ok
  487. }
  488. // ResetBackground resets all changes to the "background" field.
  489. func (m *AgentMutation) ResetBackground() {
  490. m.background = nil
  491. delete(m.clearedFields, agent.FieldBackground)
  492. }
  493. // SetExamples sets the "examples" field.
  494. func (m *AgentMutation) SetExamples(s string) {
  495. m.examples = &s
  496. }
  497. // Examples returns the value of the "examples" field in the mutation.
  498. func (m *AgentMutation) Examples() (r string, exists bool) {
  499. v := m.examples
  500. if v == nil {
  501. return
  502. }
  503. return *v, true
  504. }
  505. // OldExamples returns the old "examples" field's value of the Agent entity.
  506. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  508. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  509. if !m.op.Is(OpUpdateOne) {
  510. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  511. }
  512. if m.id == nil || m.oldValue == nil {
  513. return v, errors.New("OldExamples requires an ID field in the mutation")
  514. }
  515. oldValue, err := m.oldValue(ctx)
  516. if err != nil {
  517. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  518. }
  519. return oldValue.Examples, nil
  520. }
  521. // ClearExamples clears the value of the "examples" field.
  522. func (m *AgentMutation) ClearExamples() {
  523. m.examples = nil
  524. m.clearedFields[agent.FieldExamples] = struct{}{}
  525. }
  526. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  527. func (m *AgentMutation) ExamplesCleared() bool {
  528. _, ok := m.clearedFields[agent.FieldExamples]
  529. return ok
  530. }
  531. // ResetExamples resets all changes to the "examples" field.
  532. func (m *AgentMutation) ResetExamples() {
  533. m.examples = nil
  534. delete(m.clearedFields, agent.FieldExamples)
  535. }
  536. // SetOrganizationID sets the "organization_id" field.
  537. func (m *AgentMutation) SetOrganizationID(u uint64) {
  538. m.organization_id = &u
  539. m.addorganization_id = nil
  540. }
  541. // OrganizationID returns the value of the "organization_id" field in the mutation.
  542. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  543. v := m.organization_id
  544. if v == nil {
  545. return
  546. }
  547. return *v, true
  548. }
  549. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  550. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  552. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  553. if !m.op.Is(OpUpdateOne) {
  554. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  555. }
  556. if m.id == nil || m.oldValue == nil {
  557. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  558. }
  559. oldValue, err := m.oldValue(ctx)
  560. if err != nil {
  561. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  562. }
  563. return oldValue.OrganizationID, nil
  564. }
  565. // AddOrganizationID adds u to the "organization_id" field.
  566. func (m *AgentMutation) AddOrganizationID(u int64) {
  567. if m.addorganization_id != nil {
  568. *m.addorganization_id += u
  569. } else {
  570. m.addorganization_id = &u
  571. }
  572. }
  573. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  574. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  575. v := m.addorganization_id
  576. if v == nil {
  577. return
  578. }
  579. return *v, true
  580. }
  581. // ResetOrganizationID resets all changes to the "organization_id" field.
  582. func (m *AgentMutation) ResetOrganizationID() {
  583. m.organization_id = nil
  584. m.addorganization_id = nil
  585. }
  586. // SetDatasetID sets the "dataset_id" field.
  587. func (m *AgentMutation) SetDatasetID(s string) {
  588. m.dataset_id = &s
  589. }
  590. // DatasetID returns the value of the "dataset_id" field in the mutation.
  591. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  592. v := m.dataset_id
  593. if v == nil {
  594. return
  595. }
  596. return *v, true
  597. }
  598. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  599. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  601. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  602. if !m.op.Is(OpUpdateOne) {
  603. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  604. }
  605. if m.id == nil || m.oldValue == nil {
  606. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  607. }
  608. oldValue, err := m.oldValue(ctx)
  609. if err != nil {
  610. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  611. }
  612. return oldValue.DatasetID, nil
  613. }
  614. // ResetDatasetID resets all changes to the "dataset_id" field.
  615. func (m *AgentMutation) ResetDatasetID() {
  616. m.dataset_id = nil
  617. }
  618. // SetCollectionID sets the "collection_id" field.
  619. func (m *AgentMutation) SetCollectionID(s string) {
  620. m.collection_id = &s
  621. }
  622. // CollectionID returns the value of the "collection_id" field in the mutation.
  623. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  624. v := m.collection_id
  625. if v == nil {
  626. return
  627. }
  628. return *v, true
  629. }
  630. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  631. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  633. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  634. if !m.op.Is(OpUpdateOne) {
  635. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  636. }
  637. if m.id == nil || m.oldValue == nil {
  638. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  639. }
  640. oldValue, err := m.oldValue(ctx)
  641. if err != nil {
  642. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  643. }
  644. return oldValue.CollectionID, nil
  645. }
  646. // ResetCollectionID resets all changes to the "collection_id" field.
  647. func (m *AgentMutation) ResetCollectionID() {
  648. m.collection_id = nil
  649. }
  650. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  651. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  652. if m.wx_agent == nil {
  653. m.wx_agent = make(map[uint64]struct{})
  654. }
  655. for i := range ids {
  656. m.wx_agent[ids[i]] = struct{}{}
  657. }
  658. }
  659. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  660. func (m *AgentMutation) ClearWxAgent() {
  661. m.clearedwx_agent = true
  662. }
  663. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  664. func (m *AgentMutation) WxAgentCleared() bool {
  665. return m.clearedwx_agent
  666. }
  667. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  668. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  669. if m.removedwx_agent == nil {
  670. m.removedwx_agent = make(map[uint64]struct{})
  671. }
  672. for i := range ids {
  673. delete(m.wx_agent, ids[i])
  674. m.removedwx_agent[ids[i]] = struct{}{}
  675. }
  676. }
  677. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  678. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  679. for id := range m.removedwx_agent {
  680. ids = append(ids, id)
  681. }
  682. return
  683. }
  684. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  685. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  686. for id := range m.wx_agent {
  687. ids = append(ids, id)
  688. }
  689. return
  690. }
  691. // ResetWxAgent resets all changes to the "wx_agent" edge.
  692. func (m *AgentMutation) ResetWxAgent() {
  693. m.wx_agent = nil
  694. m.clearedwx_agent = false
  695. m.removedwx_agent = nil
  696. }
  697. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  698. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  699. if m.token_agent == nil {
  700. m.token_agent = make(map[uint64]struct{})
  701. }
  702. for i := range ids {
  703. m.token_agent[ids[i]] = struct{}{}
  704. }
  705. }
  706. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  707. func (m *AgentMutation) ClearTokenAgent() {
  708. m.clearedtoken_agent = true
  709. }
  710. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  711. func (m *AgentMutation) TokenAgentCleared() bool {
  712. return m.clearedtoken_agent
  713. }
  714. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  715. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  716. if m.removedtoken_agent == nil {
  717. m.removedtoken_agent = make(map[uint64]struct{})
  718. }
  719. for i := range ids {
  720. delete(m.token_agent, ids[i])
  721. m.removedtoken_agent[ids[i]] = struct{}{}
  722. }
  723. }
  724. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  725. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  726. for id := range m.removedtoken_agent {
  727. ids = append(ids, id)
  728. }
  729. return
  730. }
  731. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  732. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  733. for id := range m.token_agent {
  734. ids = append(ids, id)
  735. }
  736. return
  737. }
  738. // ResetTokenAgent resets all changes to the "token_agent" edge.
  739. func (m *AgentMutation) ResetTokenAgent() {
  740. m.token_agent = nil
  741. m.clearedtoken_agent = false
  742. m.removedtoken_agent = nil
  743. }
  744. // Where appends a list predicates to the AgentMutation builder.
  745. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  746. m.predicates = append(m.predicates, ps...)
  747. }
  748. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  749. // users can use type-assertion to append predicates that do not depend on any generated package.
  750. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  751. p := make([]predicate.Agent, len(ps))
  752. for i := range ps {
  753. p[i] = ps[i]
  754. }
  755. m.Where(p...)
  756. }
  757. // Op returns the operation name.
  758. func (m *AgentMutation) Op() Op {
  759. return m.op
  760. }
  761. // SetOp allows setting the mutation operation.
  762. func (m *AgentMutation) SetOp(op Op) {
  763. m.op = op
  764. }
  765. // Type returns the node type of this mutation (Agent).
  766. func (m *AgentMutation) Type() string {
  767. return m.typ
  768. }
  769. // Fields returns all fields that were changed during this mutation. Note that in
  770. // order to get all numeric fields that were incremented/decremented, call
  771. // AddedFields().
  772. func (m *AgentMutation) Fields() []string {
  773. fields := make([]string, 0, 11)
  774. if m.created_at != nil {
  775. fields = append(fields, agent.FieldCreatedAt)
  776. }
  777. if m.updated_at != nil {
  778. fields = append(fields, agent.FieldUpdatedAt)
  779. }
  780. if m.deleted_at != nil {
  781. fields = append(fields, agent.FieldDeletedAt)
  782. }
  783. if m.name != nil {
  784. fields = append(fields, agent.FieldName)
  785. }
  786. if m.role != nil {
  787. fields = append(fields, agent.FieldRole)
  788. }
  789. if m.status != nil {
  790. fields = append(fields, agent.FieldStatus)
  791. }
  792. if m.background != nil {
  793. fields = append(fields, agent.FieldBackground)
  794. }
  795. if m.examples != nil {
  796. fields = append(fields, agent.FieldExamples)
  797. }
  798. if m.organization_id != nil {
  799. fields = append(fields, agent.FieldOrganizationID)
  800. }
  801. if m.dataset_id != nil {
  802. fields = append(fields, agent.FieldDatasetID)
  803. }
  804. if m.collection_id != nil {
  805. fields = append(fields, agent.FieldCollectionID)
  806. }
  807. return fields
  808. }
  809. // Field returns the value of a field with the given name. The second boolean
  810. // return value indicates that this field was not set, or was not defined in the
  811. // schema.
  812. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  813. switch name {
  814. case agent.FieldCreatedAt:
  815. return m.CreatedAt()
  816. case agent.FieldUpdatedAt:
  817. return m.UpdatedAt()
  818. case agent.FieldDeletedAt:
  819. return m.DeletedAt()
  820. case agent.FieldName:
  821. return m.Name()
  822. case agent.FieldRole:
  823. return m.Role()
  824. case agent.FieldStatus:
  825. return m.Status()
  826. case agent.FieldBackground:
  827. return m.Background()
  828. case agent.FieldExamples:
  829. return m.Examples()
  830. case agent.FieldOrganizationID:
  831. return m.OrganizationID()
  832. case agent.FieldDatasetID:
  833. return m.DatasetID()
  834. case agent.FieldCollectionID:
  835. return m.CollectionID()
  836. }
  837. return nil, false
  838. }
  839. // OldField returns the old value of the field from the database. An error is
  840. // returned if the mutation operation is not UpdateOne, or the query to the
  841. // database failed.
  842. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  843. switch name {
  844. case agent.FieldCreatedAt:
  845. return m.OldCreatedAt(ctx)
  846. case agent.FieldUpdatedAt:
  847. return m.OldUpdatedAt(ctx)
  848. case agent.FieldDeletedAt:
  849. return m.OldDeletedAt(ctx)
  850. case agent.FieldName:
  851. return m.OldName(ctx)
  852. case agent.FieldRole:
  853. return m.OldRole(ctx)
  854. case agent.FieldStatus:
  855. return m.OldStatus(ctx)
  856. case agent.FieldBackground:
  857. return m.OldBackground(ctx)
  858. case agent.FieldExamples:
  859. return m.OldExamples(ctx)
  860. case agent.FieldOrganizationID:
  861. return m.OldOrganizationID(ctx)
  862. case agent.FieldDatasetID:
  863. return m.OldDatasetID(ctx)
  864. case agent.FieldCollectionID:
  865. return m.OldCollectionID(ctx)
  866. }
  867. return nil, fmt.Errorf("unknown Agent field %s", name)
  868. }
  869. // SetField sets the value of a field with the given name. It returns an error if
  870. // the field is not defined in the schema, or if the type mismatched the field
  871. // type.
  872. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  873. switch name {
  874. case agent.FieldCreatedAt:
  875. v, ok := value.(time.Time)
  876. if !ok {
  877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  878. }
  879. m.SetCreatedAt(v)
  880. return nil
  881. case agent.FieldUpdatedAt:
  882. v, ok := value.(time.Time)
  883. if !ok {
  884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  885. }
  886. m.SetUpdatedAt(v)
  887. return nil
  888. case agent.FieldDeletedAt:
  889. v, ok := value.(time.Time)
  890. if !ok {
  891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  892. }
  893. m.SetDeletedAt(v)
  894. return nil
  895. case agent.FieldName:
  896. v, ok := value.(string)
  897. if !ok {
  898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  899. }
  900. m.SetName(v)
  901. return nil
  902. case agent.FieldRole:
  903. v, ok := value.(string)
  904. if !ok {
  905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  906. }
  907. m.SetRole(v)
  908. return nil
  909. case agent.FieldStatus:
  910. v, ok := value.(int)
  911. if !ok {
  912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  913. }
  914. m.SetStatus(v)
  915. return nil
  916. case agent.FieldBackground:
  917. v, ok := value.(string)
  918. if !ok {
  919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  920. }
  921. m.SetBackground(v)
  922. return nil
  923. case agent.FieldExamples:
  924. v, ok := value.(string)
  925. if !ok {
  926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  927. }
  928. m.SetExamples(v)
  929. return nil
  930. case agent.FieldOrganizationID:
  931. v, ok := value.(uint64)
  932. if !ok {
  933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  934. }
  935. m.SetOrganizationID(v)
  936. return nil
  937. case agent.FieldDatasetID:
  938. v, ok := value.(string)
  939. if !ok {
  940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  941. }
  942. m.SetDatasetID(v)
  943. return nil
  944. case agent.FieldCollectionID:
  945. v, ok := value.(string)
  946. if !ok {
  947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  948. }
  949. m.SetCollectionID(v)
  950. return nil
  951. }
  952. return fmt.Errorf("unknown Agent field %s", name)
  953. }
  954. // AddedFields returns all numeric fields that were incremented/decremented during
  955. // this mutation.
  956. func (m *AgentMutation) AddedFields() []string {
  957. var fields []string
  958. if m.addstatus != nil {
  959. fields = append(fields, agent.FieldStatus)
  960. }
  961. if m.addorganization_id != nil {
  962. fields = append(fields, agent.FieldOrganizationID)
  963. }
  964. return fields
  965. }
  966. // AddedField returns the numeric value that was incremented/decremented on a field
  967. // with the given name. The second boolean return value indicates that this field
  968. // was not set, or was not defined in the schema.
  969. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  970. switch name {
  971. case agent.FieldStatus:
  972. return m.AddedStatus()
  973. case agent.FieldOrganizationID:
  974. return m.AddedOrganizationID()
  975. }
  976. return nil, false
  977. }
  978. // AddField adds the value to the field with the given name. It returns an error if
  979. // the field is not defined in the schema, or if the type mismatched the field
  980. // type.
  981. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  982. switch name {
  983. case agent.FieldStatus:
  984. v, ok := value.(int)
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.AddStatus(v)
  989. return nil
  990. case agent.FieldOrganizationID:
  991. v, ok := value.(int64)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.AddOrganizationID(v)
  996. return nil
  997. }
  998. return fmt.Errorf("unknown Agent numeric field %s", name)
  999. }
  1000. // ClearedFields returns all nullable fields that were cleared during this
  1001. // mutation.
  1002. func (m *AgentMutation) ClearedFields() []string {
  1003. var fields []string
  1004. if m.FieldCleared(agent.FieldDeletedAt) {
  1005. fields = append(fields, agent.FieldDeletedAt)
  1006. }
  1007. if m.FieldCleared(agent.FieldStatus) {
  1008. fields = append(fields, agent.FieldStatus)
  1009. }
  1010. if m.FieldCleared(agent.FieldBackground) {
  1011. fields = append(fields, agent.FieldBackground)
  1012. }
  1013. if m.FieldCleared(agent.FieldExamples) {
  1014. fields = append(fields, agent.FieldExamples)
  1015. }
  1016. return fields
  1017. }
  1018. // FieldCleared returns a boolean indicating if a field with the given name was
  1019. // cleared in this mutation.
  1020. func (m *AgentMutation) FieldCleared(name string) bool {
  1021. _, ok := m.clearedFields[name]
  1022. return ok
  1023. }
  1024. // ClearField clears the value of the field with the given name. It returns an
  1025. // error if the field is not defined in the schema.
  1026. func (m *AgentMutation) ClearField(name string) error {
  1027. switch name {
  1028. case agent.FieldDeletedAt:
  1029. m.ClearDeletedAt()
  1030. return nil
  1031. case agent.FieldStatus:
  1032. m.ClearStatus()
  1033. return nil
  1034. case agent.FieldBackground:
  1035. m.ClearBackground()
  1036. return nil
  1037. case agent.FieldExamples:
  1038. m.ClearExamples()
  1039. return nil
  1040. }
  1041. return fmt.Errorf("unknown Agent nullable field %s", name)
  1042. }
  1043. // ResetField resets all changes in the mutation for the field with the given name.
  1044. // It returns an error if the field is not defined in the schema.
  1045. func (m *AgentMutation) ResetField(name string) error {
  1046. switch name {
  1047. case agent.FieldCreatedAt:
  1048. m.ResetCreatedAt()
  1049. return nil
  1050. case agent.FieldUpdatedAt:
  1051. m.ResetUpdatedAt()
  1052. return nil
  1053. case agent.FieldDeletedAt:
  1054. m.ResetDeletedAt()
  1055. return nil
  1056. case agent.FieldName:
  1057. m.ResetName()
  1058. return nil
  1059. case agent.FieldRole:
  1060. m.ResetRole()
  1061. return nil
  1062. case agent.FieldStatus:
  1063. m.ResetStatus()
  1064. return nil
  1065. case agent.FieldBackground:
  1066. m.ResetBackground()
  1067. return nil
  1068. case agent.FieldExamples:
  1069. m.ResetExamples()
  1070. return nil
  1071. case agent.FieldOrganizationID:
  1072. m.ResetOrganizationID()
  1073. return nil
  1074. case agent.FieldDatasetID:
  1075. m.ResetDatasetID()
  1076. return nil
  1077. case agent.FieldCollectionID:
  1078. m.ResetCollectionID()
  1079. return nil
  1080. }
  1081. return fmt.Errorf("unknown Agent field %s", name)
  1082. }
  1083. // AddedEdges returns all edge names that were set/added in this mutation.
  1084. func (m *AgentMutation) AddedEdges() []string {
  1085. edges := make([]string, 0, 2)
  1086. if m.wx_agent != nil {
  1087. edges = append(edges, agent.EdgeWxAgent)
  1088. }
  1089. if m.token_agent != nil {
  1090. edges = append(edges, agent.EdgeTokenAgent)
  1091. }
  1092. return edges
  1093. }
  1094. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1095. // name in this mutation.
  1096. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1097. switch name {
  1098. case agent.EdgeWxAgent:
  1099. ids := make([]ent.Value, 0, len(m.wx_agent))
  1100. for id := range m.wx_agent {
  1101. ids = append(ids, id)
  1102. }
  1103. return ids
  1104. case agent.EdgeTokenAgent:
  1105. ids := make([]ent.Value, 0, len(m.token_agent))
  1106. for id := range m.token_agent {
  1107. ids = append(ids, id)
  1108. }
  1109. return ids
  1110. }
  1111. return nil
  1112. }
  1113. // RemovedEdges returns all edge names that were removed in this mutation.
  1114. func (m *AgentMutation) RemovedEdges() []string {
  1115. edges := make([]string, 0, 2)
  1116. if m.removedwx_agent != nil {
  1117. edges = append(edges, agent.EdgeWxAgent)
  1118. }
  1119. if m.removedtoken_agent != nil {
  1120. edges = append(edges, agent.EdgeTokenAgent)
  1121. }
  1122. return edges
  1123. }
  1124. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1125. // the given name in this mutation.
  1126. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1127. switch name {
  1128. case agent.EdgeWxAgent:
  1129. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1130. for id := range m.removedwx_agent {
  1131. ids = append(ids, id)
  1132. }
  1133. return ids
  1134. case agent.EdgeTokenAgent:
  1135. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1136. for id := range m.removedtoken_agent {
  1137. ids = append(ids, id)
  1138. }
  1139. return ids
  1140. }
  1141. return nil
  1142. }
  1143. // ClearedEdges returns all edge names that were cleared in this mutation.
  1144. func (m *AgentMutation) ClearedEdges() []string {
  1145. edges := make([]string, 0, 2)
  1146. if m.clearedwx_agent {
  1147. edges = append(edges, agent.EdgeWxAgent)
  1148. }
  1149. if m.clearedtoken_agent {
  1150. edges = append(edges, agent.EdgeTokenAgent)
  1151. }
  1152. return edges
  1153. }
  1154. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1155. // was cleared in this mutation.
  1156. func (m *AgentMutation) EdgeCleared(name string) bool {
  1157. switch name {
  1158. case agent.EdgeWxAgent:
  1159. return m.clearedwx_agent
  1160. case agent.EdgeTokenAgent:
  1161. return m.clearedtoken_agent
  1162. }
  1163. return false
  1164. }
  1165. // ClearEdge clears the value of the edge with the given name. It returns an error
  1166. // if that edge is not defined in the schema.
  1167. func (m *AgentMutation) ClearEdge(name string) error {
  1168. switch name {
  1169. }
  1170. return fmt.Errorf("unknown Agent unique edge %s", name)
  1171. }
  1172. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1173. // It returns an error if the edge is not defined in the schema.
  1174. func (m *AgentMutation) ResetEdge(name string) error {
  1175. switch name {
  1176. case agent.EdgeWxAgent:
  1177. m.ResetWxAgent()
  1178. return nil
  1179. case agent.EdgeTokenAgent:
  1180. m.ResetTokenAgent()
  1181. return nil
  1182. }
  1183. return fmt.Errorf("unknown Agent edge %s", name)
  1184. }
  1185. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1186. type AgentBaseMutation struct {
  1187. config
  1188. op Op
  1189. typ string
  1190. id *string
  1191. q *string
  1192. a *string
  1193. chunk_index *uint64
  1194. addchunk_index *int64
  1195. indexes *[]string
  1196. appendindexes []string
  1197. dataset_id *string
  1198. collection_id *string
  1199. source_name *string
  1200. can_write *[]bool
  1201. appendcan_write []bool
  1202. is_owner *[]bool
  1203. appendis_owner []bool
  1204. clearedFields map[string]struct{}
  1205. wx_agent map[uint64]struct{}
  1206. removedwx_agent map[uint64]struct{}
  1207. clearedwx_agent bool
  1208. done bool
  1209. oldValue func(context.Context) (*AgentBase, error)
  1210. predicates []predicate.AgentBase
  1211. }
  1212. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1213. // agentbaseOption allows management of the mutation configuration using functional options.
  1214. type agentbaseOption func(*AgentBaseMutation)
  1215. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1216. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1217. m := &AgentBaseMutation{
  1218. config: c,
  1219. op: op,
  1220. typ: TypeAgentBase,
  1221. clearedFields: make(map[string]struct{}),
  1222. }
  1223. for _, opt := range opts {
  1224. opt(m)
  1225. }
  1226. return m
  1227. }
  1228. // withAgentBaseID sets the ID field of the mutation.
  1229. func withAgentBaseID(id string) agentbaseOption {
  1230. return func(m *AgentBaseMutation) {
  1231. var (
  1232. err error
  1233. once sync.Once
  1234. value *AgentBase
  1235. )
  1236. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1237. once.Do(func() {
  1238. if m.done {
  1239. err = errors.New("querying old values post mutation is not allowed")
  1240. } else {
  1241. value, err = m.Client().AgentBase.Get(ctx, id)
  1242. }
  1243. })
  1244. return value, err
  1245. }
  1246. m.id = &id
  1247. }
  1248. }
  1249. // withAgentBase sets the old AgentBase of the mutation.
  1250. func withAgentBase(node *AgentBase) agentbaseOption {
  1251. return func(m *AgentBaseMutation) {
  1252. m.oldValue = func(context.Context) (*AgentBase, error) {
  1253. return node, nil
  1254. }
  1255. m.id = &node.ID
  1256. }
  1257. }
  1258. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1259. // executed in a transaction (ent.Tx), a transactional client is returned.
  1260. func (m AgentBaseMutation) Client() *Client {
  1261. client := &Client{config: m.config}
  1262. client.init()
  1263. return client
  1264. }
  1265. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1266. // it returns an error otherwise.
  1267. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1268. if _, ok := m.driver.(*txDriver); !ok {
  1269. return nil, errors.New("ent: mutation is not running in a transaction")
  1270. }
  1271. tx := &Tx{config: m.config}
  1272. tx.init()
  1273. return tx, nil
  1274. }
  1275. // SetID sets the value of the id field. Note that this
  1276. // operation is only accepted on creation of AgentBase entities.
  1277. func (m *AgentBaseMutation) SetID(id string) {
  1278. m.id = &id
  1279. }
  1280. // ID returns the ID value in the mutation. Note that the ID is only available
  1281. // if it was provided to the builder or after it was returned from the database.
  1282. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1283. if m.id == nil {
  1284. return
  1285. }
  1286. return *m.id, true
  1287. }
  1288. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1289. // That means, if the mutation is applied within a transaction with an isolation level such
  1290. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1291. // or updated by the mutation.
  1292. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1293. switch {
  1294. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1295. id, exists := m.ID()
  1296. if exists {
  1297. return []string{id}, nil
  1298. }
  1299. fallthrough
  1300. case m.op.Is(OpUpdate | OpDelete):
  1301. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1302. default:
  1303. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1304. }
  1305. }
  1306. // SetQ sets the "q" field.
  1307. func (m *AgentBaseMutation) SetQ(s string) {
  1308. m.q = &s
  1309. }
  1310. // Q returns the value of the "q" field in the mutation.
  1311. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1312. v := m.q
  1313. if v == nil {
  1314. return
  1315. }
  1316. return *v, true
  1317. }
  1318. // OldQ returns the old "q" field's value of the AgentBase entity.
  1319. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1321. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1322. if !m.op.Is(OpUpdateOne) {
  1323. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1324. }
  1325. if m.id == nil || m.oldValue == nil {
  1326. return v, errors.New("OldQ requires an ID field in the mutation")
  1327. }
  1328. oldValue, err := m.oldValue(ctx)
  1329. if err != nil {
  1330. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1331. }
  1332. return oldValue.Q, nil
  1333. }
  1334. // ClearQ clears the value of the "q" field.
  1335. func (m *AgentBaseMutation) ClearQ() {
  1336. m.q = nil
  1337. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1338. }
  1339. // QCleared returns if the "q" field was cleared in this mutation.
  1340. func (m *AgentBaseMutation) QCleared() bool {
  1341. _, ok := m.clearedFields[agentbase.FieldQ]
  1342. return ok
  1343. }
  1344. // ResetQ resets all changes to the "q" field.
  1345. func (m *AgentBaseMutation) ResetQ() {
  1346. m.q = nil
  1347. delete(m.clearedFields, agentbase.FieldQ)
  1348. }
  1349. // SetA sets the "a" field.
  1350. func (m *AgentBaseMutation) SetA(s string) {
  1351. m.a = &s
  1352. }
  1353. // A returns the value of the "a" field in the mutation.
  1354. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1355. v := m.a
  1356. if v == nil {
  1357. return
  1358. }
  1359. return *v, true
  1360. }
  1361. // OldA returns the old "a" field's value of the AgentBase entity.
  1362. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1364. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1365. if !m.op.Is(OpUpdateOne) {
  1366. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1367. }
  1368. if m.id == nil || m.oldValue == nil {
  1369. return v, errors.New("OldA requires an ID field in the mutation")
  1370. }
  1371. oldValue, err := m.oldValue(ctx)
  1372. if err != nil {
  1373. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1374. }
  1375. return oldValue.A, nil
  1376. }
  1377. // ClearA clears the value of the "a" field.
  1378. func (m *AgentBaseMutation) ClearA() {
  1379. m.a = nil
  1380. m.clearedFields[agentbase.FieldA] = struct{}{}
  1381. }
  1382. // ACleared returns if the "a" field was cleared in this mutation.
  1383. func (m *AgentBaseMutation) ACleared() bool {
  1384. _, ok := m.clearedFields[agentbase.FieldA]
  1385. return ok
  1386. }
  1387. // ResetA resets all changes to the "a" field.
  1388. func (m *AgentBaseMutation) ResetA() {
  1389. m.a = nil
  1390. delete(m.clearedFields, agentbase.FieldA)
  1391. }
  1392. // SetChunkIndex sets the "chunk_index" field.
  1393. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1394. m.chunk_index = &u
  1395. m.addchunk_index = nil
  1396. }
  1397. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1398. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1399. v := m.chunk_index
  1400. if v == nil {
  1401. return
  1402. }
  1403. return *v, true
  1404. }
  1405. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1406. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1408. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1409. if !m.op.Is(OpUpdateOne) {
  1410. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1411. }
  1412. if m.id == nil || m.oldValue == nil {
  1413. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1414. }
  1415. oldValue, err := m.oldValue(ctx)
  1416. if err != nil {
  1417. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1418. }
  1419. return oldValue.ChunkIndex, nil
  1420. }
  1421. // AddChunkIndex adds u to the "chunk_index" field.
  1422. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1423. if m.addchunk_index != nil {
  1424. *m.addchunk_index += u
  1425. } else {
  1426. m.addchunk_index = &u
  1427. }
  1428. }
  1429. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1430. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1431. v := m.addchunk_index
  1432. if v == nil {
  1433. return
  1434. }
  1435. return *v, true
  1436. }
  1437. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1438. func (m *AgentBaseMutation) ResetChunkIndex() {
  1439. m.chunk_index = nil
  1440. m.addchunk_index = nil
  1441. }
  1442. // SetIndexes sets the "indexes" field.
  1443. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1444. m.indexes = &s
  1445. m.appendindexes = nil
  1446. }
  1447. // Indexes returns the value of the "indexes" field in the mutation.
  1448. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1449. v := m.indexes
  1450. if v == nil {
  1451. return
  1452. }
  1453. return *v, true
  1454. }
  1455. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1456. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1458. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1459. if !m.op.Is(OpUpdateOne) {
  1460. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1461. }
  1462. if m.id == nil || m.oldValue == nil {
  1463. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1464. }
  1465. oldValue, err := m.oldValue(ctx)
  1466. if err != nil {
  1467. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1468. }
  1469. return oldValue.Indexes, nil
  1470. }
  1471. // AppendIndexes adds s to the "indexes" field.
  1472. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1473. m.appendindexes = append(m.appendindexes, s...)
  1474. }
  1475. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1476. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1477. if len(m.appendindexes) == 0 {
  1478. return nil, false
  1479. }
  1480. return m.appendindexes, true
  1481. }
  1482. // ClearIndexes clears the value of the "indexes" field.
  1483. func (m *AgentBaseMutation) ClearIndexes() {
  1484. m.indexes = nil
  1485. m.appendindexes = nil
  1486. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1487. }
  1488. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1489. func (m *AgentBaseMutation) IndexesCleared() bool {
  1490. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1491. return ok
  1492. }
  1493. // ResetIndexes resets all changes to the "indexes" field.
  1494. func (m *AgentBaseMutation) ResetIndexes() {
  1495. m.indexes = nil
  1496. m.appendindexes = nil
  1497. delete(m.clearedFields, agentbase.FieldIndexes)
  1498. }
  1499. // SetDatasetID sets the "dataset_id" field.
  1500. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1501. m.dataset_id = &s
  1502. }
  1503. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1504. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1505. v := m.dataset_id
  1506. if v == nil {
  1507. return
  1508. }
  1509. return *v, true
  1510. }
  1511. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1512. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1514. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1515. if !m.op.Is(OpUpdateOne) {
  1516. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1517. }
  1518. if m.id == nil || m.oldValue == nil {
  1519. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1520. }
  1521. oldValue, err := m.oldValue(ctx)
  1522. if err != nil {
  1523. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1524. }
  1525. return oldValue.DatasetID, nil
  1526. }
  1527. // ClearDatasetID clears the value of the "dataset_id" field.
  1528. func (m *AgentBaseMutation) ClearDatasetID() {
  1529. m.dataset_id = nil
  1530. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1531. }
  1532. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1533. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1534. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1535. return ok
  1536. }
  1537. // ResetDatasetID resets all changes to the "dataset_id" field.
  1538. func (m *AgentBaseMutation) ResetDatasetID() {
  1539. m.dataset_id = nil
  1540. delete(m.clearedFields, agentbase.FieldDatasetID)
  1541. }
  1542. // SetCollectionID sets the "collection_id" field.
  1543. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1544. m.collection_id = &s
  1545. }
  1546. // CollectionID returns the value of the "collection_id" field in the mutation.
  1547. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1548. v := m.collection_id
  1549. if v == nil {
  1550. return
  1551. }
  1552. return *v, true
  1553. }
  1554. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1555. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1557. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1558. if !m.op.Is(OpUpdateOne) {
  1559. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1560. }
  1561. if m.id == nil || m.oldValue == nil {
  1562. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1563. }
  1564. oldValue, err := m.oldValue(ctx)
  1565. if err != nil {
  1566. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1567. }
  1568. return oldValue.CollectionID, nil
  1569. }
  1570. // ClearCollectionID clears the value of the "collection_id" field.
  1571. func (m *AgentBaseMutation) ClearCollectionID() {
  1572. m.collection_id = nil
  1573. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1574. }
  1575. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1576. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1577. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1578. return ok
  1579. }
  1580. // ResetCollectionID resets all changes to the "collection_id" field.
  1581. func (m *AgentBaseMutation) ResetCollectionID() {
  1582. m.collection_id = nil
  1583. delete(m.clearedFields, agentbase.FieldCollectionID)
  1584. }
  1585. // SetSourceName sets the "source_name" field.
  1586. func (m *AgentBaseMutation) SetSourceName(s string) {
  1587. m.source_name = &s
  1588. }
  1589. // SourceName returns the value of the "source_name" field in the mutation.
  1590. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1591. v := m.source_name
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1598. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1600. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1601. if !m.op.Is(OpUpdateOne) {
  1602. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1603. }
  1604. if m.id == nil || m.oldValue == nil {
  1605. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1606. }
  1607. oldValue, err := m.oldValue(ctx)
  1608. if err != nil {
  1609. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1610. }
  1611. return oldValue.SourceName, nil
  1612. }
  1613. // ClearSourceName clears the value of the "source_name" field.
  1614. func (m *AgentBaseMutation) ClearSourceName() {
  1615. m.source_name = nil
  1616. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1617. }
  1618. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1619. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1620. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1621. return ok
  1622. }
  1623. // ResetSourceName resets all changes to the "source_name" field.
  1624. func (m *AgentBaseMutation) ResetSourceName() {
  1625. m.source_name = nil
  1626. delete(m.clearedFields, agentbase.FieldSourceName)
  1627. }
  1628. // SetCanWrite sets the "can_write" field.
  1629. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1630. m.can_write = &b
  1631. m.appendcan_write = nil
  1632. }
  1633. // CanWrite returns the value of the "can_write" field in the mutation.
  1634. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1635. v := m.can_write
  1636. if v == nil {
  1637. return
  1638. }
  1639. return *v, true
  1640. }
  1641. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1642. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1644. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1645. if !m.op.Is(OpUpdateOne) {
  1646. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1647. }
  1648. if m.id == nil || m.oldValue == nil {
  1649. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1650. }
  1651. oldValue, err := m.oldValue(ctx)
  1652. if err != nil {
  1653. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1654. }
  1655. return oldValue.CanWrite, nil
  1656. }
  1657. // AppendCanWrite adds b to the "can_write" field.
  1658. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1659. m.appendcan_write = append(m.appendcan_write, b...)
  1660. }
  1661. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1662. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1663. if len(m.appendcan_write) == 0 {
  1664. return nil, false
  1665. }
  1666. return m.appendcan_write, true
  1667. }
  1668. // ClearCanWrite clears the value of the "can_write" field.
  1669. func (m *AgentBaseMutation) ClearCanWrite() {
  1670. m.can_write = nil
  1671. m.appendcan_write = nil
  1672. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1673. }
  1674. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1675. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1676. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1677. return ok
  1678. }
  1679. // ResetCanWrite resets all changes to the "can_write" field.
  1680. func (m *AgentBaseMutation) ResetCanWrite() {
  1681. m.can_write = nil
  1682. m.appendcan_write = nil
  1683. delete(m.clearedFields, agentbase.FieldCanWrite)
  1684. }
  1685. // SetIsOwner sets the "is_owner" field.
  1686. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1687. m.is_owner = &b
  1688. m.appendis_owner = nil
  1689. }
  1690. // IsOwner returns the value of the "is_owner" field in the mutation.
  1691. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1692. v := m.is_owner
  1693. if v == nil {
  1694. return
  1695. }
  1696. return *v, true
  1697. }
  1698. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1699. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1701. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1702. if !m.op.Is(OpUpdateOne) {
  1703. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1704. }
  1705. if m.id == nil || m.oldValue == nil {
  1706. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1707. }
  1708. oldValue, err := m.oldValue(ctx)
  1709. if err != nil {
  1710. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1711. }
  1712. return oldValue.IsOwner, nil
  1713. }
  1714. // AppendIsOwner adds b to the "is_owner" field.
  1715. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1716. m.appendis_owner = append(m.appendis_owner, b...)
  1717. }
  1718. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1719. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1720. if len(m.appendis_owner) == 0 {
  1721. return nil, false
  1722. }
  1723. return m.appendis_owner, true
  1724. }
  1725. // ClearIsOwner clears the value of the "is_owner" field.
  1726. func (m *AgentBaseMutation) ClearIsOwner() {
  1727. m.is_owner = nil
  1728. m.appendis_owner = nil
  1729. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1730. }
  1731. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1732. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1733. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1734. return ok
  1735. }
  1736. // ResetIsOwner resets all changes to the "is_owner" field.
  1737. func (m *AgentBaseMutation) ResetIsOwner() {
  1738. m.is_owner = nil
  1739. m.appendis_owner = nil
  1740. delete(m.clearedFields, agentbase.FieldIsOwner)
  1741. }
  1742. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1743. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1744. if m.wx_agent == nil {
  1745. m.wx_agent = make(map[uint64]struct{})
  1746. }
  1747. for i := range ids {
  1748. m.wx_agent[ids[i]] = struct{}{}
  1749. }
  1750. }
  1751. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1752. func (m *AgentBaseMutation) ClearWxAgent() {
  1753. m.clearedwx_agent = true
  1754. }
  1755. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1756. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1757. return m.clearedwx_agent
  1758. }
  1759. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1760. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1761. if m.removedwx_agent == nil {
  1762. m.removedwx_agent = make(map[uint64]struct{})
  1763. }
  1764. for i := range ids {
  1765. delete(m.wx_agent, ids[i])
  1766. m.removedwx_agent[ids[i]] = struct{}{}
  1767. }
  1768. }
  1769. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1770. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1771. for id := range m.removedwx_agent {
  1772. ids = append(ids, id)
  1773. }
  1774. return
  1775. }
  1776. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1777. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1778. for id := range m.wx_agent {
  1779. ids = append(ids, id)
  1780. }
  1781. return
  1782. }
  1783. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1784. func (m *AgentBaseMutation) ResetWxAgent() {
  1785. m.wx_agent = nil
  1786. m.clearedwx_agent = false
  1787. m.removedwx_agent = nil
  1788. }
  1789. // Where appends a list predicates to the AgentBaseMutation builder.
  1790. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1791. m.predicates = append(m.predicates, ps...)
  1792. }
  1793. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1794. // users can use type-assertion to append predicates that do not depend on any generated package.
  1795. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1796. p := make([]predicate.AgentBase, len(ps))
  1797. for i := range ps {
  1798. p[i] = ps[i]
  1799. }
  1800. m.Where(p...)
  1801. }
  1802. // Op returns the operation name.
  1803. func (m *AgentBaseMutation) Op() Op {
  1804. return m.op
  1805. }
  1806. // SetOp allows setting the mutation operation.
  1807. func (m *AgentBaseMutation) SetOp(op Op) {
  1808. m.op = op
  1809. }
  1810. // Type returns the node type of this mutation (AgentBase).
  1811. func (m *AgentBaseMutation) Type() string {
  1812. return m.typ
  1813. }
  1814. // Fields returns all fields that were changed during this mutation. Note that in
  1815. // order to get all numeric fields that were incremented/decremented, call
  1816. // AddedFields().
  1817. func (m *AgentBaseMutation) Fields() []string {
  1818. fields := make([]string, 0, 9)
  1819. if m.q != nil {
  1820. fields = append(fields, agentbase.FieldQ)
  1821. }
  1822. if m.a != nil {
  1823. fields = append(fields, agentbase.FieldA)
  1824. }
  1825. if m.chunk_index != nil {
  1826. fields = append(fields, agentbase.FieldChunkIndex)
  1827. }
  1828. if m.indexes != nil {
  1829. fields = append(fields, agentbase.FieldIndexes)
  1830. }
  1831. if m.dataset_id != nil {
  1832. fields = append(fields, agentbase.FieldDatasetID)
  1833. }
  1834. if m.collection_id != nil {
  1835. fields = append(fields, agentbase.FieldCollectionID)
  1836. }
  1837. if m.source_name != nil {
  1838. fields = append(fields, agentbase.FieldSourceName)
  1839. }
  1840. if m.can_write != nil {
  1841. fields = append(fields, agentbase.FieldCanWrite)
  1842. }
  1843. if m.is_owner != nil {
  1844. fields = append(fields, agentbase.FieldIsOwner)
  1845. }
  1846. return fields
  1847. }
  1848. // Field returns the value of a field with the given name. The second boolean
  1849. // return value indicates that this field was not set, or was not defined in the
  1850. // schema.
  1851. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1852. switch name {
  1853. case agentbase.FieldQ:
  1854. return m.Q()
  1855. case agentbase.FieldA:
  1856. return m.A()
  1857. case agentbase.FieldChunkIndex:
  1858. return m.ChunkIndex()
  1859. case agentbase.FieldIndexes:
  1860. return m.Indexes()
  1861. case agentbase.FieldDatasetID:
  1862. return m.DatasetID()
  1863. case agentbase.FieldCollectionID:
  1864. return m.CollectionID()
  1865. case agentbase.FieldSourceName:
  1866. return m.SourceName()
  1867. case agentbase.FieldCanWrite:
  1868. return m.CanWrite()
  1869. case agentbase.FieldIsOwner:
  1870. return m.IsOwner()
  1871. }
  1872. return nil, false
  1873. }
  1874. // OldField returns the old value of the field from the database. An error is
  1875. // returned if the mutation operation is not UpdateOne, or the query to the
  1876. // database failed.
  1877. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1878. switch name {
  1879. case agentbase.FieldQ:
  1880. return m.OldQ(ctx)
  1881. case agentbase.FieldA:
  1882. return m.OldA(ctx)
  1883. case agentbase.FieldChunkIndex:
  1884. return m.OldChunkIndex(ctx)
  1885. case agentbase.FieldIndexes:
  1886. return m.OldIndexes(ctx)
  1887. case agentbase.FieldDatasetID:
  1888. return m.OldDatasetID(ctx)
  1889. case agentbase.FieldCollectionID:
  1890. return m.OldCollectionID(ctx)
  1891. case agentbase.FieldSourceName:
  1892. return m.OldSourceName(ctx)
  1893. case agentbase.FieldCanWrite:
  1894. return m.OldCanWrite(ctx)
  1895. case agentbase.FieldIsOwner:
  1896. return m.OldIsOwner(ctx)
  1897. }
  1898. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1899. }
  1900. // SetField sets the value of a field with the given name. It returns an error if
  1901. // the field is not defined in the schema, or if the type mismatched the field
  1902. // type.
  1903. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1904. switch name {
  1905. case agentbase.FieldQ:
  1906. v, ok := value.(string)
  1907. if !ok {
  1908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1909. }
  1910. m.SetQ(v)
  1911. return nil
  1912. case agentbase.FieldA:
  1913. v, ok := value.(string)
  1914. if !ok {
  1915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1916. }
  1917. m.SetA(v)
  1918. return nil
  1919. case agentbase.FieldChunkIndex:
  1920. v, ok := value.(uint64)
  1921. if !ok {
  1922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1923. }
  1924. m.SetChunkIndex(v)
  1925. return nil
  1926. case agentbase.FieldIndexes:
  1927. v, ok := value.([]string)
  1928. if !ok {
  1929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1930. }
  1931. m.SetIndexes(v)
  1932. return nil
  1933. case agentbase.FieldDatasetID:
  1934. v, ok := value.(string)
  1935. if !ok {
  1936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1937. }
  1938. m.SetDatasetID(v)
  1939. return nil
  1940. case agentbase.FieldCollectionID:
  1941. v, ok := value.(string)
  1942. if !ok {
  1943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1944. }
  1945. m.SetCollectionID(v)
  1946. return nil
  1947. case agentbase.FieldSourceName:
  1948. v, ok := value.(string)
  1949. if !ok {
  1950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1951. }
  1952. m.SetSourceName(v)
  1953. return nil
  1954. case agentbase.FieldCanWrite:
  1955. v, ok := value.([]bool)
  1956. if !ok {
  1957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1958. }
  1959. m.SetCanWrite(v)
  1960. return nil
  1961. case agentbase.FieldIsOwner:
  1962. v, ok := value.([]bool)
  1963. if !ok {
  1964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1965. }
  1966. m.SetIsOwner(v)
  1967. return nil
  1968. }
  1969. return fmt.Errorf("unknown AgentBase field %s", name)
  1970. }
  1971. // AddedFields returns all numeric fields that were incremented/decremented during
  1972. // this mutation.
  1973. func (m *AgentBaseMutation) AddedFields() []string {
  1974. var fields []string
  1975. if m.addchunk_index != nil {
  1976. fields = append(fields, agentbase.FieldChunkIndex)
  1977. }
  1978. return fields
  1979. }
  1980. // AddedField returns the numeric value that was incremented/decremented on a field
  1981. // with the given name. The second boolean return value indicates that this field
  1982. // was not set, or was not defined in the schema.
  1983. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1984. switch name {
  1985. case agentbase.FieldChunkIndex:
  1986. return m.AddedChunkIndex()
  1987. }
  1988. return nil, false
  1989. }
  1990. // AddField adds the value to the field with the given name. It returns an error if
  1991. // the field is not defined in the schema, or if the type mismatched the field
  1992. // type.
  1993. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1994. switch name {
  1995. case agentbase.FieldChunkIndex:
  1996. v, ok := value.(int64)
  1997. if !ok {
  1998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1999. }
  2000. m.AddChunkIndex(v)
  2001. return nil
  2002. }
  2003. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2004. }
  2005. // ClearedFields returns all nullable fields that were cleared during this
  2006. // mutation.
  2007. func (m *AgentBaseMutation) ClearedFields() []string {
  2008. var fields []string
  2009. if m.FieldCleared(agentbase.FieldQ) {
  2010. fields = append(fields, agentbase.FieldQ)
  2011. }
  2012. if m.FieldCleared(agentbase.FieldA) {
  2013. fields = append(fields, agentbase.FieldA)
  2014. }
  2015. if m.FieldCleared(agentbase.FieldIndexes) {
  2016. fields = append(fields, agentbase.FieldIndexes)
  2017. }
  2018. if m.FieldCleared(agentbase.FieldDatasetID) {
  2019. fields = append(fields, agentbase.FieldDatasetID)
  2020. }
  2021. if m.FieldCleared(agentbase.FieldCollectionID) {
  2022. fields = append(fields, agentbase.FieldCollectionID)
  2023. }
  2024. if m.FieldCleared(agentbase.FieldSourceName) {
  2025. fields = append(fields, agentbase.FieldSourceName)
  2026. }
  2027. if m.FieldCleared(agentbase.FieldCanWrite) {
  2028. fields = append(fields, agentbase.FieldCanWrite)
  2029. }
  2030. if m.FieldCleared(agentbase.FieldIsOwner) {
  2031. fields = append(fields, agentbase.FieldIsOwner)
  2032. }
  2033. return fields
  2034. }
  2035. // FieldCleared returns a boolean indicating if a field with the given name was
  2036. // cleared in this mutation.
  2037. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2038. _, ok := m.clearedFields[name]
  2039. return ok
  2040. }
  2041. // ClearField clears the value of the field with the given name. It returns an
  2042. // error if the field is not defined in the schema.
  2043. func (m *AgentBaseMutation) ClearField(name string) error {
  2044. switch name {
  2045. case agentbase.FieldQ:
  2046. m.ClearQ()
  2047. return nil
  2048. case agentbase.FieldA:
  2049. m.ClearA()
  2050. return nil
  2051. case agentbase.FieldIndexes:
  2052. m.ClearIndexes()
  2053. return nil
  2054. case agentbase.FieldDatasetID:
  2055. m.ClearDatasetID()
  2056. return nil
  2057. case agentbase.FieldCollectionID:
  2058. m.ClearCollectionID()
  2059. return nil
  2060. case agentbase.FieldSourceName:
  2061. m.ClearSourceName()
  2062. return nil
  2063. case agentbase.FieldCanWrite:
  2064. m.ClearCanWrite()
  2065. return nil
  2066. case agentbase.FieldIsOwner:
  2067. m.ClearIsOwner()
  2068. return nil
  2069. }
  2070. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2071. }
  2072. // ResetField resets all changes in the mutation for the field with the given name.
  2073. // It returns an error if the field is not defined in the schema.
  2074. func (m *AgentBaseMutation) ResetField(name string) error {
  2075. switch name {
  2076. case agentbase.FieldQ:
  2077. m.ResetQ()
  2078. return nil
  2079. case agentbase.FieldA:
  2080. m.ResetA()
  2081. return nil
  2082. case agentbase.FieldChunkIndex:
  2083. m.ResetChunkIndex()
  2084. return nil
  2085. case agentbase.FieldIndexes:
  2086. m.ResetIndexes()
  2087. return nil
  2088. case agentbase.FieldDatasetID:
  2089. m.ResetDatasetID()
  2090. return nil
  2091. case agentbase.FieldCollectionID:
  2092. m.ResetCollectionID()
  2093. return nil
  2094. case agentbase.FieldSourceName:
  2095. m.ResetSourceName()
  2096. return nil
  2097. case agentbase.FieldCanWrite:
  2098. m.ResetCanWrite()
  2099. return nil
  2100. case agentbase.FieldIsOwner:
  2101. m.ResetIsOwner()
  2102. return nil
  2103. }
  2104. return fmt.Errorf("unknown AgentBase field %s", name)
  2105. }
  2106. // AddedEdges returns all edge names that were set/added in this mutation.
  2107. func (m *AgentBaseMutation) AddedEdges() []string {
  2108. edges := make([]string, 0, 1)
  2109. if m.wx_agent != nil {
  2110. edges = append(edges, agentbase.EdgeWxAgent)
  2111. }
  2112. return edges
  2113. }
  2114. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2115. // name in this mutation.
  2116. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2117. switch name {
  2118. case agentbase.EdgeWxAgent:
  2119. ids := make([]ent.Value, 0, len(m.wx_agent))
  2120. for id := range m.wx_agent {
  2121. ids = append(ids, id)
  2122. }
  2123. return ids
  2124. }
  2125. return nil
  2126. }
  2127. // RemovedEdges returns all edge names that were removed in this mutation.
  2128. func (m *AgentBaseMutation) RemovedEdges() []string {
  2129. edges := make([]string, 0, 1)
  2130. if m.removedwx_agent != nil {
  2131. edges = append(edges, agentbase.EdgeWxAgent)
  2132. }
  2133. return edges
  2134. }
  2135. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2136. // the given name in this mutation.
  2137. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2138. switch name {
  2139. case agentbase.EdgeWxAgent:
  2140. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2141. for id := range m.removedwx_agent {
  2142. ids = append(ids, id)
  2143. }
  2144. return ids
  2145. }
  2146. return nil
  2147. }
  2148. // ClearedEdges returns all edge names that were cleared in this mutation.
  2149. func (m *AgentBaseMutation) ClearedEdges() []string {
  2150. edges := make([]string, 0, 1)
  2151. if m.clearedwx_agent {
  2152. edges = append(edges, agentbase.EdgeWxAgent)
  2153. }
  2154. return edges
  2155. }
  2156. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2157. // was cleared in this mutation.
  2158. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2159. switch name {
  2160. case agentbase.EdgeWxAgent:
  2161. return m.clearedwx_agent
  2162. }
  2163. return false
  2164. }
  2165. // ClearEdge clears the value of the edge with the given name. It returns an error
  2166. // if that edge is not defined in the schema.
  2167. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2168. switch name {
  2169. }
  2170. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2171. }
  2172. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2173. // It returns an error if the edge is not defined in the schema.
  2174. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2175. switch name {
  2176. case agentbase.EdgeWxAgent:
  2177. m.ResetWxAgent()
  2178. return nil
  2179. }
  2180. return fmt.Errorf("unknown AgentBase edge %s", name)
  2181. }
  2182. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2183. type AliyunAvatarMutation struct {
  2184. config
  2185. op Op
  2186. typ string
  2187. id *uint64
  2188. created_at *time.Time
  2189. updated_at *time.Time
  2190. deleted_at *time.Time
  2191. user_id *uint64
  2192. adduser_id *int64
  2193. biz_id *string
  2194. access_key_id *string
  2195. access_key_secret *string
  2196. app_id *string
  2197. tenant_id *uint64
  2198. addtenant_id *int64
  2199. response *string
  2200. token *string
  2201. session_id *string
  2202. clearedFields map[string]struct{}
  2203. done bool
  2204. oldValue func(context.Context) (*AliyunAvatar, error)
  2205. predicates []predicate.AliyunAvatar
  2206. }
  2207. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2208. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2209. type aliyunavatarOption func(*AliyunAvatarMutation)
  2210. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2211. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2212. m := &AliyunAvatarMutation{
  2213. config: c,
  2214. op: op,
  2215. typ: TypeAliyunAvatar,
  2216. clearedFields: make(map[string]struct{}),
  2217. }
  2218. for _, opt := range opts {
  2219. opt(m)
  2220. }
  2221. return m
  2222. }
  2223. // withAliyunAvatarID sets the ID field of the mutation.
  2224. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2225. return func(m *AliyunAvatarMutation) {
  2226. var (
  2227. err error
  2228. once sync.Once
  2229. value *AliyunAvatar
  2230. )
  2231. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2232. once.Do(func() {
  2233. if m.done {
  2234. err = errors.New("querying old values post mutation is not allowed")
  2235. } else {
  2236. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2237. }
  2238. })
  2239. return value, err
  2240. }
  2241. m.id = &id
  2242. }
  2243. }
  2244. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2245. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2246. return func(m *AliyunAvatarMutation) {
  2247. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2248. return node, nil
  2249. }
  2250. m.id = &node.ID
  2251. }
  2252. }
  2253. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2254. // executed in a transaction (ent.Tx), a transactional client is returned.
  2255. func (m AliyunAvatarMutation) Client() *Client {
  2256. client := &Client{config: m.config}
  2257. client.init()
  2258. return client
  2259. }
  2260. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2261. // it returns an error otherwise.
  2262. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2263. if _, ok := m.driver.(*txDriver); !ok {
  2264. return nil, errors.New("ent: mutation is not running in a transaction")
  2265. }
  2266. tx := &Tx{config: m.config}
  2267. tx.init()
  2268. return tx, nil
  2269. }
  2270. // SetID sets the value of the id field. Note that this
  2271. // operation is only accepted on creation of AliyunAvatar entities.
  2272. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2273. m.id = &id
  2274. }
  2275. // ID returns the ID value in the mutation. Note that the ID is only available
  2276. // if it was provided to the builder or after it was returned from the database.
  2277. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2278. if m.id == nil {
  2279. return
  2280. }
  2281. return *m.id, true
  2282. }
  2283. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2284. // That means, if the mutation is applied within a transaction with an isolation level such
  2285. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2286. // or updated by the mutation.
  2287. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2288. switch {
  2289. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2290. id, exists := m.ID()
  2291. if exists {
  2292. return []uint64{id}, nil
  2293. }
  2294. fallthrough
  2295. case m.op.Is(OpUpdate | OpDelete):
  2296. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2297. default:
  2298. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2299. }
  2300. }
  2301. // SetCreatedAt sets the "created_at" field.
  2302. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2303. m.created_at = &t
  2304. }
  2305. // CreatedAt returns the value of the "created_at" field in the mutation.
  2306. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2307. v := m.created_at
  2308. if v == nil {
  2309. return
  2310. }
  2311. return *v, true
  2312. }
  2313. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2314. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2316. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2317. if !m.op.Is(OpUpdateOne) {
  2318. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2319. }
  2320. if m.id == nil || m.oldValue == nil {
  2321. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2322. }
  2323. oldValue, err := m.oldValue(ctx)
  2324. if err != nil {
  2325. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2326. }
  2327. return oldValue.CreatedAt, nil
  2328. }
  2329. // ResetCreatedAt resets all changes to the "created_at" field.
  2330. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2331. m.created_at = nil
  2332. }
  2333. // SetUpdatedAt sets the "updated_at" field.
  2334. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2335. m.updated_at = &t
  2336. }
  2337. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2338. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2339. v := m.updated_at
  2340. if v == nil {
  2341. return
  2342. }
  2343. return *v, true
  2344. }
  2345. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2346. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2348. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2349. if !m.op.Is(OpUpdateOne) {
  2350. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2351. }
  2352. if m.id == nil || m.oldValue == nil {
  2353. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2354. }
  2355. oldValue, err := m.oldValue(ctx)
  2356. if err != nil {
  2357. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2358. }
  2359. return oldValue.UpdatedAt, nil
  2360. }
  2361. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2362. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2363. m.updated_at = nil
  2364. }
  2365. // SetDeletedAt sets the "deleted_at" field.
  2366. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2367. m.deleted_at = &t
  2368. }
  2369. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2370. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2371. v := m.deleted_at
  2372. if v == nil {
  2373. return
  2374. }
  2375. return *v, true
  2376. }
  2377. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2378. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2380. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2381. if !m.op.Is(OpUpdateOne) {
  2382. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2383. }
  2384. if m.id == nil || m.oldValue == nil {
  2385. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2386. }
  2387. oldValue, err := m.oldValue(ctx)
  2388. if err != nil {
  2389. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2390. }
  2391. return oldValue.DeletedAt, nil
  2392. }
  2393. // ClearDeletedAt clears the value of the "deleted_at" field.
  2394. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2395. m.deleted_at = nil
  2396. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2397. }
  2398. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2399. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2400. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2401. return ok
  2402. }
  2403. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2404. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2405. m.deleted_at = nil
  2406. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2407. }
  2408. // SetUserID sets the "user_id" field.
  2409. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2410. m.user_id = &u
  2411. m.adduser_id = nil
  2412. }
  2413. // UserID returns the value of the "user_id" field in the mutation.
  2414. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2415. v := m.user_id
  2416. if v == nil {
  2417. return
  2418. }
  2419. return *v, true
  2420. }
  2421. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2422. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2424. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2425. if !m.op.Is(OpUpdateOne) {
  2426. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2427. }
  2428. if m.id == nil || m.oldValue == nil {
  2429. return v, errors.New("OldUserID requires an ID field in the mutation")
  2430. }
  2431. oldValue, err := m.oldValue(ctx)
  2432. if err != nil {
  2433. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2434. }
  2435. return oldValue.UserID, nil
  2436. }
  2437. // AddUserID adds u to the "user_id" field.
  2438. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2439. if m.adduser_id != nil {
  2440. *m.adduser_id += u
  2441. } else {
  2442. m.adduser_id = &u
  2443. }
  2444. }
  2445. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2446. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2447. v := m.adduser_id
  2448. if v == nil {
  2449. return
  2450. }
  2451. return *v, true
  2452. }
  2453. // ResetUserID resets all changes to the "user_id" field.
  2454. func (m *AliyunAvatarMutation) ResetUserID() {
  2455. m.user_id = nil
  2456. m.adduser_id = nil
  2457. }
  2458. // SetBizID sets the "biz_id" field.
  2459. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2460. m.biz_id = &s
  2461. }
  2462. // BizID returns the value of the "biz_id" field in the mutation.
  2463. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2464. v := m.biz_id
  2465. if v == nil {
  2466. return
  2467. }
  2468. return *v, true
  2469. }
  2470. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2471. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2473. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2474. if !m.op.Is(OpUpdateOne) {
  2475. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2476. }
  2477. if m.id == nil || m.oldValue == nil {
  2478. return v, errors.New("OldBizID requires an ID field in the mutation")
  2479. }
  2480. oldValue, err := m.oldValue(ctx)
  2481. if err != nil {
  2482. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2483. }
  2484. return oldValue.BizID, nil
  2485. }
  2486. // ResetBizID resets all changes to the "biz_id" field.
  2487. func (m *AliyunAvatarMutation) ResetBizID() {
  2488. m.biz_id = nil
  2489. }
  2490. // SetAccessKeyID sets the "access_key_id" field.
  2491. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2492. m.access_key_id = &s
  2493. }
  2494. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2495. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2496. v := m.access_key_id
  2497. if v == nil {
  2498. return
  2499. }
  2500. return *v, true
  2501. }
  2502. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2503. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2505. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2506. if !m.op.Is(OpUpdateOne) {
  2507. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2508. }
  2509. if m.id == nil || m.oldValue == nil {
  2510. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2511. }
  2512. oldValue, err := m.oldValue(ctx)
  2513. if err != nil {
  2514. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2515. }
  2516. return oldValue.AccessKeyID, nil
  2517. }
  2518. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2519. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2520. m.access_key_id = nil
  2521. }
  2522. // SetAccessKeySecret sets the "access_key_secret" field.
  2523. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2524. m.access_key_secret = &s
  2525. }
  2526. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2527. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2528. v := m.access_key_secret
  2529. if v == nil {
  2530. return
  2531. }
  2532. return *v, true
  2533. }
  2534. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2535. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2537. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2538. if !m.op.Is(OpUpdateOne) {
  2539. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2540. }
  2541. if m.id == nil || m.oldValue == nil {
  2542. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2543. }
  2544. oldValue, err := m.oldValue(ctx)
  2545. if err != nil {
  2546. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2547. }
  2548. return oldValue.AccessKeySecret, nil
  2549. }
  2550. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2551. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2552. m.access_key_secret = nil
  2553. }
  2554. // SetAppID sets the "app_id" field.
  2555. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2556. m.app_id = &s
  2557. }
  2558. // AppID returns the value of the "app_id" field in the mutation.
  2559. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2560. v := m.app_id
  2561. if v == nil {
  2562. return
  2563. }
  2564. return *v, true
  2565. }
  2566. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2567. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2569. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2570. if !m.op.Is(OpUpdateOne) {
  2571. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2572. }
  2573. if m.id == nil || m.oldValue == nil {
  2574. return v, errors.New("OldAppID requires an ID field in the mutation")
  2575. }
  2576. oldValue, err := m.oldValue(ctx)
  2577. if err != nil {
  2578. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2579. }
  2580. return oldValue.AppID, nil
  2581. }
  2582. // ClearAppID clears the value of the "app_id" field.
  2583. func (m *AliyunAvatarMutation) ClearAppID() {
  2584. m.app_id = nil
  2585. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2586. }
  2587. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2588. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2589. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2590. return ok
  2591. }
  2592. // ResetAppID resets all changes to the "app_id" field.
  2593. func (m *AliyunAvatarMutation) ResetAppID() {
  2594. m.app_id = nil
  2595. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2596. }
  2597. // SetTenantID sets the "tenant_id" field.
  2598. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2599. m.tenant_id = &u
  2600. m.addtenant_id = nil
  2601. }
  2602. // TenantID returns the value of the "tenant_id" field in the mutation.
  2603. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2604. v := m.tenant_id
  2605. if v == nil {
  2606. return
  2607. }
  2608. return *v, true
  2609. }
  2610. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2611. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2613. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2614. if !m.op.Is(OpUpdateOne) {
  2615. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2616. }
  2617. if m.id == nil || m.oldValue == nil {
  2618. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2619. }
  2620. oldValue, err := m.oldValue(ctx)
  2621. if err != nil {
  2622. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2623. }
  2624. return oldValue.TenantID, nil
  2625. }
  2626. // AddTenantID adds u to the "tenant_id" field.
  2627. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2628. if m.addtenant_id != nil {
  2629. *m.addtenant_id += u
  2630. } else {
  2631. m.addtenant_id = &u
  2632. }
  2633. }
  2634. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2635. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2636. v := m.addtenant_id
  2637. if v == nil {
  2638. return
  2639. }
  2640. return *v, true
  2641. }
  2642. // ResetTenantID resets all changes to the "tenant_id" field.
  2643. func (m *AliyunAvatarMutation) ResetTenantID() {
  2644. m.tenant_id = nil
  2645. m.addtenant_id = nil
  2646. }
  2647. // SetResponse sets the "response" field.
  2648. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2649. m.response = &s
  2650. }
  2651. // Response returns the value of the "response" field in the mutation.
  2652. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2653. v := m.response
  2654. if v == nil {
  2655. return
  2656. }
  2657. return *v, true
  2658. }
  2659. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2660. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2662. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2663. if !m.op.Is(OpUpdateOne) {
  2664. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2665. }
  2666. if m.id == nil || m.oldValue == nil {
  2667. return v, errors.New("OldResponse requires an ID field in the mutation")
  2668. }
  2669. oldValue, err := m.oldValue(ctx)
  2670. if err != nil {
  2671. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2672. }
  2673. return oldValue.Response, nil
  2674. }
  2675. // ResetResponse resets all changes to the "response" field.
  2676. func (m *AliyunAvatarMutation) ResetResponse() {
  2677. m.response = nil
  2678. }
  2679. // SetToken sets the "token" field.
  2680. func (m *AliyunAvatarMutation) SetToken(s string) {
  2681. m.token = &s
  2682. }
  2683. // Token returns the value of the "token" field in the mutation.
  2684. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2685. v := m.token
  2686. if v == nil {
  2687. return
  2688. }
  2689. return *v, true
  2690. }
  2691. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2692. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2694. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2695. if !m.op.Is(OpUpdateOne) {
  2696. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2697. }
  2698. if m.id == nil || m.oldValue == nil {
  2699. return v, errors.New("OldToken requires an ID field in the mutation")
  2700. }
  2701. oldValue, err := m.oldValue(ctx)
  2702. if err != nil {
  2703. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2704. }
  2705. return oldValue.Token, nil
  2706. }
  2707. // ResetToken resets all changes to the "token" field.
  2708. func (m *AliyunAvatarMutation) ResetToken() {
  2709. m.token = nil
  2710. }
  2711. // SetSessionID sets the "session_id" field.
  2712. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2713. m.session_id = &s
  2714. }
  2715. // SessionID returns the value of the "session_id" field in the mutation.
  2716. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2717. v := m.session_id
  2718. if v == nil {
  2719. return
  2720. }
  2721. return *v, true
  2722. }
  2723. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2724. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2726. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2727. if !m.op.Is(OpUpdateOne) {
  2728. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2729. }
  2730. if m.id == nil || m.oldValue == nil {
  2731. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2732. }
  2733. oldValue, err := m.oldValue(ctx)
  2734. if err != nil {
  2735. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2736. }
  2737. return oldValue.SessionID, nil
  2738. }
  2739. // ResetSessionID resets all changes to the "session_id" field.
  2740. func (m *AliyunAvatarMutation) ResetSessionID() {
  2741. m.session_id = nil
  2742. }
  2743. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2744. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2745. m.predicates = append(m.predicates, ps...)
  2746. }
  2747. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2748. // users can use type-assertion to append predicates that do not depend on any generated package.
  2749. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2750. p := make([]predicate.AliyunAvatar, len(ps))
  2751. for i := range ps {
  2752. p[i] = ps[i]
  2753. }
  2754. m.Where(p...)
  2755. }
  2756. // Op returns the operation name.
  2757. func (m *AliyunAvatarMutation) Op() Op {
  2758. return m.op
  2759. }
  2760. // SetOp allows setting the mutation operation.
  2761. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2762. m.op = op
  2763. }
  2764. // Type returns the node type of this mutation (AliyunAvatar).
  2765. func (m *AliyunAvatarMutation) Type() string {
  2766. return m.typ
  2767. }
  2768. // Fields returns all fields that were changed during this mutation. Note that in
  2769. // order to get all numeric fields that were incremented/decremented, call
  2770. // AddedFields().
  2771. func (m *AliyunAvatarMutation) Fields() []string {
  2772. fields := make([]string, 0, 12)
  2773. if m.created_at != nil {
  2774. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2775. }
  2776. if m.updated_at != nil {
  2777. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2778. }
  2779. if m.deleted_at != nil {
  2780. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2781. }
  2782. if m.user_id != nil {
  2783. fields = append(fields, aliyunavatar.FieldUserID)
  2784. }
  2785. if m.biz_id != nil {
  2786. fields = append(fields, aliyunavatar.FieldBizID)
  2787. }
  2788. if m.access_key_id != nil {
  2789. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2790. }
  2791. if m.access_key_secret != nil {
  2792. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2793. }
  2794. if m.app_id != nil {
  2795. fields = append(fields, aliyunavatar.FieldAppID)
  2796. }
  2797. if m.tenant_id != nil {
  2798. fields = append(fields, aliyunavatar.FieldTenantID)
  2799. }
  2800. if m.response != nil {
  2801. fields = append(fields, aliyunavatar.FieldResponse)
  2802. }
  2803. if m.token != nil {
  2804. fields = append(fields, aliyunavatar.FieldToken)
  2805. }
  2806. if m.session_id != nil {
  2807. fields = append(fields, aliyunavatar.FieldSessionID)
  2808. }
  2809. return fields
  2810. }
  2811. // Field returns the value of a field with the given name. The second boolean
  2812. // return value indicates that this field was not set, or was not defined in the
  2813. // schema.
  2814. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2815. switch name {
  2816. case aliyunavatar.FieldCreatedAt:
  2817. return m.CreatedAt()
  2818. case aliyunavatar.FieldUpdatedAt:
  2819. return m.UpdatedAt()
  2820. case aliyunavatar.FieldDeletedAt:
  2821. return m.DeletedAt()
  2822. case aliyunavatar.FieldUserID:
  2823. return m.UserID()
  2824. case aliyunavatar.FieldBizID:
  2825. return m.BizID()
  2826. case aliyunavatar.FieldAccessKeyID:
  2827. return m.AccessKeyID()
  2828. case aliyunavatar.FieldAccessKeySecret:
  2829. return m.AccessKeySecret()
  2830. case aliyunavatar.FieldAppID:
  2831. return m.AppID()
  2832. case aliyunavatar.FieldTenantID:
  2833. return m.TenantID()
  2834. case aliyunavatar.FieldResponse:
  2835. return m.Response()
  2836. case aliyunavatar.FieldToken:
  2837. return m.Token()
  2838. case aliyunavatar.FieldSessionID:
  2839. return m.SessionID()
  2840. }
  2841. return nil, false
  2842. }
  2843. // OldField returns the old value of the field from the database. An error is
  2844. // returned if the mutation operation is not UpdateOne, or the query to the
  2845. // database failed.
  2846. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2847. switch name {
  2848. case aliyunavatar.FieldCreatedAt:
  2849. return m.OldCreatedAt(ctx)
  2850. case aliyunavatar.FieldUpdatedAt:
  2851. return m.OldUpdatedAt(ctx)
  2852. case aliyunavatar.FieldDeletedAt:
  2853. return m.OldDeletedAt(ctx)
  2854. case aliyunavatar.FieldUserID:
  2855. return m.OldUserID(ctx)
  2856. case aliyunavatar.FieldBizID:
  2857. return m.OldBizID(ctx)
  2858. case aliyunavatar.FieldAccessKeyID:
  2859. return m.OldAccessKeyID(ctx)
  2860. case aliyunavatar.FieldAccessKeySecret:
  2861. return m.OldAccessKeySecret(ctx)
  2862. case aliyunavatar.FieldAppID:
  2863. return m.OldAppID(ctx)
  2864. case aliyunavatar.FieldTenantID:
  2865. return m.OldTenantID(ctx)
  2866. case aliyunavatar.FieldResponse:
  2867. return m.OldResponse(ctx)
  2868. case aliyunavatar.FieldToken:
  2869. return m.OldToken(ctx)
  2870. case aliyunavatar.FieldSessionID:
  2871. return m.OldSessionID(ctx)
  2872. }
  2873. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2874. }
  2875. // SetField sets the value of a field with the given name. It returns an error if
  2876. // the field is not defined in the schema, or if the type mismatched the field
  2877. // type.
  2878. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2879. switch name {
  2880. case aliyunavatar.FieldCreatedAt:
  2881. v, ok := value.(time.Time)
  2882. if !ok {
  2883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2884. }
  2885. m.SetCreatedAt(v)
  2886. return nil
  2887. case aliyunavatar.FieldUpdatedAt:
  2888. v, ok := value.(time.Time)
  2889. if !ok {
  2890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2891. }
  2892. m.SetUpdatedAt(v)
  2893. return nil
  2894. case aliyunavatar.FieldDeletedAt:
  2895. v, ok := value.(time.Time)
  2896. if !ok {
  2897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2898. }
  2899. m.SetDeletedAt(v)
  2900. return nil
  2901. case aliyunavatar.FieldUserID:
  2902. v, ok := value.(uint64)
  2903. if !ok {
  2904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2905. }
  2906. m.SetUserID(v)
  2907. return nil
  2908. case aliyunavatar.FieldBizID:
  2909. v, ok := value.(string)
  2910. if !ok {
  2911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2912. }
  2913. m.SetBizID(v)
  2914. return nil
  2915. case aliyunavatar.FieldAccessKeyID:
  2916. v, ok := value.(string)
  2917. if !ok {
  2918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2919. }
  2920. m.SetAccessKeyID(v)
  2921. return nil
  2922. case aliyunavatar.FieldAccessKeySecret:
  2923. v, ok := value.(string)
  2924. if !ok {
  2925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2926. }
  2927. m.SetAccessKeySecret(v)
  2928. return nil
  2929. case aliyunavatar.FieldAppID:
  2930. v, ok := value.(string)
  2931. if !ok {
  2932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2933. }
  2934. m.SetAppID(v)
  2935. return nil
  2936. case aliyunavatar.FieldTenantID:
  2937. v, ok := value.(uint64)
  2938. if !ok {
  2939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2940. }
  2941. m.SetTenantID(v)
  2942. return nil
  2943. case aliyunavatar.FieldResponse:
  2944. v, ok := value.(string)
  2945. if !ok {
  2946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2947. }
  2948. m.SetResponse(v)
  2949. return nil
  2950. case aliyunavatar.FieldToken:
  2951. v, ok := value.(string)
  2952. if !ok {
  2953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2954. }
  2955. m.SetToken(v)
  2956. return nil
  2957. case aliyunavatar.FieldSessionID:
  2958. v, ok := value.(string)
  2959. if !ok {
  2960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2961. }
  2962. m.SetSessionID(v)
  2963. return nil
  2964. }
  2965. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2966. }
  2967. // AddedFields returns all numeric fields that were incremented/decremented during
  2968. // this mutation.
  2969. func (m *AliyunAvatarMutation) AddedFields() []string {
  2970. var fields []string
  2971. if m.adduser_id != nil {
  2972. fields = append(fields, aliyunavatar.FieldUserID)
  2973. }
  2974. if m.addtenant_id != nil {
  2975. fields = append(fields, aliyunavatar.FieldTenantID)
  2976. }
  2977. return fields
  2978. }
  2979. // AddedField returns the numeric value that was incremented/decremented on a field
  2980. // with the given name. The second boolean return value indicates that this field
  2981. // was not set, or was not defined in the schema.
  2982. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2983. switch name {
  2984. case aliyunavatar.FieldUserID:
  2985. return m.AddedUserID()
  2986. case aliyunavatar.FieldTenantID:
  2987. return m.AddedTenantID()
  2988. }
  2989. return nil, false
  2990. }
  2991. // AddField adds the value to the field with the given name. It returns an error if
  2992. // the field is not defined in the schema, or if the type mismatched the field
  2993. // type.
  2994. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2995. switch name {
  2996. case aliyunavatar.FieldUserID:
  2997. v, ok := value.(int64)
  2998. if !ok {
  2999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3000. }
  3001. m.AddUserID(v)
  3002. return nil
  3003. case aliyunavatar.FieldTenantID:
  3004. v, ok := value.(int64)
  3005. if !ok {
  3006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3007. }
  3008. m.AddTenantID(v)
  3009. return nil
  3010. }
  3011. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3012. }
  3013. // ClearedFields returns all nullable fields that were cleared during this
  3014. // mutation.
  3015. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3016. var fields []string
  3017. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3018. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3019. }
  3020. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3021. fields = append(fields, aliyunavatar.FieldAppID)
  3022. }
  3023. return fields
  3024. }
  3025. // FieldCleared returns a boolean indicating if a field with the given name was
  3026. // cleared in this mutation.
  3027. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3028. _, ok := m.clearedFields[name]
  3029. return ok
  3030. }
  3031. // ClearField clears the value of the field with the given name. It returns an
  3032. // error if the field is not defined in the schema.
  3033. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3034. switch name {
  3035. case aliyunavatar.FieldDeletedAt:
  3036. m.ClearDeletedAt()
  3037. return nil
  3038. case aliyunavatar.FieldAppID:
  3039. m.ClearAppID()
  3040. return nil
  3041. }
  3042. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3043. }
  3044. // ResetField resets all changes in the mutation for the field with the given name.
  3045. // It returns an error if the field is not defined in the schema.
  3046. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3047. switch name {
  3048. case aliyunavatar.FieldCreatedAt:
  3049. m.ResetCreatedAt()
  3050. return nil
  3051. case aliyunavatar.FieldUpdatedAt:
  3052. m.ResetUpdatedAt()
  3053. return nil
  3054. case aliyunavatar.FieldDeletedAt:
  3055. m.ResetDeletedAt()
  3056. return nil
  3057. case aliyunavatar.FieldUserID:
  3058. m.ResetUserID()
  3059. return nil
  3060. case aliyunavatar.FieldBizID:
  3061. m.ResetBizID()
  3062. return nil
  3063. case aliyunavatar.FieldAccessKeyID:
  3064. m.ResetAccessKeyID()
  3065. return nil
  3066. case aliyunavatar.FieldAccessKeySecret:
  3067. m.ResetAccessKeySecret()
  3068. return nil
  3069. case aliyunavatar.FieldAppID:
  3070. m.ResetAppID()
  3071. return nil
  3072. case aliyunavatar.FieldTenantID:
  3073. m.ResetTenantID()
  3074. return nil
  3075. case aliyunavatar.FieldResponse:
  3076. m.ResetResponse()
  3077. return nil
  3078. case aliyunavatar.FieldToken:
  3079. m.ResetToken()
  3080. return nil
  3081. case aliyunavatar.FieldSessionID:
  3082. m.ResetSessionID()
  3083. return nil
  3084. }
  3085. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3086. }
  3087. // AddedEdges returns all edge names that were set/added in this mutation.
  3088. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3089. edges := make([]string, 0, 0)
  3090. return edges
  3091. }
  3092. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3093. // name in this mutation.
  3094. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3095. return nil
  3096. }
  3097. // RemovedEdges returns all edge names that were removed in this mutation.
  3098. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3099. edges := make([]string, 0, 0)
  3100. return edges
  3101. }
  3102. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3103. // the given name in this mutation.
  3104. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3105. return nil
  3106. }
  3107. // ClearedEdges returns all edge names that were cleared in this mutation.
  3108. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3109. edges := make([]string, 0, 0)
  3110. return edges
  3111. }
  3112. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3113. // was cleared in this mutation.
  3114. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3115. return false
  3116. }
  3117. // ClearEdge clears the value of the edge with the given name. It returns an error
  3118. // if that edge is not defined in the schema.
  3119. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3120. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3121. }
  3122. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3123. // It returns an error if the edge is not defined in the schema.
  3124. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3125. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3126. }
  3127. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3128. type AllocAgentMutation struct {
  3129. config
  3130. op Op
  3131. typ string
  3132. id *uint64
  3133. created_at *time.Time
  3134. updated_at *time.Time
  3135. deleted_at *time.Time
  3136. user_id *string
  3137. organization_id *uint64
  3138. addorganization_id *int64
  3139. agents *[]uint64
  3140. appendagents []uint64
  3141. status *int
  3142. addstatus *int
  3143. clearedFields map[string]struct{}
  3144. done bool
  3145. oldValue func(context.Context) (*AllocAgent, error)
  3146. predicates []predicate.AllocAgent
  3147. }
  3148. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3149. // allocagentOption allows management of the mutation configuration using functional options.
  3150. type allocagentOption func(*AllocAgentMutation)
  3151. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3152. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3153. m := &AllocAgentMutation{
  3154. config: c,
  3155. op: op,
  3156. typ: TypeAllocAgent,
  3157. clearedFields: make(map[string]struct{}),
  3158. }
  3159. for _, opt := range opts {
  3160. opt(m)
  3161. }
  3162. return m
  3163. }
  3164. // withAllocAgentID sets the ID field of the mutation.
  3165. func withAllocAgentID(id uint64) allocagentOption {
  3166. return func(m *AllocAgentMutation) {
  3167. var (
  3168. err error
  3169. once sync.Once
  3170. value *AllocAgent
  3171. )
  3172. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3173. once.Do(func() {
  3174. if m.done {
  3175. err = errors.New("querying old values post mutation is not allowed")
  3176. } else {
  3177. value, err = m.Client().AllocAgent.Get(ctx, id)
  3178. }
  3179. })
  3180. return value, err
  3181. }
  3182. m.id = &id
  3183. }
  3184. }
  3185. // withAllocAgent sets the old AllocAgent of the mutation.
  3186. func withAllocAgent(node *AllocAgent) allocagentOption {
  3187. return func(m *AllocAgentMutation) {
  3188. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3189. return node, nil
  3190. }
  3191. m.id = &node.ID
  3192. }
  3193. }
  3194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3195. // executed in a transaction (ent.Tx), a transactional client is returned.
  3196. func (m AllocAgentMutation) Client() *Client {
  3197. client := &Client{config: m.config}
  3198. client.init()
  3199. return client
  3200. }
  3201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3202. // it returns an error otherwise.
  3203. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3204. if _, ok := m.driver.(*txDriver); !ok {
  3205. return nil, errors.New("ent: mutation is not running in a transaction")
  3206. }
  3207. tx := &Tx{config: m.config}
  3208. tx.init()
  3209. return tx, nil
  3210. }
  3211. // SetID sets the value of the id field. Note that this
  3212. // operation is only accepted on creation of AllocAgent entities.
  3213. func (m *AllocAgentMutation) SetID(id uint64) {
  3214. m.id = &id
  3215. }
  3216. // ID returns the ID value in the mutation. Note that the ID is only available
  3217. // if it was provided to the builder or after it was returned from the database.
  3218. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3219. if m.id == nil {
  3220. return
  3221. }
  3222. return *m.id, true
  3223. }
  3224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3225. // That means, if the mutation is applied within a transaction with an isolation level such
  3226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3227. // or updated by the mutation.
  3228. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3229. switch {
  3230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3231. id, exists := m.ID()
  3232. if exists {
  3233. return []uint64{id}, nil
  3234. }
  3235. fallthrough
  3236. case m.op.Is(OpUpdate | OpDelete):
  3237. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3238. default:
  3239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3240. }
  3241. }
  3242. // SetCreatedAt sets the "created_at" field.
  3243. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3244. m.created_at = &t
  3245. }
  3246. // CreatedAt returns the value of the "created_at" field in the mutation.
  3247. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3248. v := m.created_at
  3249. if v == nil {
  3250. return
  3251. }
  3252. return *v, true
  3253. }
  3254. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3255. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3257. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3258. if !m.op.Is(OpUpdateOne) {
  3259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3260. }
  3261. if m.id == nil || m.oldValue == nil {
  3262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3263. }
  3264. oldValue, err := m.oldValue(ctx)
  3265. if err != nil {
  3266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3267. }
  3268. return oldValue.CreatedAt, nil
  3269. }
  3270. // ResetCreatedAt resets all changes to the "created_at" field.
  3271. func (m *AllocAgentMutation) ResetCreatedAt() {
  3272. m.created_at = nil
  3273. }
  3274. // SetUpdatedAt sets the "updated_at" field.
  3275. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3276. m.updated_at = &t
  3277. }
  3278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3279. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3280. v := m.updated_at
  3281. if v == nil {
  3282. return
  3283. }
  3284. return *v, true
  3285. }
  3286. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3287. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3289. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3290. if !m.op.Is(OpUpdateOne) {
  3291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3292. }
  3293. if m.id == nil || m.oldValue == nil {
  3294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3295. }
  3296. oldValue, err := m.oldValue(ctx)
  3297. if err != nil {
  3298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3299. }
  3300. return oldValue.UpdatedAt, nil
  3301. }
  3302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3303. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3304. m.updated_at = nil
  3305. }
  3306. // SetDeletedAt sets the "deleted_at" field.
  3307. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3308. m.deleted_at = &t
  3309. }
  3310. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3311. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3312. v := m.deleted_at
  3313. if v == nil {
  3314. return
  3315. }
  3316. return *v, true
  3317. }
  3318. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3319. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3321. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3322. if !m.op.Is(OpUpdateOne) {
  3323. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3324. }
  3325. if m.id == nil || m.oldValue == nil {
  3326. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3327. }
  3328. oldValue, err := m.oldValue(ctx)
  3329. if err != nil {
  3330. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3331. }
  3332. return oldValue.DeletedAt, nil
  3333. }
  3334. // ClearDeletedAt clears the value of the "deleted_at" field.
  3335. func (m *AllocAgentMutation) ClearDeletedAt() {
  3336. m.deleted_at = nil
  3337. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3338. }
  3339. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3340. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3341. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3342. return ok
  3343. }
  3344. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3345. func (m *AllocAgentMutation) ResetDeletedAt() {
  3346. m.deleted_at = nil
  3347. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3348. }
  3349. // SetUserID sets the "user_id" field.
  3350. func (m *AllocAgentMutation) SetUserID(s string) {
  3351. m.user_id = &s
  3352. }
  3353. // UserID returns the value of the "user_id" field in the mutation.
  3354. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3355. v := m.user_id
  3356. if v == nil {
  3357. return
  3358. }
  3359. return *v, true
  3360. }
  3361. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3362. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3364. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3365. if !m.op.Is(OpUpdateOne) {
  3366. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3367. }
  3368. if m.id == nil || m.oldValue == nil {
  3369. return v, errors.New("OldUserID requires an ID field in the mutation")
  3370. }
  3371. oldValue, err := m.oldValue(ctx)
  3372. if err != nil {
  3373. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3374. }
  3375. return oldValue.UserID, nil
  3376. }
  3377. // ClearUserID clears the value of the "user_id" field.
  3378. func (m *AllocAgentMutation) ClearUserID() {
  3379. m.user_id = nil
  3380. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3381. }
  3382. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3383. func (m *AllocAgentMutation) UserIDCleared() bool {
  3384. _, ok := m.clearedFields[allocagent.FieldUserID]
  3385. return ok
  3386. }
  3387. // ResetUserID resets all changes to the "user_id" field.
  3388. func (m *AllocAgentMutation) ResetUserID() {
  3389. m.user_id = nil
  3390. delete(m.clearedFields, allocagent.FieldUserID)
  3391. }
  3392. // SetOrganizationID sets the "organization_id" field.
  3393. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3394. m.organization_id = &u
  3395. m.addorganization_id = nil
  3396. }
  3397. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3398. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3399. v := m.organization_id
  3400. if v == nil {
  3401. return
  3402. }
  3403. return *v, true
  3404. }
  3405. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3406. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3408. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3409. if !m.op.Is(OpUpdateOne) {
  3410. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3411. }
  3412. if m.id == nil || m.oldValue == nil {
  3413. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3414. }
  3415. oldValue, err := m.oldValue(ctx)
  3416. if err != nil {
  3417. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3418. }
  3419. return oldValue.OrganizationID, nil
  3420. }
  3421. // AddOrganizationID adds u to the "organization_id" field.
  3422. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3423. if m.addorganization_id != nil {
  3424. *m.addorganization_id += u
  3425. } else {
  3426. m.addorganization_id = &u
  3427. }
  3428. }
  3429. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3430. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3431. v := m.addorganization_id
  3432. if v == nil {
  3433. return
  3434. }
  3435. return *v, true
  3436. }
  3437. // ClearOrganizationID clears the value of the "organization_id" field.
  3438. func (m *AllocAgentMutation) ClearOrganizationID() {
  3439. m.organization_id = nil
  3440. m.addorganization_id = nil
  3441. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3442. }
  3443. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3444. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3445. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3446. return ok
  3447. }
  3448. // ResetOrganizationID resets all changes to the "organization_id" field.
  3449. func (m *AllocAgentMutation) ResetOrganizationID() {
  3450. m.organization_id = nil
  3451. m.addorganization_id = nil
  3452. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3453. }
  3454. // SetAgents sets the "agents" field.
  3455. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3456. m.agents = &u
  3457. m.appendagents = nil
  3458. }
  3459. // Agents returns the value of the "agents" field in the mutation.
  3460. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3461. v := m.agents
  3462. if v == nil {
  3463. return
  3464. }
  3465. return *v, true
  3466. }
  3467. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3468. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3470. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3471. if !m.op.Is(OpUpdateOne) {
  3472. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3473. }
  3474. if m.id == nil || m.oldValue == nil {
  3475. return v, errors.New("OldAgents requires an ID field in the mutation")
  3476. }
  3477. oldValue, err := m.oldValue(ctx)
  3478. if err != nil {
  3479. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3480. }
  3481. return oldValue.Agents, nil
  3482. }
  3483. // AppendAgents adds u to the "agents" field.
  3484. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3485. m.appendagents = append(m.appendagents, u...)
  3486. }
  3487. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3488. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3489. if len(m.appendagents) == 0 {
  3490. return nil, false
  3491. }
  3492. return m.appendagents, true
  3493. }
  3494. // ResetAgents resets all changes to the "agents" field.
  3495. func (m *AllocAgentMutation) ResetAgents() {
  3496. m.agents = nil
  3497. m.appendagents = nil
  3498. }
  3499. // SetStatus sets the "status" field.
  3500. func (m *AllocAgentMutation) SetStatus(i int) {
  3501. m.status = &i
  3502. m.addstatus = nil
  3503. }
  3504. // Status returns the value of the "status" field in the mutation.
  3505. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3506. v := m.status
  3507. if v == nil {
  3508. return
  3509. }
  3510. return *v, true
  3511. }
  3512. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3513. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3515. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3516. if !m.op.Is(OpUpdateOne) {
  3517. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3518. }
  3519. if m.id == nil || m.oldValue == nil {
  3520. return v, errors.New("OldStatus requires an ID field in the mutation")
  3521. }
  3522. oldValue, err := m.oldValue(ctx)
  3523. if err != nil {
  3524. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3525. }
  3526. return oldValue.Status, nil
  3527. }
  3528. // AddStatus adds i to the "status" field.
  3529. func (m *AllocAgentMutation) AddStatus(i int) {
  3530. if m.addstatus != nil {
  3531. *m.addstatus += i
  3532. } else {
  3533. m.addstatus = &i
  3534. }
  3535. }
  3536. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3537. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3538. v := m.addstatus
  3539. if v == nil {
  3540. return
  3541. }
  3542. return *v, true
  3543. }
  3544. // ClearStatus clears the value of the "status" field.
  3545. func (m *AllocAgentMutation) ClearStatus() {
  3546. m.status = nil
  3547. m.addstatus = nil
  3548. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3549. }
  3550. // StatusCleared returns if the "status" field was cleared in this mutation.
  3551. func (m *AllocAgentMutation) StatusCleared() bool {
  3552. _, ok := m.clearedFields[allocagent.FieldStatus]
  3553. return ok
  3554. }
  3555. // ResetStatus resets all changes to the "status" field.
  3556. func (m *AllocAgentMutation) ResetStatus() {
  3557. m.status = nil
  3558. m.addstatus = nil
  3559. delete(m.clearedFields, allocagent.FieldStatus)
  3560. }
  3561. // Where appends a list predicates to the AllocAgentMutation builder.
  3562. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3563. m.predicates = append(m.predicates, ps...)
  3564. }
  3565. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3566. // users can use type-assertion to append predicates that do not depend on any generated package.
  3567. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3568. p := make([]predicate.AllocAgent, len(ps))
  3569. for i := range ps {
  3570. p[i] = ps[i]
  3571. }
  3572. m.Where(p...)
  3573. }
  3574. // Op returns the operation name.
  3575. func (m *AllocAgentMutation) Op() Op {
  3576. return m.op
  3577. }
  3578. // SetOp allows setting the mutation operation.
  3579. func (m *AllocAgentMutation) SetOp(op Op) {
  3580. m.op = op
  3581. }
  3582. // Type returns the node type of this mutation (AllocAgent).
  3583. func (m *AllocAgentMutation) Type() string {
  3584. return m.typ
  3585. }
  3586. // Fields returns all fields that were changed during this mutation. Note that in
  3587. // order to get all numeric fields that were incremented/decremented, call
  3588. // AddedFields().
  3589. func (m *AllocAgentMutation) Fields() []string {
  3590. fields := make([]string, 0, 7)
  3591. if m.created_at != nil {
  3592. fields = append(fields, allocagent.FieldCreatedAt)
  3593. }
  3594. if m.updated_at != nil {
  3595. fields = append(fields, allocagent.FieldUpdatedAt)
  3596. }
  3597. if m.deleted_at != nil {
  3598. fields = append(fields, allocagent.FieldDeletedAt)
  3599. }
  3600. if m.user_id != nil {
  3601. fields = append(fields, allocagent.FieldUserID)
  3602. }
  3603. if m.organization_id != nil {
  3604. fields = append(fields, allocagent.FieldOrganizationID)
  3605. }
  3606. if m.agents != nil {
  3607. fields = append(fields, allocagent.FieldAgents)
  3608. }
  3609. if m.status != nil {
  3610. fields = append(fields, allocagent.FieldStatus)
  3611. }
  3612. return fields
  3613. }
  3614. // Field returns the value of a field with the given name. The second boolean
  3615. // return value indicates that this field was not set, or was not defined in the
  3616. // schema.
  3617. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3618. switch name {
  3619. case allocagent.FieldCreatedAt:
  3620. return m.CreatedAt()
  3621. case allocagent.FieldUpdatedAt:
  3622. return m.UpdatedAt()
  3623. case allocagent.FieldDeletedAt:
  3624. return m.DeletedAt()
  3625. case allocagent.FieldUserID:
  3626. return m.UserID()
  3627. case allocagent.FieldOrganizationID:
  3628. return m.OrganizationID()
  3629. case allocagent.FieldAgents:
  3630. return m.Agents()
  3631. case allocagent.FieldStatus:
  3632. return m.Status()
  3633. }
  3634. return nil, false
  3635. }
  3636. // OldField returns the old value of the field from the database. An error is
  3637. // returned if the mutation operation is not UpdateOne, or the query to the
  3638. // database failed.
  3639. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3640. switch name {
  3641. case allocagent.FieldCreatedAt:
  3642. return m.OldCreatedAt(ctx)
  3643. case allocagent.FieldUpdatedAt:
  3644. return m.OldUpdatedAt(ctx)
  3645. case allocagent.FieldDeletedAt:
  3646. return m.OldDeletedAt(ctx)
  3647. case allocagent.FieldUserID:
  3648. return m.OldUserID(ctx)
  3649. case allocagent.FieldOrganizationID:
  3650. return m.OldOrganizationID(ctx)
  3651. case allocagent.FieldAgents:
  3652. return m.OldAgents(ctx)
  3653. case allocagent.FieldStatus:
  3654. return m.OldStatus(ctx)
  3655. }
  3656. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3657. }
  3658. // SetField sets the value of a field with the given name. It returns an error if
  3659. // the field is not defined in the schema, or if the type mismatched the field
  3660. // type.
  3661. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3662. switch name {
  3663. case allocagent.FieldCreatedAt:
  3664. v, ok := value.(time.Time)
  3665. if !ok {
  3666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3667. }
  3668. m.SetCreatedAt(v)
  3669. return nil
  3670. case allocagent.FieldUpdatedAt:
  3671. v, ok := value.(time.Time)
  3672. if !ok {
  3673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3674. }
  3675. m.SetUpdatedAt(v)
  3676. return nil
  3677. case allocagent.FieldDeletedAt:
  3678. v, ok := value.(time.Time)
  3679. if !ok {
  3680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3681. }
  3682. m.SetDeletedAt(v)
  3683. return nil
  3684. case allocagent.FieldUserID:
  3685. v, ok := value.(string)
  3686. if !ok {
  3687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3688. }
  3689. m.SetUserID(v)
  3690. return nil
  3691. case allocagent.FieldOrganizationID:
  3692. v, ok := value.(uint64)
  3693. if !ok {
  3694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3695. }
  3696. m.SetOrganizationID(v)
  3697. return nil
  3698. case allocagent.FieldAgents:
  3699. v, ok := value.([]uint64)
  3700. if !ok {
  3701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3702. }
  3703. m.SetAgents(v)
  3704. return nil
  3705. case allocagent.FieldStatus:
  3706. v, ok := value.(int)
  3707. if !ok {
  3708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3709. }
  3710. m.SetStatus(v)
  3711. return nil
  3712. }
  3713. return fmt.Errorf("unknown AllocAgent field %s", name)
  3714. }
  3715. // AddedFields returns all numeric fields that were incremented/decremented during
  3716. // this mutation.
  3717. func (m *AllocAgentMutation) AddedFields() []string {
  3718. var fields []string
  3719. if m.addorganization_id != nil {
  3720. fields = append(fields, allocagent.FieldOrganizationID)
  3721. }
  3722. if m.addstatus != nil {
  3723. fields = append(fields, allocagent.FieldStatus)
  3724. }
  3725. return fields
  3726. }
  3727. // AddedField returns the numeric value that was incremented/decremented on a field
  3728. // with the given name. The second boolean return value indicates that this field
  3729. // was not set, or was not defined in the schema.
  3730. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3731. switch name {
  3732. case allocagent.FieldOrganizationID:
  3733. return m.AddedOrganizationID()
  3734. case allocagent.FieldStatus:
  3735. return m.AddedStatus()
  3736. }
  3737. return nil, false
  3738. }
  3739. // AddField adds the value to the field with the given name. It returns an error if
  3740. // the field is not defined in the schema, or if the type mismatched the field
  3741. // type.
  3742. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3743. switch name {
  3744. case allocagent.FieldOrganizationID:
  3745. v, ok := value.(int64)
  3746. if !ok {
  3747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3748. }
  3749. m.AddOrganizationID(v)
  3750. return nil
  3751. case allocagent.FieldStatus:
  3752. v, ok := value.(int)
  3753. if !ok {
  3754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3755. }
  3756. m.AddStatus(v)
  3757. return nil
  3758. }
  3759. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3760. }
  3761. // ClearedFields returns all nullable fields that were cleared during this
  3762. // mutation.
  3763. func (m *AllocAgentMutation) ClearedFields() []string {
  3764. var fields []string
  3765. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3766. fields = append(fields, allocagent.FieldDeletedAt)
  3767. }
  3768. if m.FieldCleared(allocagent.FieldUserID) {
  3769. fields = append(fields, allocagent.FieldUserID)
  3770. }
  3771. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3772. fields = append(fields, allocagent.FieldOrganizationID)
  3773. }
  3774. if m.FieldCleared(allocagent.FieldStatus) {
  3775. fields = append(fields, allocagent.FieldStatus)
  3776. }
  3777. return fields
  3778. }
  3779. // FieldCleared returns a boolean indicating if a field with the given name was
  3780. // cleared in this mutation.
  3781. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3782. _, ok := m.clearedFields[name]
  3783. return ok
  3784. }
  3785. // ClearField clears the value of the field with the given name. It returns an
  3786. // error if the field is not defined in the schema.
  3787. func (m *AllocAgentMutation) ClearField(name string) error {
  3788. switch name {
  3789. case allocagent.FieldDeletedAt:
  3790. m.ClearDeletedAt()
  3791. return nil
  3792. case allocagent.FieldUserID:
  3793. m.ClearUserID()
  3794. return nil
  3795. case allocagent.FieldOrganizationID:
  3796. m.ClearOrganizationID()
  3797. return nil
  3798. case allocagent.FieldStatus:
  3799. m.ClearStatus()
  3800. return nil
  3801. }
  3802. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3803. }
  3804. // ResetField resets all changes in the mutation for the field with the given name.
  3805. // It returns an error if the field is not defined in the schema.
  3806. func (m *AllocAgentMutation) ResetField(name string) error {
  3807. switch name {
  3808. case allocagent.FieldCreatedAt:
  3809. m.ResetCreatedAt()
  3810. return nil
  3811. case allocagent.FieldUpdatedAt:
  3812. m.ResetUpdatedAt()
  3813. return nil
  3814. case allocagent.FieldDeletedAt:
  3815. m.ResetDeletedAt()
  3816. return nil
  3817. case allocagent.FieldUserID:
  3818. m.ResetUserID()
  3819. return nil
  3820. case allocagent.FieldOrganizationID:
  3821. m.ResetOrganizationID()
  3822. return nil
  3823. case allocagent.FieldAgents:
  3824. m.ResetAgents()
  3825. return nil
  3826. case allocagent.FieldStatus:
  3827. m.ResetStatus()
  3828. return nil
  3829. }
  3830. return fmt.Errorf("unknown AllocAgent field %s", name)
  3831. }
  3832. // AddedEdges returns all edge names that were set/added in this mutation.
  3833. func (m *AllocAgentMutation) AddedEdges() []string {
  3834. edges := make([]string, 0, 0)
  3835. return edges
  3836. }
  3837. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3838. // name in this mutation.
  3839. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3840. return nil
  3841. }
  3842. // RemovedEdges returns all edge names that were removed in this mutation.
  3843. func (m *AllocAgentMutation) RemovedEdges() []string {
  3844. edges := make([]string, 0, 0)
  3845. return edges
  3846. }
  3847. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3848. // the given name in this mutation.
  3849. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3850. return nil
  3851. }
  3852. // ClearedEdges returns all edge names that were cleared in this mutation.
  3853. func (m *AllocAgentMutation) ClearedEdges() []string {
  3854. edges := make([]string, 0, 0)
  3855. return edges
  3856. }
  3857. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3858. // was cleared in this mutation.
  3859. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3860. return false
  3861. }
  3862. // ClearEdge clears the value of the edge with the given name. It returns an error
  3863. // if that edge is not defined in the schema.
  3864. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3865. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3866. }
  3867. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3868. // It returns an error if the edge is not defined in the schema.
  3869. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3870. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3871. }
  3872. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3873. type BatchMsgMutation struct {
  3874. config
  3875. op Op
  3876. typ string
  3877. id *uint64
  3878. created_at *time.Time
  3879. updated_at *time.Time
  3880. deleted_at *time.Time
  3881. status *uint8
  3882. addstatus *int8
  3883. batch_no *string
  3884. task_name *string
  3885. fromwxid *string
  3886. msg *string
  3887. tag *string
  3888. tagids *string
  3889. total *int32
  3890. addtotal *int32
  3891. success *int32
  3892. addsuccess *int32
  3893. fail *int32
  3894. addfail *int32
  3895. start_time *time.Time
  3896. stop_time *time.Time
  3897. send_time *time.Time
  3898. _type *int32
  3899. add_type *int32
  3900. organization_id *uint64
  3901. addorganization_id *int64
  3902. clearedFields map[string]struct{}
  3903. done bool
  3904. oldValue func(context.Context) (*BatchMsg, error)
  3905. predicates []predicate.BatchMsg
  3906. }
  3907. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3908. // batchmsgOption allows management of the mutation configuration using functional options.
  3909. type batchmsgOption func(*BatchMsgMutation)
  3910. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3911. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3912. m := &BatchMsgMutation{
  3913. config: c,
  3914. op: op,
  3915. typ: TypeBatchMsg,
  3916. clearedFields: make(map[string]struct{}),
  3917. }
  3918. for _, opt := range opts {
  3919. opt(m)
  3920. }
  3921. return m
  3922. }
  3923. // withBatchMsgID sets the ID field of the mutation.
  3924. func withBatchMsgID(id uint64) batchmsgOption {
  3925. return func(m *BatchMsgMutation) {
  3926. var (
  3927. err error
  3928. once sync.Once
  3929. value *BatchMsg
  3930. )
  3931. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3932. once.Do(func() {
  3933. if m.done {
  3934. err = errors.New("querying old values post mutation is not allowed")
  3935. } else {
  3936. value, err = m.Client().BatchMsg.Get(ctx, id)
  3937. }
  3938. })
  3939. return value, err
  3940. }
  3941. m.id = &id
  3942. }
  3943. }
  3944. // withBatchMsg sets the old BatchMsg of the mutation.
  3945. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3946. return func(m *BatchMsgMutation) {
  3947. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3948. return node, nil
  3949. }
  3950. m.id = &node.ID
  3951. }
  3952. }
  3953. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3954. // executed in a transaction (ent.Tx), a transactional client is returned.
  3955. func (m BatchMsgMutation) Client() *Client {
  3956. client := &Client{config: m.config}
  3957. client.init()
  3958. return client
  3959. }
  3960. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3961. // it returns an error otherwise.
  3962. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3963. if _, ok := m.driver.(*txDriver); !ok {
  3964. return nil, errors.New("ent: mutation is not running in a transaction")
  3965. }
  3966. tx := &Tx{config: m.config}
  3967. tx.init()
  3968. return tx, nil
  3969. }
  3970. // SetID sets the value of the id field. Note that this
  3971. // operation is only accepted on creation of BatchMsg entities.
  3972. func (m *BatchMsgMutation) SetID(id uint64) {
  3973. m.id = &id
  3974. }
  3975. // ID returns the ID value in the mutation. Note that the ID is only available
  3976. // if it was provided to the builder or after it was returned from the database.
  3977. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3978. if m.id == nil {
  3979. return
  3980. }
  3981. return *m.id, true
  3982. }
  3983. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3984. // That means, if the mutation is applied within a transaction with an isolation level such
  3985. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3986. // or updated by the mutation.
  3987. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3988. switch {
  3989. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3990. id, exists := m.ID()
  3991. if exists {
  3992. return []uint64{id}, nil
  3993. }
  3994. fallthrough
  3995. case m.op.Is(OpUpdate | OpDelete):
  3996. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3997. default:
  3998. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3999. }
  4000. }
  4001. // SetCreatedAt sets the "created_at" field.
  4002. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4003. m.created_at = &t
  4004. }
  4005. // CreatedAt returns the value of the "created_at" field in the mutation.
  4006. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4007. v := m.created_at
  4008. if v == nil {
  4009. return
  4010. }
  4011. return *v, true
  4012. }
  4013. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4014. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4016. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4017. if !m.op.Is(OpUpdateOne) {
  4018. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4019. }
  4020. if m.id == nil || m.oldValue == nil {
  4021. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4022. }
  4023. oldValue, err := m.oldValue(ctx)
  4024. if err != nil {
  4025. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4026. }
  4027. return oldValue.CreatedAt, nil
  4028. }
  4029. // ResetCreatedAt resets all changes to the "created_at" field.
  4030. func (m *BatchMsgMutation) ResetCreatedAt() {
  4031. m.created_at = nil
  4032. }
  4033. // SetUpdatedAt sets the "updated_at" field.
  4034. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4035. m.updated_at = &t
  4036. }
  4037. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4038. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4039. v := m.updated_at
  4040. if v == nil {
  4041. return
  4042. }
  4043. return *v, true
  4044. }
  4045. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4046. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4048. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4049. if !m.op.Is(OpUpdateOne) {
  4050. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4051. }
  4052. if m.id == nil || m.oldValue == nil {
  4053. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4054. }
  4055. oldValue, err := m.oldValue(ctx)
  4056. if err != nil {
  4057. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4058. }
  4059. return oldValue.UpdatedAt, nil
  4060. }
  4061. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4062. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4063. m.updated_at = nil
  4064. }
  4065. // SetDeletedAt sets the "deleted_at" field.
  4066. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4067. m.deleted_at = &t
  4068. }
  4069. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4070. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4071. v := m.deleted_at
  4072. if v == nil {
  4073. return
  4074. }
  4075. return *v, true
  4076. }
  4077. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4078. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4080. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4081. if !m.op.Is(OpUpdateOne) {
  4082. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4083. }
  4084. if m.id == nil || m.oldValue == nil {
  4085. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4086. }
  4087. oldValue, err := m.oldValue(ctx)
  4088. if err != nil {
  4089. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4090. }
  4091. return oldValue.DeletedAt, nil
  4092. }
  4093. // ClearDeletedAt clears the value of the "deleted_at" field.
  4094. func (m *BatchMsgMutation) ClearDeletedAt() {
  4095. m.deleted_at = nil
  4096. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4097. }
  4098. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4099. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4100. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4101. return ok
  4102. }
  4103. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4104. func (m *BatchMsgMutation) ResetDeletedAt() {
  4105. m.deleted_at = nil
  4106. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4107. }
  4108. // SetStatus sets the "status" field.
  4109. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4110. m.status = &u
  4111. m.addstatus = nil
  4112. }
  4113. // Status returns the value of the "status" field in the mutation.
  4114. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4115. v := m.status
  4116. if v == nil {
  4117. return
  4118. }
  4119. return *v, true
  4120. }
  4121. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4122. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4124. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4125. if !m.op.Is(OpUpdateOne) {
  4126. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4127. }
  4128. if m.id == nil || m.oldValue == nil {
  4129. return v, errors.New("OldStatus requires an ID field in the mutation")
  4130. }
  4131. oldValue, err := m.oldValue(ctx)
  4132. if err != nil {
  4133. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4134. }
  4135. return oldValue.Status, nil
  4136. }
  4137. // AddStatus adds u to the "status" field.
  4138. func (m *BatchMsgMutation) AddStatus(u int8) {
  4139. if m.addstatus != nil {
  4140. *m.addstatus += u
  4141. } else {
  4142. m.addstatus = &u
  4143. }
  4144. }
  4145. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4146. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4147. v := m.addstatus
  4148. if v == nil {
  4149. return
  4150. }
  4151. return *v, true
  4152. }
  4153. // ClearStatus clears the value of the "status" field.
  4154. func (m *BatchMsgMutation) ClearStatus() {
  4155. m.status = nil
  4156. m.addstatus = nil
  4157. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4158. }
  4159. // StatusCleared returns if the "status" field was cleared in this mutation.
  4160. func (m *BatchMsgMutation) StatusCleared() bool {
  4161. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4162. return ok
  4163. }
  4164. // ResetStatus resets all changes to the "status" field.
  4165. func (m *BatchMsgMutation) ResetStatus() {
  4166. m.status = nil
  4167. m.addstatus = nil
  4168. delete(m.clearedFields, batchmsg.FieldStatus)
  4169. }
  4170. // SetBatchNo sets the "batch_no" field.
  4171. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4172. m.batch_no = &s
  4173. }
  4174. // BatchNo returns the value of the "batch_no" field in the mutation.
  4175. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4176. v := m.batch_no
  4177. if v == nil {
  4178. return
  4179. }
  4180. return *v, true
  4181. }
  4182. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4183. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4185. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4186. if !m.op.Is(OpUpdateOne) {
  4187. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4188. }
  4189. if m.id == nil || m.oldValue == nil {
  4190. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4191. }
  4192. oldValue, err := m.oldValue(ctx)
  4193. if err != nil {
  4194. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4195. }
  4196. return oldValue.BatchNo, nil
  4197. }
  4198. // ClearBatchNo clears the value of the "batch_no" field.
  4199. func (m *BatchMsgMutation) ClearBatchNo() {
  4200. m.batch_no = nil
  4201. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4202. }
  4203. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4204. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4205. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4206. return ok
  4207. }
  4208. // ResetBatchNo resets all changes to the "batch_no" field.
  4209. func (m *BatchMsgMutation) ResetBatchNo() {
  4210. m.batch_no = nil
  4211. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4212. }
  4213. // SetTaskName sets the "task_name" field.
  4214. func (m *BatchMsgMutation) SetTaskName(s string) {
  4215. m.task_name = &s
  4216. }
  4217. // TaskName returns the value of the "task_name" field in the mutation.
  4218. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4219. v := m.task_name
  4220. if v == nil {
  4221. return
  4222. }
  4223. return *v, true
  4224. }
  4225. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4226. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4228. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4229. if !m.op.Is(OpUpdateOne) {
  4230. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4231. }
  4232. if m.id == nil || m.oldValue == nil {
  4233. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4234. }
  4235. oldValue, err := m.oldValue(ctx)
  4236. if err != nil {
  4237. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4238. }
  4239. return oldValue.TaskName, nil
  4240. }
  4241. // ClearTaskName clears the value of the "task_name" field.
  4242. func (m *BatchMsgMutation) ClearTaskName() {
  4243. m.task_name = nil
  4244. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4245. }
  4246. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4247. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4248. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4249. return ok
  4250. }
  4251. // ResetTaskName resets all changes to the "task_name" field.
  4252. func (m *BatchMsgMutation) ResetTaskName() {
  4253. m.task_name = nil
  4254. delete(m.clearedFields, batchmsg.FieldTaskName)
  4255. }
  4256. // SetFromwxid sets the "fromwxid" field.
  4257. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4258. m.fromwxid = &s
  4259. }
  4260. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4261. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4262. v := m.fromwxid
  4263. if v == nil {
  4264. return
  4265. }
  4266. return *v, true
  4267. }
  4268. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4269. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4271. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4272. if !m.op.Is(OpUpdateOne) {
  4273. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4274. }
  4275. if m.id == nil || m.oldValue == nil {
  4276. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4277. }
  4278. oldValue, err := m.oldValue(ctx)
  4279. if err != nil {
  4280. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4281. }
  4282. return oldValue.Fromwxid, nil
  4283. }
  4284. // ClearFromwxid clears the value of the "fromwxid" field.
  4285. func (m *BatchMsgMutation) ClearFromwxid() {
  4286. m.fromwxid = nil
  4287. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4288. }
  4289. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4290. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4291. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4292. return ok
  4293. }
  4294. // ResetFromwxid resets all changes to the "fromwxid" field.
  4295. func (m *BatchMsgMutation) ResetFromwxid() {
  4296. m.fromwxid = nil
  4297. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4298. }
  4299. // SetMsg sets the "msg" field.
  4300. func (m *BatchMsgMutation) SetMsg(s string) {
  4301. m.msg = &s
  4302. }
  4303. // Msg returns the value of the "msg" field in the mutation.
  4304. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4305. v := m.msg
  4306. if v == nil {
  4307. return
  4308. }
  4309. return *v, true
  4310. }
  4311. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4314. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4315. if !m.op.Is(OpUpdateOne) {
  4316. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4317. }
  4318. if m.id == nil || m.oldValue == nil {
  4319. return v, errors.New("OldMsg requires an ID field in the mutation")
  4320. }
  4321. oldValue, err := m.oldValue(ctx)
  4322. if err != nil {
  4323. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4324. }
  4325. return oldValue.Msg, nil
  4326. }
  4327. // ClearMsg clears the value of the "msg" field.
  4328. func (m *BatchMsgMutation) ClearMsg() {
  4329. m.msg = nil
  4330. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4331. }
  4332. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4333. func (m *BatchMsgMutation) MsgCleared() bool {
  4334. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4335. return ok
  4336. }
  4337. // ResetMsg resets all changes to the "msg" field.
  4338. func (m *BatchMsgMutation) ResetMsg() {
  4339. m.msg = nil
  4340. delete(m.clearedFields, batchmsg.FieldMsg)
  4341. }
  4342. // SetTag sets the "tag" field.
  4343. func (m *BatchMsgMutation) SetTag(s string) {
  4344. m.tag = &s
  4345. }
  4346. // Tag returns the value of the "tag" field in the mutation.
  4347. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4348. v := m.tag
  4349. if v == nil {
  4350. return
  4351. }
  4352. return *v, true
  4353. }
  4354. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4357. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4358. if !m.op.Is(OpUpdateOne) {
  4359. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4360. }
  4361. if m.id == nil || m.oldValue == nil {
  4362. return v, errors.New("OldTag requires an ID field in the mutation")
  4363. }
  4364. oldValue, err := m.oldValue(ctx)
  4365. if err != nil {
  4366. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4367. }
  4368. return oldValue.Tag, nil
  4369. }
  4370. // ClearTag clears the value of the "tag" field.
  4371. func (m *BatchMsgMutation) ClearTag() {
  4372. m.tag = nil
  4373. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4374. }
  4375. // TagCleared returns if the "tag" field was cleared in this mutation.
  4376. func (m *BatchMsgMutation) TagCleared() bool {
  4377. _, ok := m.clearedFields[batchmsg.FieldTag]
  4378. return ok
  4379. }
  4380. // ResetTag resets all changes to the "tag" field.
  4381. func (m *BatchMsgMutation) ResetTag() {
  4382. m.tag = nil
  4383. delete(m.clearedFields, batchmsg.FieldTag)
  4384. }
  4385. // SetTagids sets the "tagids" field.
  4386. func (m *BatchMsgMutation) SetTagids(s string) {
  4387. m.tagids = &s
  4388. }
  4389. // Tagids returns the value of the "tagids" field in the mutation.
  4390. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4391. v := m.tagids
  4392. if v == nil {
  4393. return
  4394. }
  4395. return *v, true
  4396. }
  4397. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4400. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4401. if !m.op.Is(OpUpdateOne) {
  4402. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4403. }
  4404. if m.id == nil || m.oldValue == nil {
  4405. return v, errors.New("OldTagids requires an ID field in the mutation")
  4406. }
  4407. oldValue, err := m.oldValue(ctx)
  4408. if err != nil {
  4409. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4410. }
  4411. return oldValue.Tagids, nil
  4412. }
  4413. // ClearTagids clears the value of the "tagids" field.
  4414. func (m *BatchMsgMutation) ClearTagids() {
  4415. m.tagids = nil
  4416. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4417. }
  4418. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4419. func (m *BatchMsgMutation) TagidsCleared() bool {
  4420. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4421. return ok
  4422. }
  4423. // ResetTagids resets all changes to the "tagids" field.
  4424. func (m *BatchMsgMutation) ResetTagids() {
  4425. m.tagids = nil
  4426. delete(m.clearedFields, batchmsg.FieldTagids)
  4427. }
  4428. // SetTotal sets the "total" field.
  4429. func (m *BatchMsgMutation) SetTotal(i int32) {
  4430. m.total = &i
  4431. m.addtotal = nil
  4432. }
  4433. // Total returns the value of the "total" field in the mutation.
  4434. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4435. v := m.total
  4436. if v == nil {
  4437. return
  4438. }
  4439. return *v, true
  4440. }
  4441. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4442. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4444. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4445. if !m.op.Is(OpUpdateOne) {
  4446. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4447. }
  4448. if m.id == nil || m.oldValue == nil {
  4449. return v, errors.New("OldTotal requires an ID field in the mutation")
  4450. }
  4451. oldValue, err := m.oldValue(ctx)
  4452. if err != nil {
  4453. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4454. }
  4455. return oldValue.Total, nil
  4456. }
  4457. // AddTotal adds i to the "total" field.
  4458. func (m *BatchMsgMutation) AddTotal(i int32) {
  4459. if m.addtotal != nil {
  4460. *m.addtotal += i
  4461. } else {
  4462. m.addtotal = &i
  4463. }
  4464. }
  4465. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4466. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4467. v := m.addtotal
  4468. if v == nil {
  4469. return
  4470. }
  4471. return *v, true
  4472. }
  4473. // ClearTotal clears the value of the "total" field.
  4474. func (m *BatchMsgMutation) ClearTotal() {
  4475. m.total = nil
  4476. m.addtotal = nil
  4477. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4478. }
  4479. // TotalCleared returns if the "total" field was cleared in this mutation.
  4480. func (m *BatchMsgMutation) TotalCleared() bool {
  4481. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4482. return ok
  4483. }
  4484. // ResetTotal resets all changes to the "total" field.
  4485. func (m *BatchMsgMutation) ResetTotal() {
  4486. m.total = nil
  4487. m.addtotal = nil
  4488. delete(m.clearedFields, batchmsg.FieldTotal)
  4489. }
  4490. // SetSuccess sets the "success" field.
  4491. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4492. m.success = &i
  4493. m.addsuccess = nil
  4494. }
  4495. // Success returns the value of the "success" field in the mutation.
  4496. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4497. v := m.success
  4498. if v == nil {
  4499. return
  4500. }
  4501. return *v, true
  4502. }
  4503. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4504. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4506. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4507. if !m.op.Is(OpUpdateOne) {
  4508. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4509. }
  4510. if m.id == nil || m.oldValue == nil {
  4511. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4512. }
  4513. oldValue, err := m.oldValue(ctx)
  4514. if err != nil {
  4515. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4516. }
  4517. return oldValue.Success, nil
  4518. }
  4519. // AddSuccess adds i to the "success" field.
  4520. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4521. if m.addsuccess != nil {
  4522. *m.addsuccess += i
  4523. } else {
  4524. m.addsuccess = &i
  4525. }
  4526. }
  4527. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4528. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4529. v := m.addsuccess
  4530. if v == nil {
  4531. return
  4532. }
  4533. return *v, true
  4534. }
  4535. // ClearSuccess clears the value of the "success" field.
  4536. func (m *BatchMsgMutation) ClearSuccess() {
  4537. m.success = nil
  4538. m.addsuccess = nil
  4539. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4540. }
  4541. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4542. func (m *BatchMsgMutation) SuccessCleared() bool {
  4543. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4544. return ok
  4545. }
  4546. // ResetSuccess resets all changes to the "success" field.
  4547. func (m *BatchMsgMutation) ResetSuccess() {
  4548. m.success = nil
  4549. m.addsuccess = nil
  4550. delete(m.clearedFields, batchmsg.FieldSuccess)
  4551. }
  4552. // SetFail sets the "fail" field.
  4553. func (m *BatchMsgMutation) SetFail(i int32) {
  4554. m.fail = &i
  4555. m.addfail = nil
  4556. }
  4557. // Fail returns the value of the "fail" field in the mutation.
  4558. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4559. v := m.fail
  4560. if v == nil {
  4561. return
  4562. }
  4563. return *v, true
  4564. }
  4565. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4566. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4568. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4569. if !m.op.Is(OpUpdateOne) {
  4570. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4571. }
  4572. if m.id == nil || m.oldValue == nil {
  4573. return v, errors.New("OldFail requires an ID field in the mutation")
  4574. }
  4575. oldValue, err := m.oldValue(ctx)
  4576. if err != nil {
  4577. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4578. }
  4579. return oldValue.Fail, nil
  4580. }
  4581. // AddFail adds i to the "fail" field.
  4582. func (m *BatchMsgMutation) AddFail(i int32) {
  4583. if m.addfail != nil {
  4584. *m.addfail += i
  4585. } else {
  4586. m.addfail = &i
  4587. }
  4588. }
  4589. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4590. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4591. v := m.addfail
  4592. if v == nil {
  4593. return
  4594. }
  4595. return *v, true
  4596. }
  4597. // ClearFail clears the value of the "fail" field.
  4598. func (m *BatchMsgMutation) ClearFail() {
  4599. m.fail = nil
  4600. m.addfail = nil
  4601. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4602. }
  4603. // FailCleared returns if the "fail" field was cleared in this mutation.
  4604. func (m *BatchMsgMutation) FailCleared() bool {
  4605. _, ok := m.clearedFields[batchmsg.FieldFail]
  4606. return ok
  4607. }
  4608. // ResetFail resets all changes to the "fail" field.
  4609. func (m *BatchMsgMutation) ResetFail() {
  4610. m.fail = nil
  4611. m.addfail = nil
  4612. delete(m.clearedFields, batchmsg.FieldFail)
  4613. }
  4614. // SetStartTime sets the "start_time" field.
  4615. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4616. m.start_time = &t
  4617. }
  4618. // StartTime returns the value of the "start_time" field in the mutation.
  4619. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4620. v := m.start_time
  4621. if v == nil {
  4622. return
  4623. }
  4624. return *v, true
  4625. }
  4626. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4627. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4629. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4630. if !m.op.Is(OpUpdateOne) {
  4631. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4632. }
  4633. if m.id == nil || m.oldValue == nil {
  4634. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4635. }
  4636. oldValue, err := m.oldValue(ctx)
  4637. if err != nil {
  4638. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4639. }
  4640. return oldValue.StartTime, nil
  4641. }
  4642. // ClearStartTime clears the value of the "start_time" field.
  4643. func (m *BatchMsgMutation) ClearStartTime() {
  4644. m.start_time = nil
  4645. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4646. }
  4647. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4648. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4649. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4650. return ok
  4651. }
  4652. // ResetStartTime resets all changes to the "start_time" field.
  4653. func (m *BatchMsgMutation) ResetStartTime() {
  4654. m.start_time = nil
  4655. delete(m.clearedFields, batchmsg.FieldStartTime)
  4656. }
  4657. // SetStopTime sets the "stop_time" field.
  4658. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4659. m.stop_time = &t
  4660. }
  4661. // StopTime returns the value of the "stop_time" field in the mutation.
  4662. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4663. v := m.stop_time
  4664. if v == nil {
  4665. return
  4666. }
  4667. return *v, true
  4668. }
  4669. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4670. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4672. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4673. if !m.op.Is(OpUpdateOne) {
  4674. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4675. }
  4676. if m.id == nil || m.oldValue == nil {
  4677. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4678. }
  4679. oldValue, err := m.oldValue(ctx)
  4680. if err != nil {
  4681. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4682. }
  4683. return oldValue.StopTime, nil
  4684. }
  4685. // ClearStopTime clears the value of the "stop_time" field.
  4686. func (m *BatchMsgMutation) ClearStopTime() {
  4687. m.stop_time = nil
  4688. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4689. }
  4690. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4691. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4692. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4693. return ok
  4694. }
  4695. // ResetStopTime resets all changes to the "stop_time" field.
  4696. func (m *BatchMsgMutation) ResetStopTime() {
  4697. m.stop_time = nil
  4698. delete(m.clearedFields, batchmsg.FieldStopTime)
  4699. }
  4700. // SetSendTime sets the "send_time" field.
  4701. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4702. m.send_time = &t
  4703. }
  4704. // SendTime returns the value of the "send_time" field in the mutation.
  4705. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4706. v := m.send_time
  4707. if v == nil {
  4708. return
  4709. }
  4710. return *v, true
  4711. }
  4712. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4713. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4715. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4716. if !m.op.Is(OpUpdateOne) {
  4717. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4718. }
  4719. if m.id == nil || m.oldValue == nil {
  4720. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4721. }
  4722. oldValue, err := m.oldValue(ctx)
  4723. if err != nil {
  4724. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4725. }
  4726. return oldValue.SendTime, nil
  4727. }
  4728. // ClearSendTime clears the value of the "send_time" field.
  4729. func (m *BatchMsgMutation) ClearSendTime() {
  4730. m.send_time = nil
  4731. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4732. }
  4733. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4734. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4735. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4736. return ok
  4737. }
  4738. // ResetSendTime resets all changes to the "send_time" field.
  4739. func (m *BatchMsgMutation) ResetSendTime() {
  4740. m.send_time = nil
  4741. delete(m.clearedFields, batchmsg.FieldSendTime)
  4742. }
  4743. // SetType sets the "type" field.
  4744. func (m *BatchMsgMutation) SetType(i int32) {
  4745. m._type = &i
  4746. m.add_type = nil
  4747. }
  4748. // GetType returns the value of the "type" field in the mutation.
  4749. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4750. v := m._type
  4751. if v == nil {
  4752. return
  4753. }
  4754. return *v, true
  4755. }
  4756. // OldType returns the old "type" field's value of the BatchMsg entity.
  4757. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4759. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4760. if !m.op.Is(OpUpdateOne) {
  4761. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4762. }
  4763. if m.id == nil || m.oldValue == nil {
  4764. return v, errors.New("OldType requires an ID field in the mutation")
  4765. }
  4766. oldValue, err := m.oldValue(ctx)
  4767. if err != nil {
  4768. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4769. }
  4770. return oldValue.Type, nil
  4771. }
  4772. // AddType adds i to the "type" field.
  4773. func (m *BatchMsgMutation) AddType(i int32) {
  4774. if m.add_type != nil {
  4775. *m.add_type += i
  4776. } else {
  4777. m.add_type = &i
  4778. }
  4779. }
  4780. // AddedType returns the value that was added to the "type" field in this mutation.
  4781. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4782. v := m.add_type
  4783. if v == nil {
  4784. return
  4785. }
  4786. return *v, true
  4787. }
  4788. // ClearType clears the value of the "type" field.
  4789. func (m *BatchMsgMutation) ClearType() {
  4790. m._type = nil
  4791. m.add_type = nil
  4792. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4793. }
  4794. // TypeCleared returns if the "type" field was cleared in this mutation.
  4795. func (m *BatchMsgMutation) TypeCleared() bool {
  4796. _, ok := m.clearedFields[batchmsg.FieldType]
  4797. return ok
  4798. }
  4799. // ResetType resets all changes to the "type" field.
  4800. func (m *BatchMsgMutation) ResetType() {
  4801. m._type = nil
  4802. m.add_type = nil
  4803. delete(m.clearedFields, batchmsg.FieldType)
  4804. }
  4805. // SetOrganizationID sets the "organization_id" field.
  4806. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4807. m.organization_id = &u
  4808. m.addorganization_id = nil
  4809. }
  4810. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4811. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4812. v := m.organization_id
  4813. if v == nil {
  4814. return
  4815. }
  4816. return *v, true
  4817. }
  4818. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4819. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4821. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4822. if !m.op.Is(OpUpdateOne) {
  4823. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4824. }
  4825. if m.id == nil || m.oldValue == nil {
  4826. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4827. }
  4828. oldValue, err := m.oldValue(ctx)
  4829. if err != nil {
  4830. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4831. }
  4832. return oldValue.OrganizationID, nil
  4833. }
  4834. // AddOrganizationID adds u to the "organization_id" field.
  4835. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4836. if m.addorganization_id != nil {
  4837. *m.addorganization_id += u
  4838. } else {
  4839. m.addorganization_id = &u
  4840. }
  4841. }
  4842. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4843. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4844. v := m.addorganization_id
  4845. if v == nil {
  4846. return
  4847. }
  4848. return *v, true
  4849. }
  4850. // ResetOrganizationID resets all changes to the "organization_id" field.
  4851. func (m *BatchMsgMutation) ResetOrganizationID() {
  4852. m.organization_id = nil
  4853. m.addorganization_id = nil
  4854. }
  4855. // Where appends a list predicates to the BatchMsgMutation builder.
  4856. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4857. m.predicates = append(m.predicates, ps...)
  4858. }
  4859. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4860. // users can use type-assertion to append predicates that do not depend on any generated package.
  4861. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4862. p := make([]predicate.BatchMsg, len(ps))
  4863. for i := range ps {
  4864. p[i] = ps[i]
  4865. }
  4866. m.Where(p...)
  4867. }
  4868. // Op returns the operation name.
  4869. func (m *BatchMsgMutation) Op() Op {
  4870. return m.op
  4871. }
  4872. // SetOp allows setting the mutation operation.
  4873. func (m *BatchMsgMutation) SetOp(op Op) {
  4874. m.op = op
  4875. }
  4876. // Type returns the node type of this mutation (BatchMsg).
  4877. func (m *BatchMsgMutation) Type() string {
  4878. return m.typ
  4879. }
  4880. // Fields returns all fields that were changed during this mutation. Note that in
  4881. // order to get all numeric fields that were incremented/decremented, call
  4882. // AddedFields().
  4883. func (m *BatchMsgMutation) Fields() []string {
  4884. fields := make([]string, 0, 18)
  4885. if m.created_at != nil {
  4886. fields = append(fields, batchmsg.FieldCreatedAt)
  4887. }
  4888. if m.updated_at != nil {
  4889. fields = append(fields, batchmsg.FieldUpdatedAt)
  4890. }
  4891. if m.deleted_at != nil {
  4892. fields = append(fields, batchmsg.FieldDeletedAt)
  4893. }
  4894. if m.status != nil {
  4895. fields = append(fields, batchmsg.FieldStatus)
  4896. }
  4897. if m.batch_no != nil {
  4898. fields = append(fields, batchmsg.FieldBatchNo)
  4899. }
  4900. if m.task_name != nil {
  4901. fields = append(fields, batchmsg.FieldTaskName)
  4902. }
  4903. if m.fromwxid != nil {
  4904. fields = append(fields, batchmsg.FieldFromwxid)
  4905. }
  4906. if m.msg != nil {
  4907. fields = append(fields, batchmsg.FieldMsg)
  4908. }
  4909. if m.tag != nil {
  4910. fields = append(fields, batchmsg.FieldTag)
  4911. }
  4912. if m.tagids != nil {
  4913. fields = append(fields, batchmsg.FieldTagids)
  4914. }
  4915. if m.total != nil {
  4916. fields = append(fields, batchmsg.FieldTotal)
  4917. }
  4918. if m.success != nil {
  4919. fields = append(fields, batchmsg.FieldSuccess)
  4920. }
  4921. if m.fail != nil {
  4922. fields = append(fields, batchmsg.FieldFail)
  4923. }
  4924. if m.start_time != nil {
  4925. fields = append(fields, batchmsg.FieldStartTime)
  4926. }
  4927. if m.stop_time != nil {
  4928. fields = append(fields, batchmsg.FieldStopTime)
  4929. }
  4930. if m.send_time != nil {
  4931. fields = append(fields, batchmsg.FieldSendTime)
  4932. }
  4933. if m._type != nil {
  4934. fields = append(fields, batchmsg.FieldType)
  4935. }
  4936. if m.organization_id != nil {
  4937. fields = append(fields, batchmsg.FieldOrganizationID)
  4938. }
  4939. return fields
  4940. }
  4941. // Field returns the value of a field with the given name. The second boolean
  4942. // return value indicates that this field was not set, or was not defined in the
  4943. // schema.
  4944. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4945. switch name {
  4946. case batchmsg.FieldCreatedAt:
  4947. return m.CreatedAt()
  4948. case batchmsg.FieldUpdatedAt:
  4949. return m.UpdatedAt()
  4950. case batchmsg.FieldDeletedAt:
  4951. return m.DeletedAt()
  4952. case batchmsg.FieldStatus:
  4953. return m.Status()
  4954. case batchmsg.FieldBatchNo:
  4955. return m.BatchNo()
  4956. case batchmsg.FieldTaskName:
  4957. return m.TaskName()
  4958. case batchmsg.FieldFromwxid:
  4959. return m.Fromwxid()
  4960. case batchmsg.FieldMsg:
  4961. return m.Msg()
  4962. case batchmsg.FieldTag:
  4963. return m.Tag()
  4964. case batchmsg.FieldTagids:
  4965. return m.Tagids()
  4966. case batchmsg.FieldTotal:
  4967. return m.Total()
  4968. case batchmsg.FieldSuccess:
  4969. return m.Success()
  4970. case batchmsg.FieldFail:
  4971. return m.Fail()
  4972. case batchmsg.FieldStartTime:
  4973. return m.StartTime()
  4974. case batchmsg.FieldStopTime:
  4975. return m.StopTime()
  4976. case batchmsg.FieldSendTime:
  4977. return m.SendTime()
  4978. case batchmsg.FieldType:
  4979. return m.GetType()
  4980. case batchmsg.FieldOrganizationID:
  4981. return m.OrganizationID()
  4982. }
  4983. return nil, false
  4984. }
  4985. // OldField returns the old value of the field from the database. An error is
  4986. // returned if the mutation operation is not UpdateOne, or the query to the
  4987. // database failed.
  4988. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4989. switch name {
  4990. case batchmsg.FieldCreatedAt:
  4991. return m.OldCreatedAt(ctx)
  4992. case batchmsg.FieldUpdatedAt:
  4993. return m.OldUpdatedAt(ctx)
  4994. case batchmsg.FieldDeletedAt:
  4995. return m.OldDeletedAt(ctx)
  4996. case batchmsg.FieldStatus:
  4997. return m.OldStatus(ctx)
  4998. case batchmsg.FieldBatchNo:
  4999. return m.OldBatchNo(ctx)
  5000. case batchmsg.FieldTaskName:
  5001. return m.OldTaskName(ctx)
  5002. case batchmsg.FieldFromwxid:
  5003. return m.OldFromwxid(ctx)
  5004. case batchmsg.FieldMsg:
  5005. return m.OldMsg(ctx)
  5006. case batchmsg.FieldTag:
  5007. return m.OldTag(ctx)
  5008. case batchmsg.FieldTagids:
  5009. return m.OldTagids(ctx)
  5010. case batchmsg.FieldTotal:
  5011. return m.OldTotal(ctx)
  5012. case batchmsg.FieldSuccess:
  5013. return m.OldSuccess(ctx)
  5014. case batchmsg.FieldFail:
  5015. return m.OldFail(ctx)
  5016. case batchmsg.FieldStartTime:
  5017. return m.OldStartTime(ctx)
  5018. case batchmsg.FieldStopTime:
  5019. return m.OldStopTime(ctx)
  5020. case batchmsg.FieldSendTime:
  5021. return m.OldSendTime(ctx)
  5022. case batchmsg.FieldType:
  5023. return m.OldType(ctx)
  5024. case batchmsg.FieldOrganizationID:
  5025. return m.OldOrganizationID(ctx)
  5026. }
  5027. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5028. }
  5029. // SetField sets the value of a field with the given name. It returns an error if
  5030. // the field is not defined in the schema, or if the type mismatched the field
  5031. // type.
  5032. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5033. switch name {
  5034. case batchmsg.FieldCreatedAt:
  5035. v, ok := value.(time.Time)
  5036. if !ok {
  5037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5038. }
  5039. m.SetCreatedAt(v)
  5040. return nil
  5041. case batchmsg.FieldUpdatedAt:
  5042. v, ok := value.(time.Time)
  5043. if !ok {
  5044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5045. }
  5046. m.SetUpdatedAt(v)
  5047. return nil
  5048. case batchmsg.FieldDeletedAt:
  5049. v, ok := value.(time.Time)
  5050. if !ok {
  5051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5052. }
  5053. m.SetDeletedAt(v)
  5054. return nil
  5055. case batchmsg.FieldStatus:
  5056. v, ok := value.(uint8)
  5057. if !ok {
  5058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5059. }
  5060. m.SetStatus(v)
  5061. return nil
  5062. case batchmsg.FieldBatchNo:
  5063. v, ok := value.(string)
  5064. if !ok {
  5065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5066. }
  5067. m.SetBatchNo(v)
  5068. return nil
  5069. case batchmsg.FieldTaskName:
  5070. v, ok := value.(string)
  5071. if !ok {
  5072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5073. }
  5074. m.SetTaskName(v)
  5075. return nil
  5076. case batchmsg.FieldFromwxid:
  5077. v, ok := value.(string)
  5078. if !ok {
  5079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5080. }
  5081. m.SetFromwxid(v)
  5082. return nil
  5083. case batchmsg.FieldMsg:
  5084. v, ok := value.(string)
  5085. if !ok {
  5086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5087. }
  5088. m.SetMsg(v)
  5089. return nil
  5090. case batchmsg.FieldTag:
  5091. v, ok := value.(string)
  5092. if !ok {
  5093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5094. }
  5095. m.SetTag(v)
  5096. return nil
  5097. case batchmsg.FieldTagids:
  5098. v, ok := value.(string)
  5099. if !ok {
  5100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5101. }
  5102. m.SetTagids(v)
  5103. return nil
  5104. case batchmsg.FieldTotal:
  5105. v, ok := value.(int32)
  5106. if !ok {
  5107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5108. }
  5109. m.SetTotal(v)
  5110. return nil
  5111. case batchmsg.FieldSuccess:
  5112. v, ok := value.(int32)
  5113. if !ok {
  5114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5115. }
  5116. m.SetSuccess(v)
  5117. return nil
  5118. case batchmsg.FieldFail:
  5119. v, ok := value.(int32)
  5120. if !ok {
  5121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5122. }
  5123. m.SetFail(v)
  5124. return nil
  5125. case batchmsg.FieldStartTime:
  5126. v, ok := value.(time.Time)
  5127. if !ok {
  5128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5129. }
  5130. m.SetStartTime(v)
  5131. return nil
  5132. case batchmsg.FieldStopTime:
  5133. v, ok := value.(time.Time)
  5134. if !ok {
  5135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5136. }
  5137. m.SetStopTime(v)
  5138. return nil
  5139. case batchmsg.FieldSendTime:
  5140. v, ok := value.(time.Time)
  5141. if !ok {
  5142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5143. }
  5144. m.SetSendTime(v)
  5145. return nil
  5146. case batchmsg.FieldType:
  5147. v, ok := value.(int32)
  5148. if !ok {
  5149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5150. }
  5151. m.SetType(v)
  5152. return nil
  5153. case batchmsg.FieldOrganizationID:
  5154. v, ok := value.(uint64)
  5155. if !ok {
  5156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5157. }
  5158. m.SetOrganizationID(v)
  5159. return nil
  5160. }
  5161. return fmt.Errorf("unknown BatchMsg field %s", name)
  5162. }
  5163. // AddedFields returns all numeric fields that were incremented/decremented during
  5164. // this mutation.
  5165. func (m *BatchMsgMutation) AddedFields() []string {
  5166. var fields []string
  5167. if m.addstatus != nil {
  5168. fields = append(fields, batchmsg.FieldStatus)
  5169. }
  5170. if m.addtotal != nil {
  5171. fields = append(fields, batchmsg.FieldTotal)
  5172. }
  5173. if m.addsuccess != nil {
  5174. fields = append(fields, batchmsg.FieldSuccess)
  5175. }
  5176. if m.addfail != nil {
  5177. fields = append(fields, batchmsg.FieldFail)
  5178. }
  5179. if m.add_type != nil {
  5180. fields = append(fields, batchmsg.FieldType)
  5181. }
  5182. if m.addorganization_id != nil {
  5183. fields = append(fields, batchmsg.FieldOrganizationID)
  5184. }
  5185. return fields
  5186. }
  5187. // AddedField returns the numeric value that was incremented/decremented on a field
  5188. // with the given name. The second boolean return value indicates that this field
  5189. // was not set, or was not defined in the schema.
  5190. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5191. switch name {
  5192. case batchmsg.FieldStatus:
  5193. return m.AddedStatus()
  5194. case batchmsg.FieldTotal:
  5195. return m.AddedTotal()
  5196. case batchmsg.FieldSuccess:
  5197. return m.AddedSuccess()
  5198. case batchmsg.FieldFail:
  5199. return m.AddedFail()
  5200. case batchmsg.FieldType:
  5201. return m.AddedType()
  5202. case batchmsg.FieldOrganizationID:
  5203. return m.AddedOrganizationID()
  5204. }
  5205. return nil, false
  5206. }
  5207. // AddField adds the value to the field with the given name. It returns an error if
  5208. // the field is not defined in the schema, or if the type mismatched the field
  5209. // type.
  5210. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5211. switch name {
  5212. case batchmsg.FieldStatus:
  5213. v, ok := value.(int8)
  5214. if !ok {
  5215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5216. }
  5217. m.AddStatus(v)
  5218. return nil
  5219. case batchmsg.FieldTotal:
  5220. v, ok := value.(int32)
  5221. if !ok {
  5222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5223. }
  5224. m.AddTotal(v)
  5225. return nil
  5226. case batchmsg.FieldSuccess:
  5227. v, ok := value.(int32)
  5228. if !ok {
  5229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5230. }
  5231. m.AddSuccess(v)
  5232. return nil
  5233. case batchmsg.FieldFail:
  5234. v, ok := value.(int32)
  5235. if !ok {
  5236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5237. }
  5238. m.AddFail(v)
  5239. return nil
  5240. case batchmsg.FieldType:
  5241. v, ok := value.(int32)
  5242. if !ok {
  5243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5244. }
  5245. m.AddType(v)
  5246. return nil
  5247. case batchmsg.FieldOrganizationID:
  5248. v, ok := value.(int64)
  5249. if !ok {
  5250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5251. }
  5252. m.AddOrganizationID(v)
  5253. return nil
  5254. }
  5255. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5256. }
  5257. // ClearedFields returns all nullable fields that were cleared during this
  5258. // mutation.
  5259. func (m *BatchMsgMutation) ClearedFields() []string {
  5260. var fields []string
  5261. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5262. fields = append(fields, batchmsg.FieldDeletedAt)
  5263. }
  5264. if m.FieldCleared(batchmsg.FieldStatus) {
  5265. fields = append(fields, batchmsg.FieldStatus)
  5266. }
  5267. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5268. fields = append(fields, batchmsg.FieldBatchNo)
  5269. }
  5270. if m.FieldCleared(batchmsg.FieldTaskName) {
  5271. fields = append(fields, batchmsg.FieldTaskName)
  5272. }
  5273. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5274. fields = append(fields, batchmsg.FieldFromwxid)
  5275. }
  5276. if m.FieldCleared(batchmsg.FieldMsg) {
  5277. fields = append(fields, batchmsg.FieldMsg)
  5278. }
  5279. if m.FieldCleared(batchmsg.FieldTag) {
  5280. fields = append(fields, batchmsg.FieldTag)
  5281. }
  5282. if m.FieldCleared(batchmsg.FieldTagids) {
  5283. fields = append(fields, batchmsg.FieldTagids)
  5284. }
  5285. if m.FieldCleared(batchmsg.FieldTotal) {
  5286. fields = append(fields, batchmsg.FieldTotal)
  5287. }
  5288. if m.FieldCleared(batchmsg.FieldSuccess) {
  5289. fields = append(fields, batchmsg.FieldSuccess)
  5290. }
  5291. if m.FieldCleared(batchmsg.FieldFail) {
  5292. fields = append(fields, batchmsg.FieldFail)
  5293. }
  5294. if m.FieldCleared(batchmsg.FieldStartTime) {
  5295. fields = append(fields, batchmsg.FieldStartTime)
  5296. }
  5297. if m.FieldCleared(batchmsg.FieldStopTime) {
  5298. fields = append(fields, batchmsg.FieldStopTime)
  5299. }
  5300. if m.FieldCleared(batchmsg.FieldSendTime) {
  5301. fields = append(fields, batchmsg.FieldSendTime)
  5302. }
  5303. if m.FieldCleared(batchmsg.FieldType) {
  5304. fields = append(fields, batchmsg.FieldType)
  5305. }
  5306. return fields
  5307. }
  5308. // FieldCleared returns a boolean indicating if a field with the given name was
  5309. // cleared in this mutation.
  5310. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5311. _, ok := m.clearedFields[name]
  5312. return ok
  5313. }
  5314. // ClearField clears the value of the field with the given name. It returns an
  5315. // error if the field is not defined in the schema.
  5316. func (m *BatchMsgMutation) ClearField(name string) error {
  5317. switch name {
  5318. case batchmsg.FieldDeletedAt:
  5319. m.ClearDeletedAt()
  5320. return nil
  5321. case batchmsg.FieldStatus:
  5322. m.ClearStatus()
  5323. return nil
  5324. case batchmsg.FieldBatchNo:
  5325. m.ClearBatchNo()
  5326. return nil
  5327. case batchmsg.FieldTaskName:
  5328. m.ClearTaskName()
  5329. return nil
  5330. case batchmsg.FieldFromwxid:
  5331. m.ClearFromwxid()
  5332. return nil
  5333. case batchmsg.FieldMsg:
  5334. m.ClearMsg()
  5335. return nil
  5336. case batchmsg.FieldTag:
  5337. m.ClearTag()
  5338. return nil
  5339. case batchmsg.FieldTagids:
  5340. m.ClearTagids()
  5341. return nil
  5342. case batchmsg.FieldTotal:
  5343. m.ClearTotal()
  5344. return nil
  5345. case batchmsg.FieldSuccess:
  5346. m.ClearSuccess()
  5347. return nil
  5348. case batchmsg.FieldFail:
  5349. m.ClearFail()
  5350. return nil
  5351. case batchmsg.FieldStartTime:
  5352. m.ClearStartTime()
  5353. return nil
  5354. case batchmsg.FieldStopTime:
  5355. m.ClearStopTime()
  5356. return nil
  5357. case batchmsg.FieldSendTime:
  5358. m.ClearSendTime()
  5359. return nil
  5360. case batchmsg.FieldType:
  5361. m.ClearType()
  5362. return nil
  5363. }
  5364. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5365. }
  5366. // ResetField resets all changes in the mutation for the field with the given name.
  5367. // It returns an error if the field is not defined in the schema.
  5368. func (m *BatchMsgMutation) ResetField(name string) error {
  5369. switch name {
  5370. case batchmsg.FieldCreatedAt:
  5371. m.ResetCreatedAt()
  5372. return nil
  5373. case batchmsg.FieldUpdatedAt:
  5374. m.ResetUpdatedAt()
  5375. return nil
  5376. case batchmsg.FieldDeletedAt:
  5377. m.ResetDeletedAt()
  5378. return nil
  5379. case batchmsg.FieldStatus:
  5380. m.ResetStatus()
  5381. return nil
  5382. case batchmsg.FieldBatchNo:
  5383. m.ResetBatchNo()
  5384. return nil
  5385. case batchmsg.FieldTaskName:
  5386. m.ResetTaskName()
  5387. return nil
  5388. case batchmsg.FieldFromwxid:
  5389. m.ResetFromwxid()
  5390. return nil
  5391. case batchmsg.FieldMsg:
  5392. m.ResetMsg()
  5393. return nil
  5394. case batchmsg.FieldTag:
  5395. m.ResetTag()
  5396. return nil
  5397. case batchmsg.FieldTagids:
  5398. m.ResetTagids()
  5399. return nil
  5400. case batchmsg.FieldTotal:
  5401. m.ResetTotal()
  5402. return nil
  5403. case batchmsg.FieldSuccess:
  5404. m.ResetSuccess()
  5405. return nil
  5406. case batchmsg.FieldFail:
  5407. m.ResetFail()
  5408. return nil
  5409. case batchmsg.FieldStartTime:
  5410. m.ResetStartTime()
  5411. return nil
  5412. case batchmsg.FieldStopTime:
  5413. m.ResetStopTime()
  5414. return nil
  5415. case batchmsg.FieldSendTime:
  5416. m.ResetSendTime()
  5417. return nil
  5418. case batchmsg.FieldType:
  5419. m.ResetType()
  5420. return nil
  5421. case batchmsg.FieldOrganizationID:
  5422. m.ResetOrganizationID()
  5423. return nil
  5424. }
  5425. return fmt.Errorf("unknown BatchMsg field %s", name)
  5426. }
  5427. // AddedEdges returns all edge names that were set/added in this mutation.
  5428. func (m *BatchMsgMutation) AddedEdges() []string {
  5429. edges := make([]string, 0, 0)
  5430. return edges
  5431. }
  5432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5433. // name in this mutation.
  5434. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5435. return nil
  5436. }
  5437. // RemovedEdges returns all edge names that were removed in this mutation.
  5438. func (m *BatchMsgMutation) RemovedEdges() []string {
  5439. edges := make([]string, 0, 0)
  5440. return edges
  5441. }
  5442. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5443. // the given name in this mutation.
  5444. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5445. return nil
  5446. }
  5447. // ClearedEdges returns all edge names that were cleared in this mutation.
  5448. func (m *BatchMsgMutation) ClearedEdges() []string {
  5449. edges := make([]string, 0, 0)
  5450. return edges
  5451. }
  5452. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5453. // was cleared in this mutation.
  5454. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5455. return false
  5456. }
  5457. // ClearEdge clears the value of the edge with the given name. It returns an error
  5458. // if that edge is not defined in the schema.
  5459. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5460. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5461. }
  5462. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5463. // It returns an error if the edge is not defined in the schema.
  5464. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5465. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5466. }
  5467. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5468. type CategoryMutation struct {
  5469. config
  5470. op Op
  5471. typ string
  5472. id *uint64
  5473. created_at *time.Time
  5474. updated_at *time.Time
  5475. deleted_at *time.Time
  5476. name *string
  5477. organization_id *uint64
  5478. addorganization_id *int64
  5479. clearedFields map[string]struct{}
  5480. done bool
  5481. oldValue func(context.Context) (*Category, error)
  5482. predicates []predicate.Category
  5483. }
  5484. var _ ent.Mutation = (*CategoryMutation)(nil)
  5485. // categoryOption allows management of the mutation configuration using functional options.
  5486. type categoryOption func(*CategoryMutation)
  5487. // newCategoryMutation creates new mutation for the Category entity.
  5488. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5489. m := &CategoryMutation{
  5490. config: c,
  5491. op: op,
  5492. typ: TypeCategory,
  5493. clearedFields: make(map[string]struct{}),
  5494. }
  5495. for _, opt := range opts {
  5496. opt(m)
  5497. }
  5498. return m
  5499. }
  5500. // withCategoryID sets the ID field of the mutation.
  5501. func withCategoryID(id uint64) categoryOption {
  5502. return func(m *CategoryMutation) {
  5503. var (
  5504. err error
  5505. once sync.Once
  5506. value *Category
  5507. )
  5508. m.oldValue = func(ctx context.Context) (*Category, error) {
  5509. once.Do(func() {
  5510. if m.done {
  5511. err = errors.New("querying old values post mutation is not allowed")
  5512. } else {
  5513. value, err = m.Client().Category.Get(ctx, id)
  5514. }
  5515. })
  5516. return value, err
  5517. }
  5518. m.id = &id
  5519. }
  5520. }
  5521. // withCategory sets the old Category of the mutation.
  5522. func withCategory(node *Category) categoryOption {
  5523. return func(m *CategoryMutation) {
  5524. m.oldValue = func(context.Context) (*Category, error) {
  5525. return node, nil
  5526. }
  5527. m.id = &node.ID
  5528. }
  5529. }
  5530. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5531. // executed in a transaction (ent.Tx), a transactional client is returned.
  5532. func (m CategoryMutation) Client() *Client {
  5533. client := &Client{config: m.config}
  5534. client.init()
  5535. return client
  5536. }
  5537. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5538. // it returns an error otherwise.
  5539. func (m CategoryMutation) Tx() (*Tx, error) {
  5540. if _, ok := m.driver.(*txDriver); !ok {
  5541. return nil, errors.New("ent: mutation is not running in a transaction")
  5542. }
  5543. tx := &Tx{config: m.config}
  5544. tx.init()
  5545. return tx, nil
  5546. }
  5547. // SetID sets the value of the id field. Note that this
  5548. // operation is only accepted on creation of Category entities.
  5549. func (m *CategoryMutation) SetID(id uint64) {
  5550. m.id = &id
  5551. }
  5552. // ID returns the ID value in the mutation. Note that the ID is only available
  5553. // if it was provided to the builder or after it was returned from the database.
  5554. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5555. if m.id == nil {
  5556. return
  5557. }
  5558. return *m.id, true
  5559. }
  5560. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5561. // That means, if the mutation is applied within a transaction with an isolation level such
  5562. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5563. // or updated by the mutation.
  5564. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5565. switch {
  5566. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5567. id, exists := m.ID()
  5568. if exists {
  5569. return []uint64{id}, nil
  5570. }
  5571. fallthrough
  5572. case m.op.Is(OpUpdate | OpDelete):
  5573. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5574. default:
  5575. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5576. }
  5577. }
  5578. // SetCreatedAt sets the "created_at" field.
  5579. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5580. m.created_at = &t
  5581. }
  5582. // CreatedAt returns the value of the "created_at" field in the mutation.
  5583. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5584. v := m.created_at
  5585. if v == nil {
  5586. return
  5587. }
  5588. return *v, true
  5589. }
  5590. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5591. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5593. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5594. if !m.op.Is(OpUpdateOne) {
  5595. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5596. }
  5597. if m.id == nil || m.oldValue == nil {
  5598. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5599. }
  5600. oldValue, err := m.oldValue(ctx)
  5601. if err != nil {
  5602. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5603. }
  5604. return oldValue.CreatedAt, nil
  5605. }
  5606. // ResetCreatedAt resets all changes to the "created_at" field.
  5607. func (m *CategoryMutation) ResetCreatedAt() {
  5608. m.created_at = nil
  5609. }
  5610. // SetUpdatedAt sets the "updated_at" field.
  5611. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5612. m.updated_at = &t
  5613. }
  5614. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5615. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5616. v := m.updated_at
  5617. if v == nil {
  5618. return
  5619. }
  5620. return *v, true
  5621. }
  5622. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5623. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5625. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5626. if !m.op.Is(OpUpdateOne) {
  5627. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5628. }
  5629. if m.id == nil || m.oldValue == nil {
  5630. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5631. }
  5632. oldValue, err := m.oldValue(ctx)
  5633. if err != nil {
  5634. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5635. }
  5636. return oldValue.UpdatedAt, nil
  5637. }
  5638. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5639. func (m *CategoryMutation) ResetUpdatedAt() {
  5640. m.updated_at = nil
  5641. }
  5642. // SetDeletedAt sets the "deleted_at" field.
  5643. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5644. m.deleted_at = &t
  5645. }
  5646. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5647. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5648. v := m.deleted_at
  5649. if v == nil {
  5650. return
  5651. }
  5652. return *v, true
  5653. }
  5654. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5655. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5657. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5658. if !m.op.Is(OpUpdateOne) {
  5659. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5660. }
  5661. if m.id == nil || m.oldValue == nil {
  5662. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5663. }
  5664. oldValue, err := m.oldValue(ctx)
  5665. if err != nil {
  5666. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5667. }
  5668. return oldValue.DeletedAt, nil
  5669. }
  5670. // ClearDeletedAt clears the value of the "deleted_at" field.
  5671. func (m *CategoryMutation) ClearDeletedAt() {
  5672. m.deleted_at = nil
  5673. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5674. }
  5675. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5676. func (m *CategoryMutation) DeletedAtCleared() bool {
  5677. _, ok := m.clearedFields[category.FieldDeletedAt]
  5678. return ok
  5679. }
  5680. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5681. func (m *CategoryMutation) ResetDeletedAt() {
  5682. m.deleted_at = nil
  5683. delete(m.clearedFields, category.FieldDeletedAt)
  5684. }
  5685. // SetName sets the "name" field.
  5686. func (m *CategoryMutation) SetName(s string) {
  5687. m.name = &s
  5688. }
  5689. // Name returns the value of the "name" field in the mutation.
  5690. func (m *CategoryMutation) Name() (r string, exists bool) {
  5691. v := m.name
  5692. if v == nil {
  5693. return
  5694. }
  5695. return *v, true
  5696. }
  5697. // OldName returns the old "name" field's value of the Category entity.
  5698. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5700. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5701. if !m.op.Is(OpUpdateOne) {
  5702. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5703. }
  5704. if m.id == nil || m.oldValue == nil {
  5705. return v, errors.New("OldName requires an ID field in the mutation")
  5706. }
  5707. oldValue, err := m.oldValue(ctx)
  5708. if err != nil {
  5709. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5710. }
  5711. return oldValue.Name, nil
  5712. }
  5713. // ResetName resets all changes to the "name" field.
  5714. func (m *CategoryMutation) ResetName() {
  5715. m.name = nil
  5716. }
  5717. // SetOrganizationID sets the "organization_id" field.
  5718. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5719. m.organization_id = &u
  5720. m.addorganization_id = nil
  5721. }
  5722. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5723. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5724. v := m.organization_id
  5725. if v == nil {
  5726. return
  5727. }
  5728. return *v, true
  5729. }
  5730. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5731. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5733. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5734. if !m.op.Is(OpUpdateOne) {
  5735. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5736. }
  5737. if m.id == nil || m.oldValue == nil {
  5738. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5739. }
  5740. oldValue, err := m.oldValue(ctx)
  5741. if err != nil {
  5742. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5743. }
  5744. return oldValue.OrganizationID, nil
  5745. }
  5746. // AddOrganizationID adds u to the "organization_id" field.
  5747. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5748. if m.addorganization_id != nil {
  5749. *m.addorganization_id += u
  5750. } else {
  5751. m.addorganization_id = &u
  5752. }
  5753. }
  5754. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5755. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5756. v := m.addorganization_id
  5757. if v == nil {
  5758. return
  5759. }
  5760. return *v, true
  5761. }
  5762. // ResetOrganizationID resets all changes to the "organization_id" field.
  5763. func (m *CategoryMutation) ResetOrganizationID() {
  5764. m.organization_id = nil
  5765. m.addorganization_id = nil
  5766. }
  5767. // Where appends a list predicates to the CategoryMutation builder.
  5768. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5769. m.predicates = append(m.predicates, ps...)
  5770. }
  5771. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5772. // users can use type-assertion to append predicates that do not depend on any generated package.
  5773. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5774. p := make([]predicate.Category, len(ps))
  5775. for i := range ps {
  5776. p[i] = ps[i]
  5777. }
  5778. m.Where(p...)
  5779. }
  5780. // Op returns the operation name.
  5781. func (m *CategoryMutation) Op() Op {
  5782. return m.op
  5783. }
  5784. // SetOp allows setting the mutation operation.
  5785. func (m *CategoryMutation) SetOp(op Op) {
  5786. m.op = op
  5787. }
  5788. // Type returns the node type of this mutation (Category).
  5789. func (m *CategoryMutation) Type() string {
  5790. return m.typ
  5791. }
  5792. // Fields returns all fields that were changed during this mutation. Note that in
  5793. // order to get all numeric fields that were incremented/decremented, call
  5794. // AddedFields().
  5795. func (m *CategoryMutation) Fields() []string {
  5796. fields := make([]string, 0, 5)
  5797. if m.created_at != nil {
  5798. fields = append(fields, category.FieldCreatedAt)
  5799. }
  5800. if m.updated_at != nil {
  5801. fields = append(fields, category.FieldUpdatedAt)
  5802. }
  5803. if m.deleted_at != nil {
  5804. fields = append(fields, category.FieldDeletedAt)
  5805. }
  5806. if m.name != nil {
  5807. fields = append(fields, category.FieldName)
  5808. }
  5809. if m.organization_id != nil {
  5810. fields = append(fields, category.FieldOrganizationID)
  5811. }
  5812. return fields
  5813. }
  5814. // Field returns the value of a field with the given name. The second boolean
  5815. // return value indicates that this field was not set, or was not defined in the
  5816. // schema.
  5817. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5818. switch name {
  5819. case category.FieldCreatedAt:
  5820. return m.CreatedAt()
  5821. case category.FieldUpdatedAt:
  5822. return m.UpdatedAt()
  5823. case category.FieldDeletedAt:
  5824. return m.DeletedAt()
  5825. case category.FieldName:
  5826. return m.Name()
  5827. case category.FieldOrganizationID:
  5828. return m.OrganizationID()
  5829. }
  5830. return nil, false
  5831. }
  5832. // OldField returns the old value of the field from the database. An error is
  5833. // returned if the mutation operation is not UpdateOne, or the query to the
  5834. // database failed.
  5835. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5836. switch name {
  5837. case category.FieldCreatedAt:
  5838. return m.OldCreatedAt(ctx)
  5839. case category.FieldUpdatedAt:
  5840. return m.OldUpdatedAt(ctx)
  5841. case category.FieldDeletedAt:
  5842. return m.OldDeletedAt(ctx)
  5843. case category.FieldName:
  5844. return m.OldName(ctx)
  5845. case category.FieldOrganizationID:
  5846. return m.OldOrganizationID(ctx)
  5847. }
  5848. return nil, fmt.Errorf("unknown Category field %s", name)
  5849. }
  5850. // SetField sets the value of a field with the given name. It returns an error if
  5851. // the field is not defined in the schema, or if the type mismatched the field
  5852. // type.
  5853. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5854. switch name {
  5855. case category.FieldCreatedAt:
  5856. v, ok := value.(time.Time)
  5857. if !ok {
  5858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5859. }
  5860. m.SetCreatedAt(v)
  5861. return nil
  5862. case category.FieldUpdatedAt:
  5863. v, ok := value.(time.Time)
  5864. if !ok {
  5865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5866. }
  5867. m.SetUpdatedAt(v)
  5868. return nil
  5869. case category.FieldDeletedAt:
  5870. v, ok := value.(time.Time)
  5871. if !ok {
  5872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5873. }
  5874. m.SetDeletedAt(v)
  5875. return nil
  5876. case category.FieldName:
  5877. v, ok := value.(string)
  5878. if !ok {
  5879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5880. }
  5881. m.SetName(v)
  5882. return nil
  5883. case category.FieldOrganizationID:
  5884. v, ok := value.(uint64)
  5885. if !ok {
  5886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5887. }
  5888. m.SetOrganizationID(v)
  5889. return nil
  5890. }
  5891. return fmt.Errorf("unknown Category field %s", name)
  5892. }
  5893. // AddedFields returns all numeric fields that were incremented/decremented during
  5894. // this mutation.
  5895. func (m *CategoryMutation) AddedFields() []string {
  5896. var fields []string
  5897. if m.addorganization_id != nil {
  5898. fields = append(fields, category.FieldOrganizationID)
  5899. }
  5900. return fields
  5901. }
  5902. // AddedField returns the numeric value that was incremented/decremented on a field
  5903. // with the given name. The second boolean return value indicates that this field
  5904. // was not set, or was not defined in the schema.
  5905. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5906. switch name {
  5907. case category.FieldOrganizationID:
  5908. return m.AddedOrganizationID()
  5909. }
  5910. return nil, false
  5911. }
  5912. // AddField adds the value to the field with the given name. It returns an error if
  5913. // the field is not defined in the schema, or if the type mismatched the field
  5914. // type.
  5915. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5916. switch name {
  5917. case category.FieldOrganizationID:
  5918. v, ok := value.(int64)
  5919. if !ok {
  5920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5921. }
  5922. m.AddOrganizationID(v)
  5923. return nil
  5924. }
  5925. return fmt.Errorf("unknown Category numeric field %s", name)
  5926. }
  5927. // ClearedFields returns all nullable fields that were cleared during this
  5928. // mutation.
  5929. func (m *CategoryMutation) ClearedFields() []string {
  5930. var fields []string
  5931. if m.FieldCleared(category.FieldDeletedAt) {
  5932. fields = append(fields, category.FieldDeletedAt)
  5933. }
  5934. return fields
  5935. }
  5936. // FieldCleared returns a boolean indicating if a field with the given name was
  5937. // cleared in this mutation.
  5938. func (m *CategoryMutation) FieldCleared(name string) bool {
  5939. _, ok := m.clearedFields[name]
  5940. return ok
  5941. }
  5942. // ClearField clears the value of the field with the given name. It returns an
  5943. // error if the field is not defined in the schema.
  5944. func (m *CategoryMutation) ClearField(name string) error {
  5945. switch name {
  5946. case category.FieldDeletedAt:
  5947. m.ClearDeletedAt()
  5948. return nil
  5949. }
  5950. return fmt.Errorf("unknown Category nullable field %s", name)
  5951. }
  5952. // ResetField resets all changes in the mutation for the field with the given name.
  5953. // It returns an error if the field is not defined in the schema.
  5954. func (m *CategoryMutation) ResetField(name string) error {
  5955. switch name {
  5956. case category.FieldCreatedAt:
  5957. m.ResetCreatedAt()
  5958. return nil
  5959. case category.FieldUpdatedAt:
  5960. m.ResetUpdatedAt()
  5961. return nil
  5962. case category.FieldDeletedAt:
  5963. m.ResetDeletedAt()
  5964. return nil
  5965. case category.FieldName:
  5966. m.ResetName()
  5967. return nil
  5968. case category.FieldOrganizationID:
  5969. m.ResetOrganizationID()
  5970. return nil
  5971. }
  5972. return fmt.Errorf("unknown Category field %s", name)
  5973. }
  5974. // AddedEdges returns all edge names that were set/added in this mutation.
  5975. func (m *CategoryMutation) AddedEdges() []string {
  5976. edges := make([]string, 0, 0)
  5977. return edges
  5978. }
  5979. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5980. // name in this mutation.
  5981. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5982. return nil
  5983. }
  5984. // RemovedEdges returns all edge names that were removed in this mutation.
  5985. func (m *CategoryMutation) RemovedEdges() []string {
  5986. edges := make([]string, 0, 0)
  5987. return edges
  5988. }
  5989. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5990. // the given name in this mutation.
  5991. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5992. return nil
  5993. }
  5994. // ClearedEdges returns all edge names that were cleared in this mutation.
  5995. func (m *CategoryMutation) ClearedEdges() []string {
  5996. edges := make([]string, 0, 0)
  5997. return edges
  5998. }
  5999. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6000. // was cleared in this mutation.
  6001. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6002. return false
  6003. }
  6004. // ClearEdge clears the value of the edge with the given name. It returns an error
  6005. // if that edge is not defined in the schema.
  6006. func (m *CategoryMutation) ClearEdge(name string) error {
  6007. return fmt.Errorf("unknown Category unique edge %s", name)
  6008. }
  6009. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6010. // It returns an error if the edge is not defined in the schema.
  6011. func (m *CategoryMutation) ResetEdge(name string) error {
  6012. return fmt.Errorf("unknown Category edge %s", name)
  6013. }
  6014. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6015. type ChatRecordsMutation struct {
  6016. config
  6017. op Op
  6018. typ string
  6019. id *uint64
  6020. created_at *time.Time
  6021. updated_at *time.Time
  6022. deleted_at *time.Time
  6023. content *string
  6024. content_type *uint8
  6025. addcontent_type *int8
  6026. session_id *uint64
  6027. addsession_id *int64
  6028. user_id *uint64
  6029. adduser_id *int64
  6030. bot_id *uint64
  6031. addbot_id *int64
  6032. bot_type *uint8
  6033. addbot_type *int8
  6034. clearedFields map[string]struct{}
  6035. done bool
  6036. oldValue func(context.Context) (*ChatRecords, error)
  6037. predicates []predicate.ChatRecords
  6038. }
  6039. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6040. // chatrecordsOption allows management of the mutation configuration using functional options.
  6041. type chatrecordsOption func(*ChatRecordsMutation)
  6042. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6043. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6044. m := &ChatRecordsMutation{
  6045. config: c,
  6046. op: op,
  6047. typ: TypeChatRecords,
  6048. clearedFields: make(map[string]struct{}),
  6049. }
  6050. for _, opt := range opts {
  6051. opt(m)
  6052. }
  6053. return m
  6054. }
  6055. // withChatRecordsID sets the ID field of the mutation.
  6056. func withChatRecordsID(id uint64) chatrecordsOption {
  6057. return func(m *ChatRecordsMutation) {
  6058. var (
  6059. err error
  6060. once sync.Once
  6061. value *ChatRecords
  6062. )
  6063. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6064. once.Do(func() {
  6065. if m.done {
  6066. err = errors.New("querying old values post mutation is not allowed")
  6067. } else {
  6068. value, err = m.Client().ChatRecords.Get(ctx, id)
  6069. }
  6070. })
  6071. return value, err
  6072. }
  6073. m.id = &id
  6074. }
  6075. }
  6076. // withChatRecords sets the old ChatRecords of the mutation.
  6077. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6078. return func(m *ChatRecordsMutation) {
  6079. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6080. return node, nil
  6081. }
  6082. m.id = &node.ID
  6083. }
  6084. }
  6085. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6086. // executed in a transaction (ent.Tx), a transactional client is returned.
  6087. func (m ChatRecordsMutation) Client() *Client {
  6088. client := &Client{config: m.config}
  6089. client.init()
  6090. return client
  6091. }
  6092. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6093. // it returns an error otherwise.
  6094. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6095. if _, ok := m.driver.(*txDriver); !ok {
  6096. return nil, errors.New("ent: mutation is not running in a transaction")
  6097. }
  6098. tx := &Tx{config: m.config}
  6099. tx.init()
  6100. return tx, nil
  6101. }
  6102. // SetID sets the value of the id field. Note that this
  6103. // operation is only accepted on creation of ChatRecords entities.
  6104. func (m *ChatRecordsMutation) SetID(id uint64) {
  6105. m.id = &id
  6106. }
  6107. // ID returns the ID value in the mutation. Note that the ID is only available
  6108. // if it was provided to the builder or after it was returned from the database.
  6109. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6110. if m.id == nil {
  6111. return
  6112. }
  6113. return *m.id, true
  6114. }
  6115. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6116. // That means, if the mutation is applied within a transaction with an isolation level such
  6117. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6118. // or updated by the mutation.
  6119. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6120. switch {
  6121. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6122. id, exists := m.ID()
  6123. if exists {
  6124. return []uint64{id}, nil
  6125. }
  6126. fallthrough
  6127. case m.op.Is(OpUpdate | OpDelete):
  6128. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6129. default:
  6130. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6131. }
  6132. }
  6133. // SetCreatedAt sets the "created_at" field.
  6134. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6135. m.created_at = &t
  6136. }
  6137. // CreatedAt returns the value of the "created_at" field in the mutation.
  6138. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6139. v := m.created_at
  6140. if v == nil {
  6141. return
  6142. }
  6143. return *v, true
  6144. }
  6145. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6146. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6148. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6149. if !m.op.Is(OpUpdateOne) {
  6150. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6151. }
  6152. if m.id == nil || m.oldValue == nil {
  6153. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6154. }
  6155. oldValue, err := m.oldValue(ctx)
  6156. if err != nil {
  6157. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6158. }
  6159. return oldValue.CreatedAt, nil
  6160. }
  6161. // ResetCreatedAt resets all changes to the "created_at" field.
  6162. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6163. m.created_at = nil
  6164. }
  6165. // SetUpdatedAt sets the "updated_at" field.
  6166. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6167. m.updated_at = &t
  6168. }
  6169. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6170. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6171. v := m.updated_at
  6172. if v == nil {
  6173. return
  6174. }
  6175. return *v, true
  6176. }
  6177. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6178. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6180. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6181. if !m.op.Is(OpUpdateOne) {
  6182. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6183. }
  6184. if m.id == nil || m.oldValue == nil {
  6185. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6186. }
  6187. oldValue, err := m.oldValue(ctx)
  6188. if err != nil {
  6189. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6190. }
  6191. return oldValue.UpdatedAt, nil
  6192. }
  6193. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6194. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6195. m.updated_at = nil
  6196. }
  6197. // SetDeletedAt sets the "deleted_at" field.
  6198. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6199. m.deleted_at = &t
  6200. }
  6201. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6202. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6203. v := m.deleted_at
  6204. if v == nil {
  6205. return
  6206. }
  6207. return *v, true
  6208. }
  6209. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6210. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6212. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6213. if !m.op.Is(OpUpdateOne) {
  6214. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6215. }
  6216. if m.id == nil || m.oldValue == nil {
  6217. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6218. }
  6219. oldValue, err := m.oldValue(ctx)
  6220. if err != nil {
  6221. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6222. }
  6223. return oldValue.DeletedAt, nil
  6224. }
  6225. // ClearDeletedAt clears the value of the "deleted_at" field.
  6226. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6227. m.deleted_at = nil
  6228. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6229. }
  6230. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6231. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6232. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6233. return ok
  6234. }
  6235. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6236. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6237. m.deleted_at = nil
  6238. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6239. }
  6240. // SetContent sets the "content" field.
  6241. func (m *ChatRecordsMutation) SetContent(s string) {
  6242. m.content = &s
  6243. }
  6244. // Content returns the value of the "content" field in the mutation.
  6245. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6246. v := m.content
  6247. if v == nil {
  6248. return
  6249. }
  6250. return *v, true
  6251. }
  6252. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6253. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6255. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6256. if !m.op.Is(OpUpdateOne) {
  6257. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6258. }
  6259. if m.id == nil || m.oldValue == nil {
  6260. return v, errors.New("OldContent requires an ID field in the mutation")
  6261. }
  6262. oldValue, err := m.oldValue(ctx)
  6263. if err != nil {
  6264. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6265. }
  6266. return oldValue.Content, nil
  6267. }
  6268. // ResetContent resets all changes to the "content" field.
  6269. func (m *ChatRecordsMutation) ResetContent() {
  6270. m.content = nil
  6271. }
  6272. // SetContentType sets the "content_type" field.
  6273. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6274. m.content_type = &u
  6275. m.addcontent_type = nil
  6276. }
  6277. // ContentType returns the value of the "content_type" field in the mutation.
  6278. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6279. v := m.content_type
  6280. if v == nil {
  6281. return
  6282. }
  6283. return *v, true
  6284. }
  6285. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6286. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6288. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6289. if !m.op.Is(OpUpdateOne) {
  6290. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6291. }
  6292. if m.id == nil || m.oldValue == nil {
  6293. return v, errors.New("OldContentType requires an ID field in the mutation")
  6294. }
  6295. oldValue, err := m.oldValue(ctx)
  6296. if err != nil {
  6297. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6298. }
  6299. return oldValue.ContentType, nil
  6300. }
  6301. // AddContentType adds u to the "content_type" field.
  6302. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6303. if m.addcontent_type != nil {
  6304. *m.addcontent_type += u
  6305. } else {
  6306. m.addcontent_type = &u
  6307. }
  6308. }
  6309. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6310. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6311. v := m.addcontent_type
  6312. if v == nil {
  6313. return
  6314. }
  6315. return *v, true
  6316. }
  6317. // ResetContentType resets all changes to the "content_type" field.
  6318. func (m *ChatRecordsMutation) ResetContentType() {
  6319. m.content_type = nil
  6320. m.addcontent_type = nil
  6321. }
  6322. // SetSessionID sets the "session_id" field.
  6323. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6324. m.session_id = &u
  6325. m.addsession_id = nil
  6326. }
  6327. // SessionID returns the value of the "session_id" field in the mutation.
  6328. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6329. v := m.session_id
  6330. if v == nil {
  6331. return
  6332. }
  6333. return *v, true
  6334. }
  6335. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6336. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6338. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6339. if !m.op.Is(OpUpdateOne) {
  6340. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6341. }
  6342. if m.id == nil || m.oldValue == nil {
  6343. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6344. }
  6345. oldValue, err := m.oldValue(ctx)
  6346. if err != nil {
  6347. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6348. }
  6349. return oldValue.SessionID, nil
  6350. }
  6351. // AddSessionID adds u to the "session_id" field.
  6352. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6353. if m.addsession_id != nil {
  6354. *m.addsession_id += u
  6355. } else {
  6356. m.addsession_id = &u
  6357. }
  6358. }
  6359. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6360. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6361. v := m.addsession_id
  6362. if v == nil {
  6363. return
  6364. }
  6365. return *v, true
  6366. }
  6367. // ResetSessionID resets all changes to the "session_id" field.
  6368. func (m *ChatRecordsMutation) ResetSessionID() {
  6369. m.session_id = nil
  6370. m.addsession_id = nil
  6371. }
  6372. // SetUserID sets the "user_id" field.
  6373. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6374. m.user_id = &u
  6375. m.adduser_id = nil
  6376. }
  6377. // UserID returns the value of the "user_id" field in the mutation.
  6378. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6379. v := m.user_id
  6380. if v == nil {
  6381. return
  6382. }
  6383. return *v, true
  6384. }
  6385. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6386. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6388. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6389. if !m.op.Is(OpUpdateOne) {
  6390. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6391. }
  6392. if m.id == nil || m.oldValue == nil {
  6393. return v, errors.New("OldUserID requires an ID field in the mutation")
  6394. }
  6395. oldValue, err := m.oldValue(ctx)
  6396. if err != nil {
  6397. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6398. }
  6399. return oldValue.UserID, nil
  6400. }
  6401. // AddUserID adds u to the "user_id" field.
  6402. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6403. if m.adduser_id != nil {
  6404. *m.adduser_id += u
  6405. } else {
  6406. m.adduser_id = &u
  6407. }
  6408. }
  6409. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6410. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6411. v := m.adduser_id
  6412. if v == nil {
  6413. return
  6414. }
  6415. return *v, true
  6416. }
  6417. // ResetUserID resets all changes to the "user_id" field.
  6418. func (m *ChatRecordsMutation) ResetUserID() {
  6419. m.user_id = nil
  6420. m.adduser_id = nil
  6421. }
  6422. // SetBotID sets the "bot_id" field.
  6423. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6424. m.bot_id = &u
  6425. m.addbot_id = nil
  6426. }
  6427. // BotID returns the value of the "bot_id" field in the mutation.
  6428. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6429. v := m.bot_id
  6430. if v == nil {
  6431. return
  6432. }
  6433. return *v, true
  6434. }
  6435. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6436. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6438. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6439. if !m.op.Is(OpUpdateOne) {
  6440. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6441. }
  6442. if m.id == nil || m.oldValue == nil {
  6443. return v, errors.New("OldBotID requires an ID field in the mutation")
  6444. }
  6445. oldValue, err := m.oldValue(ctx)
  6446. if err != nil {
  6447. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6448. }
  6449. return oldValue.BotID, nil
  6450. }
  6451. // AddBotID adds u to the "bot_id" field.
  6452. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6453. if m.addbot_id != nil {
  6454. *m.addbot_id += u
  6455. } else {
  6456. m.addbot_id = &u
  6457. }
  6458. }
  6459. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6460. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6461. v := m.addbot_id
  6462. if v == nil {
  6463. return
  6464. }
  6465. return *v, true
  6466. }
  6467. // ResetBotID resets all changes to the "bot_id" field.
  6468. func (m *ChatRecordsMutation) ResetBotID() {
  6469. m.bot_id = nil
  6470. m.addbot_id = nil
  6471. }
  6472. // SetBotType sets the "bot_type" field.
  6473. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6474. m.bot_type = &u
  6475. m.addbot_type = nil
  6476. }
  6477. // BotType returns the value of the "bot_type" field in the mutation.
  6478. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6479. v := m.bot_type
  6480. if v == nil {
  6481. return
  6482. }
  6483. return *v, true
  6484. }
  6485. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6486. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6488. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6489. if !m.op.Is(OpUpdateOne) {
  6490. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6491. }
  6492. if m.id == nil || m.oldValue == nil {
  6493. return v, errors.New("OldBotType requires an ID field in the mutation")
  6494. }
  6495. oldValue, err := m.oldValue(ctx)
  6496. if err != nil {
  6497. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6498. }
  6499. return oldValue.BotType, nil
  6500. }
  6501. // AddBotType adds u to the "bot_type" field.
  6502. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6503. if m.addbot_type != nil {
  6504. *m.addbot_type += u
  6505. } else {
  6506. m.addbot_type = &u
  6507. }
  6508. }
  6509. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6510. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6511. v := m.addbot_type
  6512. if v == nil {
  6513. return
  6514. }
  6515. return *v, true
  6516. }
  6517. // ResetBotType resets all changes to the "bot_type" field.
  6518. func (m *ChatRecordsMutation) ResetBotType() {
  6519. m.bot_type = nil
  6520. m.addbot_type = nil
  6521. }
  6522. // Where appends a list predicates to the ChatRecordsMutation builder.
  6523. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6524. m.predicates = append(m.predicates, ps...)
  6525. }
  6526. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6527. // users can use type-assertion to append predicates that do not depend on any generated package.
  6528. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6529. p := make([]predicate.ChatRecords, len(ps))
  6530. for i := range ps {
  6531. p[i] = ps[i]
  6532. }
  6533. m.Where(p...)
  6534. }
  6535. // Op returns the operation name.
  6536. func (m *ChatRecordsMutation) Op() Op {
  6537. return m.op
  6538. }
  6539. // SetOp allows setting the mutation operation.
  6540. func (m *ChatRecordsMutation) SetOp(op Op) {
  6541. m.op = op
  6542. }
  6543. // Type returns the node type of this mutation (ChatRecords).
  6544. func (m *ChatRecordsMutation) Type() string {
  6545. return m.typ
  6546. }
  6547. // Fields returns all fields that were changed during this mutation. Note that in
  6548. // order to get all numeric fields that were incremented/decremented, call
  6549. // AddedFields().
  6550. func (m *ChatRecordsMutation) Fields() []string {
  6551. fields := make([]string, 0, 9)
  6552. if m.created_at != nil {
  6553. fields = append(fields, chatrecords.FieldCreatedAt)
  6554. }
  6555. if m.updated_at != nil {
  6556. fields = append(fields, chatrecords.FieldUpdatedAt)
  6557. }
  6558. if m.deleted_at != nil {
  6559. fields = append(fields, chatrecords.FieldDeletedAt)
  6560. }
  6561. if m.content != nil {
  6562. fields = append(fields, chatrecords.FieldContent)
  6563. }
  6564. if m.content_type != nil {
  6565. fields = append(fields, chatrecords.FieldContentType)
  6566. }
  6567. if m.session_id != nil {
  6568. fields = append(fields, chatrecords.FieldSessionID)
  6569. }
  6570. if m.user_id != nil {
  6571. fields = append(fields, chatrecords.FieldUserID)
  6572. }
  6573. if m.bot_id != nil {
  6574. fields = append(fields, chatrecords.FieldBotID)
  6575. }
  6576. if m.bot_type != nil {
  6577. fields = append(fields, chatrecords.FieldBotType)
  6578. }
  6579. return fields
  6580. }
  6581. // Field returns the value of a field with the given name. The second boolean
  6582. // return value indicates that this field was not set, or was not defined in the
  6583. // schema.
  6584. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6585. switch name {
  6586. case chatrecords.FieldCreatedAt:
  6587. return m.CreatedAt()
  6588. case chatrecords.FieldUpdatedAt:
  6589. return m.UpdatedAt()
  6590. case chatrecords.FieldDeletedAt:
  6591. return m.DeletedAt()
  6592. case chatrecords.FieldContent:
  6593. return m.Content()
  6594. case chatrecords.FieldContentType:
  6595. return m.ContentType()
  6596. case chatrecords.FieldSessionID:
  6597. return m.SessionID()
  6598. case chatrecords.FieldUserID:
  6599. return m.UserID()
  6600. case chatrecords.FieldBotID:
  6601. return m.BotID()
  6602. case chatrecords.FieldBotType:
  6603. return m.BotType()
  6604. }
  6605. return nil, false
  6606. }
  6607. // OldField returns the old value of the field from the database. An error is
  6608. // returned if the mutation operation is not UpdateOne, or the query to the
  6609. // database failed.
  6610. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6611. switch name {
  6612. case chatrecords.FieldCreatedAt:
  6613. return m.OldCreatedAt(ctx)
  6614. case chatrecords.FieldUpdatedAt:
  6615. return m.OldUpdatedAt(ctx)
  6616. case chatrecords.FieldDeletedAt:
  6617. return m.OldDeletedAt(ctx)
  6618. case chatrecords.FieldContent:
  6619. return m.OldContent(ctx)
  6620. case chatrecords.FieldContentType:
  6621. return m.OldContentType(ctx)
  6622. case chatrecords.FieldSessionID:
  6623. return m.OldSessionID(ctx)
  6624. case chatrecords.FieldUserID:
  6625. return m.OldUserID(ctx)
  6626. case chatrecords.FieldBotID:
  6627. return m.OldBotID(ctx)
  6628. case chatrecords.FieldBotType:
  6629. return m.OldBotType(ctx)
  6630. }
  6631. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6632. }
  6633. // SetField sets the value of a field with the given name. It returns an error if
  6634. // the field is not defined in the schema, or if the type mismatched the field
  6635. // type.
  6636. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6637. switch name {
  6638. case chatrecords.FieldCreatedAt:
  6639. v, ok := value.(time.Time)
  6640. if !ok {
  6641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6642. }
  6643. m.SetCreatedAt(v)
  6644. return nil
  6645. case chatrecords.FieldUpdatedAt:
  6646. v, ok := value.(time.Time)
  6647. if !ok {
  6648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6649. }
  6650. m.SetUpdatedAt(v)
  6651. return nil
  6652. case chatrecords.FieldDeletedAt:
  6653. v, ok := value.(time.Time)
  6654. if !ok {
  6655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6656. }
  6657. m.SetDeletedAt(v)
  6658. return nil
  6659. case chatrecords.FieldContent:
  6660. v, ok := value.(string)
  6661. if !ok {
  6662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6663. }
  6664. m.SetContent(v)
  6665. return nil
  6666. case chatrecords.FieldContentType:
  6667. v, ok := value.(uint8)
  6668. if !ok {
  6669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6670. }
  6671. m.SetContentType(v)
  6672. return nil
  6673. case chatrecords.FieldSessionID:
  6674. v, ok := value.(uint64)
  6675. if !ok {
  6676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6677. }
  6678. m.SetSessionID(v)
  6679. return nil
  6680. case chatrecords.FieldUserID:
  6681. v, ok := value.(uint64)
  6682. if !ok {
  6683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6684. }
  6685. m.SetUserID(v)
  6686. return nil
  6687. case chatrecords.FieldBotID:
  6688. v, ok := value.(uint64)
  6689. if !ok {
  6690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6691. }
  6692. m.SetBotID(v)
  6693. return nil
  6694. case chatrecords.FieldBotType:
  6695. v, ok := value.(uint8)
  6696. if !ok {
  6697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6698. }
  6699. m.SetBotType(v)
  6700. return nil
  6701. }
  6702. return fmt.Errorf("unknown ChatRecords field %s", name)
  6703. }
  6704. // AddedFields returns all numeric fields that were incremented/decremented during
  6705. // this mutation.
  6706. func (m *ChatRecordsMutation) AddedFields() []string {
  6707. var fields []string
  6708. if m.addcontent_type != nil {
  6709. fields = append(fields, chatrecords.FieldContentType)
  6710. }
  6711. if m.addsession_id != nil {
  6712. fields = append(fields, chatrecords.FieldSessionID)
  6713. }
  6714. if m.adduser_id != nil {
  6715. fields = append(fields, chatrecords.FieldUserID)
  6716. }
  6717. if m.addbot_id != nil {
  6718. fields = append(fields, chatrecords.FieldBotID)
  6719. }
  6720. if m.addbot_type != nil {
  6721. fields = append(fields, chatrecords.FieldBotType)
  6722. }
  6723. return fields
  6724. }
  6725. // AddedField returns the numeric value that was incremented/decremented on a field
  6726. // with the given name. The second boolean return value indicates that this field
  6727. // was not set, or was not defined in the schema.
  6728. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6729. switch name {
  6730. case chatrecords.FieldContentType:
  6731. return m.AddedContentType()
  6732. case chatrecords.FieldSessionID:
  6733. return m.AddedSessionID()
  6734. case chatrecords.FieldUserID:
  6735. return m.AddedUserID()
  6736. case chatrecords.FieldBotID:
  6737. return m.AddedBotID()
  6738. case chatrecords.FieldBotType:
  6739. return m.AddedBotType()
  6740. }
  6741. return nil, false
  6742. }
  6743. // AddField adds the value to the field with the given name. It returns an error if
  6744. // the field is not defined in the schema, or if the type mismatched the field
  6745. // type.
  6746. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6747. switch name {
  6748. case chatrecords.FieldContentType:
  6749. v, ok := value.(int8)
  6750. if !ok {
  6751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6752. }
  6753. m.AddContentType(v)
  6754. return nil
  6755. case chatrecords.FieldSessionID:
  6756. v, ok := value.(int64)
  6757. if !ok {
  6758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6759. }
  6760. m.AddSessionID(v)
  6761. return nil
  6762. case chatrecords.FieldUserID:
  6763. v, ok := value.(int64)
  6764. if !ok {
  6765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6766. }
  6767. m.AddUserID(v)
  6768. return nil
  6769. case chatrecords.FieldBotID:
  6770. v, ok := value.(int64)
  6771. if !ok {
  6772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6773. }
  6774. m.AddBotID(v)
  6775. return nil
  6776. case chatrecords.FieldBotType:
  6777. v, ok := value.(int8)
  6778. if !ok {
  6779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6780. }
  6781. m.AddBotType(v)
  6782. return nil
  6783. }
  6784. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6785. }
  6786. // ClearedFields returns all nullable fields that were cleared during this
  6787. // mutation.
  6788. func (m *ChatRecordsMutation) ClearedFields() []string {
  6789. var fields []string
  6790. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6791. fields = append(fields, chatrecords.FieldDeletedAt)
  6792. }
  6793. return fields
  6794. }
  6795. // FieldCleared returns a boolean indicating if a field with the given name was
  6796. // cleared in this mutation.
  6797. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6798. _, ok := m.clearedFields[name]
  6799. return ok
  6800. }
  6801. // ClearField clears the value of the field with the given name. It returns an
  6802. // error if the field is not defined in the schema.
  6803. func (m *ChatRecordsMutation) ClearField(name string) error {
  6804. switch name {
  6805. case chatrecords.FieldDeletedAt:
  6806. m.ClearDeletedAt()
  6807. return nil
  6808. }
  6809. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6810. }
  6811. // ResetField resets all changes in the mutation for the field with the given name.
  6812. // It returns an error if the field is not defined in the schema.
  6813. func (m *ChatRecordsMutation) ResetField(name string) error {
  6814. switch name {
  6815. case chatrecords.FieldCreatedAt:
  6816. m.ResetCreatedAt()
  6817. return nil
  6818. case chatrecords.FieldUpdatedAt:
  6819. m.ResetUpdatedAt()
  6820. return nil
  6821. case chatrecords.FieldDeletedAt:
  6822. m.ResetDeletedAt()
  6823. return nil
  6824. case chatrecords.FieldContent:
  6825. m.ResetContent()
  6826. return nil
  6827. case chatrecords.FieldContentType:
  6828. m.ResetContentType()
  6829. return nil
  6830. case chatrecords.FieldSessionID:
  6831. m.ResetSessionID()
  6832. return nil
  6833. case chatrecords.FieldUserID:
  6834. m.ResetUserID()
  6835. return nil
  6836. case chatrecords.FieldBotID:
  6837. m.ResetBotID()
  6838. return nil
  6839. case chatrecords.FieldBotType:
  6840. m.ResetBotType()
  6841. return nil
  6842. }
  6843. return fmt.Errorf("unknown ChatRecords field %s", name)
  6844. }
  6845. // AddedEdges returns all edge names that were set/added in this mutation.
  6846. func (m *ChatRecordsMutation) AddedEdges() []string {
  6847. edges := make([]string, 0, 0)
  6848. return edges
  6849. }
  6850. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6851. // name in this mutation.
  6852. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6853. return nil
  6854. }
  6855. // RemovedEdges returns all edge names that were removed in this mutation.
  6856. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6857. edges := make([]string, 0, 0)
  6858. return edges
  6859. }
  6860. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6861. // the given name in this mutation.
  6862. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6863. return nil
  6864. }
  6865. // ClearedEdges returns all edge names that were cleared in this mutation.
  6866. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6867. edges := make([]string, 0, 0)
  6868. return edges
  6869. }
  6870. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6871. // was cleared in this mutation.
  6872. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6873. return false
  6874. }
  6875. // ClearEdge clears the value of the edge with the given name. It returns an error
  6876. // if that edge is not defined in the schema.
  6877. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6878. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6879. }
  6880. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6881. // It returns an error if the edge is not defined in the schema.
  6882. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6883. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6884. }
  6885. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6886. type ChatSessionMutation struct {
  6887. config
  6888. op Op
  6889. typ string
  6890. id *uint64
  6891. created_at *time.Time
  6892. updated_at *time.Time
  6893. deleted_at *time.Time
  6894. name *string
  6895. user_id *uint64
  6896. adduser_id *int64
  6897. bot_id *uint64
  6898. addbot_id *int64
  6899. bot_type *uint8
  6900. addbot_type *int8
  6901. clearedFields map[string]struct{}
  6902. done bool
  6903. oldValue func(context.Context) (*ChatSession, error)
  6904. predicates []predicate.ChatSession
  6905. }
  6906. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6907. // chatsessionOption allows management of the mutation configuration using functional options.
  6908. type chatsessionOption func(*ChatSessionMutation)
  6909. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6910. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6911. m := &ChatSessionMutation{
  6912. config: c,
  6913. op: op,
  6914. typ: TypeChatSession,
  6915. clearedFields: make(map[string]struct{}),
  6916. }
  6917. for _, opt := range opts {
  6918. opt(m)
  6919. }
  6920. return m
  6921. }
  6922. // withChatSessionID sets the ID field of the mutation.
  6923. func withChatSessionID(id uint64) chatsessionOption {
  6924. return func(m *ChatSessionMutation) {
  6925. var (
  6926. err error
  6927. once sync.Once
  6928. value *ChatSession
  6929. )
  6930. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6931. once.Do(func() {
  6932. if m.done {
  6933. err = errors.New("querying old values post mutation is not allowed")
  6934. } else {
  6935. value, err = m.Client().ChatSession.Get(ctx, id)
  6936. }
  6937. })
  6938. return value, err
  6939. }
  6940. m.id = &id
  6941. }
  6942. }
  6943. // withChatSession sets the old ChatSession of the mutation.
  6944. func withChatSession(node *ChatSession) chatsessionOption {
  6945. return func(m *ChatSessionMutation) {
  6946. m.oldValue = func(context.Context) (*ChatSession, error) {
  6947. return node, nil
  6948. }
  6949. m.id = &node.ID
  6950. }
  6951. }
  6952. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6953. // executed in a transaction (ent.Tx), a transactional client is returned.
  6954. func (m ChatSessionMutation) Client() *Client {
  6955. client := &Client{config: m.config}
  6956. client.init()
  6957. return client
  6958. }
  6959. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6960. // it returns an error otherwise.
  6961. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6962. if _, ok := m.driver.(*txDriver); !ok {
  6963. return nil, errors.New("ent: mutation is not running in a transaction")
  6964. }
  6965. tx := &Tx{config: m.config}
  6966. tx.init()
  6967. return tx, nil
  6968. }
  6969. // SetID sets the value of the id field. Note that this
  6970. // operation is only accepted on creation of ChatSession entities.
  6971. func (m *ChatSessionMutation) SetID(id uint64) {
  6972. m.id = &id
  6973. }
  6974. // ID returns the ID value in the mutation. Note that the ID is only available
  6975. // if it was provided to the builder or after it was returned from the database.
  6976. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6977. if m.id == nil {
  6978. return
  6979. }
  6980. return *m.id, true
  6981. }
  6982. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6983. // That means, if the mutation is applied within a transaction with an isolation level such
  6984. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6985. // or updated by the mutation.
  6986. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6987. switch {
  6988. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6989. id, exists := m.ID()
  6990. if exists {
  6991. return []uint64{id}, nil
  6992. }
  6993. fallthrough
  6994. case m.op.Is(OpUpdate | OpDelete):
  6995. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6996. default:
  6997. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6998. }
  6999. }
  7000. // SetCreatedAt sets the "created_at" field.
  7001. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7002. m.created_at = &t
  7003. }
  7004. // CreatedAt returns the value of the "created_at" field in the mutation.
  7005. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7006. v := m.created_at
  7007. if v == nil {
  7008. return
  7009. }
  7010. return *v, true
  7011. }
  7012. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7013. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7015. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7016. if !m.op.Is(OpUpdateOne) {
  7017. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7018. }
  7019. if m.id == nil || m.oldValue == nil {
  7020. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7021. }
  7022. oldValue, err := m.oldValue(ctx)
  7023. if err != nil {
  7024. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7025. }
  7026. return oldValue.CreatedAt, nil
  7027. }
  7028. // ResetCreatedAt resets all changes to the "created_at" field.
  7029. func (m *ChatSessionMutation) ResetCreatedAt() {
  7030. m.created_at = nil
  7031. }
  7032. // SetUpdatedAt sets the "updated_at" field.
  7033. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7034. m.updated_at = &t
  7035. }
  7036. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7037. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7038. v := m.updated_at
  7039. if v == nil {
  7040. return
  7041. }
  7042. return *v, true
  7043. }
  7044. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7045. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7047. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7048. if !m.op.Is(OpUpdateOne) {
  7049. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7050. }
  7051. if m.id == nil || m.oldValue == nil {
  7052. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7053. }
  7054. oldValue, err := m.oldValue(ctx)
  7055. if err != nil {
  7056. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7057. }
  7058. return oldValue.UpdatedAt, nil
  7059. }
  7060. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7061. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7062. m.updated_at = nil
  7063. }
  7064. // SetDeletedAt sets the "deleted_at" field.
  7065. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7066. m.deleted_at = &t
  7067. }
  7068. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7069. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7070. v := m.deleted_at
  7071. if v == nil {
  7072. return
  7073. }
  7074. return *v, true
  7075. }
  7076. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7077. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7079. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7080. if !m.op.Is(OpUpdateOne) {
  7081. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7082. }
  7083. if m.id == nil || m.oldValue == nil {
  7084. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7085. }
  7086. oldValue, err := m.oldValue(ctx)
  7087. if err != nil {
  7088. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7089. }
  7090. return oldValue.DeletedAt, nil
  7091. }
  7092. // ClearDeletedAt clears the value of the "deleted_at" field.
  7093. func (m *ChatSessionMutation) ClearDeletedAt() {
  7094. m.deleted_at = nil
  7095. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7096. }
  7097. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7098. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7099. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7100. return ok
  7101. }
  7102. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7103. func (m *ChatSessionMutation) ResetDeletedAt() {
  7104. m.deleted_at = nil
  7105. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7106. }
  7107. // SetName sets the "name" field.
  7108. func (m *ChatSessionMutation) SetName(s string) {
  7109. m.name = &s
  7110. }
  7111. // Name returns the value of the "name" field in the mutation.
  7112. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7113. v := m.name
  7114. if v == nil {
  7115. return
  7116. }
  7117. return *v, true
  7118. }
  7119. // OldName returns the old "name" field's value of the ChatSession entity.
  7120. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7122. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7123. if !m.op.Is(OpUpdateOne) {
  7124. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7125. }
  7126. if m.id == nil || m.oldValue == nil {
  7127. return v, errors.New("OldName requires an ID field in the mutation")
  7128. }
  7129. oldValue, err := m.oldValue(ctx)
  7130. if err != nil {
  7131. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7132. }
  7133. return oldValue.Name, nil
  7134. }
  7135. // ResetName resets all changes to the "name" field.
  7136. func (m *ChatSessionMutation) ResetName() {
  7137. m.name = nil
  7138. }
  7139. // SetUserID sets the "user_id" field.
  7140. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7141. m.user_id = &u
  7142. m.adduser_id = nil
  7143. }
  7144. // UserID returns the value of the "user_id" field in the mutation.
  7145. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7146. v := m.user_id
  7147. if v == nil {
  7148. return
  7149. }
  7150. return *v, true
  7151. }
  7152. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7153. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7155. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7156. if !m.op.Is(OpUpdateOne) {
  7157. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7158. }
  7159. if m.id == nil || m.oldValue == nil {
  7160. return v, errors.New("OldUserID requires an ID field in the mutation")
  7161. }
  7162. oldValue, err := m.oldValue(ctx)
  7163. if err != nil {
  7164. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7165. }
  7166. return oldValue.UserID, nil
  7167. }
  7168. // AddUserID adds u to the "user_id" field.
  7169. func (m *ChatSessionMutation) AddUserID(u int64) {
  7170. if m.adduser_id != nil {
  7171. *m.adduser_id += u
  7172. } else {
  7173. m.adduser_id = &u
  7174. }
  7175. }
  7176. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7177. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7178. v := m.adduser_id
  7179. if v == nil {
  7180. return
  7181. }
  7182. return *v, true
  7183. }
  7184. // ResetUserID resets all changes to the "user_id" field.
  7185. func (m *ChatSessionMutation) ResetUserID() {
  7186. m.user_id = nil
  7187. m.adduser_id = nil
  7188. }
  7189. // SetBotID sets the "bot_id" field.
  7190. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7191. m.bot_id = &u
  7192. m.addbot_id = nil
  7193. }
  7194. // BotID returns the value of the "bot_id" field in the mutation.
  7195. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7196. v := m.bot_id
  7197. if v == nil {
  7198. return
  7199. }
  7200. return *v, true
  7201. }
  7202. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7203. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7205. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7206. if !m.op.Is(OpUpdateOne) {
  7207. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7208. }
  7209. if m.id == nil || m.oldValue == nil {
  7210. return v, errors.New("OldBotID requires an ID field in the mutation")
  7211. }
  7212. oldValue, err := m.oldValue(ctx)
  7213. if err != nil {
  7214. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7215. }
  7216. return oldValue.BotID, nil
  7217. }
  7218. // AddBotID adds u to the "bot_id" field.
  7219. func (m *ChatSessionMutation) AddBotID(u int64) {
  7220. if m.addbot_id != nil {
  7221. *m.addbot_id += u
  7222. } else {
  7223. m.addbot_id = &u
  7224. }
  7225. }
  7226. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7227. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7228. v := m.addbot_id
  7229. if v == nil {
  7230. return
  7231. }
  7232. return *v, true
  7233. }
  7234. // ResetBotID resets all changes to the "bot_id" field.
  7235. func (m *ChatSessionMutation) ResetBotID() {
  7236. m.bot_id = nil
  7237. m.addbot_id = nil
  7238. }
  7239. // SetBotType sets the "bot_type" field.
  7240. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7241. m.bot_type = &u
  7242. m.addbot_type = nil
  7243. }
  7244. // BotType returns the value of the "bot_type" field in the mutation.
  7245. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7246. v := m.bot_type
  7247. if v == nil {
  7248. return
  7249. }
  7250. return *v, true
  7251. }
  7252. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7253. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7255. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7256. if !m.op.Is(OpUpdateOne) {
  7257. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7258. }
  7259. if m.id == nil || m.oldValue == nil {
  7260. return v, errors.New("OldBotType requires an ID field in the mutation")
  7261. }
  7262. oldValue, err := m.oldValue(ctx)
  7263. if err != nil {
  7264. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7265. }
  7266. return oldValue.BotType, nil
  7267. }
  7268. // AddBotType adds u to the "bot_type" field.
  7269. func (m *ChatSessionMutation) AddBotType(u int8) {
  7270. if m.addbot_type != nil {
  7271. *m.addbot_type += u
  7272. } else {
  7273. m.addbot_type = &u
  7274. }
  7275. }
  7276. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7277. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7278. v := m.addbot_type
  7279. if v == nil {
  7280. return
  7281. }
  7282. return *v, true
  7283. }
  7284. // ResetBotType resets all changes to the "bot_type" field.
  7285. func (m *ChatSessionMutation) ResetBotType() {
  7286. m.bot_type = nil
  7287. m.addbot_type = nil
  7288. }
  7289. // Where appends a list predicates to the ChatSessionMutation builder.
  7290. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7291. m.predicates = append(m.predicates, ps...)
  7292. }
  7293. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7294. // users can use type-assertion to append predicates that do not depend on any generated package.
  7295. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7296. p := make([]predicate.ChatSession, len(ps))
  7297. for i := range ps {
  7298. p[i] = ps[i]
  7299. }
  7300. m.Where(p...)
  7301. }
  7302. // Op returns the operation name.
  7303. func (m *ChatSessionMutation) Op() Op {
  7304. return m.op
  7305. }
  7306. // SetOp allows setting the mutation operation.
  7307. func (m *ChatSessionMutation) SetOp(op Op) {
  7308. m.op = op
  7309. }
  7310. // Type returns the node type of this mutation (ChatSession).
  7311. func (m *ChatSessionMutation) Type() string {
  7312. return m.typ
  7313. }
  7314. // Fields returns all fields that were changed during this mutation. Note that in
  7315. // order to get all numeric fields that were incremented/decremented, call
  7316. // AddedFields().
  7317. func (m *ChatSessionMutation) Fields() []string {
  7318. fields := make([]string, 0, 7)
  7319. if m.created_at != nil {
  7320. fields = append(fields, chatsession.FieldCreatedAt)
  7321. }
  7322. if m.updated_at != nil {
  7323. fields = append(fields, chatsession.FieldUpdatedAt)
  7324. }
  7325. if m.deleted_at != nil {
  7326. fields = append(fields, chatsession.FieldDeletedAt)
  7327. }
  7328. if m.name != nil {
  7329. fields = append(fields, chatsession.FieldName)
  7330. }
  7331. if m.user_id != nil {
  7332. fields = append(fields, chatsession.FieldUserID)
  7333. }
  7334. if m.bot_id != nil {
  7335. fields = append(fields, chatsession.FieldBotID)
  7336. }
  7337. if m.bot_type != nil {
  7338. fields = append(fields, chatsession.FieldBotType)
  7339. }
  7340. return fields
  7341. }
  7342. // Field returns the value of a field with the given name. The second boolean
  7343. // return value indicates that this field was not set, or was not defined in the
  7344. // schema.
  7345. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7346. switch name {
  7347. case chatsession.FieldCreatedAt:
  7348. return m.CreatedAt()
  7349. case chatsession.FieldUpdatedAt:
  7350. return m.UpdatedAt()
  7351. case chatsession.FieldDeletedAt:
  7352. return m.DeletedAt()
  7353. case chatsession.FieldName:
  7354. return m.Name()
  7355. case chatsession.FieldUserID:
  7356. return m.UserID()
  7357. case chatsession.FieldBotID:
  7358. return m.BotID()
  7359. case chatsession.FieldBotType:
  7360. return m.BotType()
  7361. }
  7362. return nil, false
  7363. }
  7364. // OldField returns the old value of the field from the database. An error is
  7365. // returned if the mutation operation is not UpdateOne, or the query to the
  7366. // database failed.
  7367. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7368. switch name {
  7369. case chatsession.FieldCreatedAt:
  7370. return m.OldCreatedAt(ctx)
  7371. case chatsession.FieldUpdatedAt:
  7372. return m.OldUpdatedAt(ctx)
  7373. case chatsession.FieldDeletedAt:
  7374. return m.OldDeletedAt(ctx)
  7375. case chatsession.FieldName:
  7376. return m.OldName(ctx)
  7377. case chatsession.FieldUserID:
  7378. return m.OldUserID(ctx)
  7379. case chatsession.FieldBotID:
  7380. return m.OldBotID(ctx)
  7381. case chatsession.FieldBotType:
  7382. return m.OldBotType(ctx)
  7383. }
  7384. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7385. }
  7386. // SetField sets the value of a field with the given name. It returns an error if
  7387. // the field is not defined in the schema, or if the type mismatched the field
  7388. // type.
  7389. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7390. switch name {
  7391. case chatsession.FieldCreatedAt:
  7392. v, ok := value.(time.Time)
  7393. if !ok {
  7394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7395. }
  7396. m.SetCreatedAt(v)
  7397. return nil
  7398. case chatsession.FieldUpdatedAt:
  7399. v, ok := value.(time.Time)
  7400. if !ok {
  7401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7402. }
  7403. m.SetUpdatedAt(v)
  7404. return nil
  7405. case chatsession.FieldDeletedAt:
  7406. v, ok := value.(time.Time)
  7407. if !ok {
  7408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7409. }
  7410. m.SetDeletedAt(v)
  7411. return nil
  7412. case chatsession.FieldName:
  7413. v, ok := value.(string)
  7414. if !ok {
  7415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7416. }
  7417. m.SetName(v)
  7418. return nil
  7419. case chatsession.FieldUserID:
  7420. v, ok := value.(uint64)
  7421. if !ok {
  7422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7423. }
  7424. m.SetUserID(v)
  7425. return nil
  7426. case chatsession.FieldBotID:
  7427. v, ok := value.(uint64)
  7428. if !ok {
  7429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7430. }
  7431. m.SetBotID(v)
  7432. return nil
  7433. case chatsession.FieldBotType:
  7434. v, ok := value.(uint8)
  7435. if !ok {
  7436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7437. }
  7438. m.SetBotType(v)
  7439. return nil
  7440. }
  7441. return fmt.Errorf("unknown ChatSession field %s", name)
  7442. }
  7443. // AddedFields returns all numeric fields that were incremented/decremented during
  7444. // this mutation.
  7445. func (m *ChatSessionMutation) AddedFields() []string {
  7446. var fields []string
  7447. if m.adduser_id != nil {
  7448. fields = append(fields, chatsession.FieldUserID)
  7449. }
  7450. if m.addbot_id != nil {
  7451. fields = append(fields, chatsession.FieldBotID)
  7452. }
  7453. if m.addbot_type != nil {
  7454. fields = append(fields, chatsession.FieldBotType)
  7455. }
  7456. return fields
  7457. }
  7458. // AddedField returns the numeric value that was incremented/decremented on a field
  7459. // with the given name. The second boolean return value indicates that this field
  7460. // was not set, or was not defined in the schema.
  7461. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7462. switch name {
  7463. case chatsession.FieldUserID:
  7464. return m.AddedUserID()
  7465. case chatsession.FieldBotID:
  7466. return m.AddedBotID()
  7467. case chatsession.FieldBotType:
  7468. return m.AddedBotType()
  7469. }
  7470. return nil, false
  7471. }
  7472. // AddField adds the value to the field with the given name. It returns an error if
  7473. // the field is not defined in the schema, or if the type mismatched the field
  7474. // type.
  7475. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7476. switch name {
  7477. case chatsession.FieldUserID:
  7478. v, ok := value.(int64)
  7479. if !ok {
  7480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7481. }
  7482. m.AddUserID(v)
  7483. return nil
  7484. case chatsession.FieldBotID:
  7485. v, ok := value.(int64)
  7486. if !ok {
  7487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7488. }
  7489. m.AddBotID(v)
  7490. return nil
  7491. case chatsession.FieldBotType:
  7492. v, ok := value.(int8)
  7493. if !ok {
  7494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7495. }
  7496. m.AddBotType(v)
  7497. return nil
  7498. }
  7499. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7500. }
  7501. // ClearedFields returns all nullable fields that were cleared during this
  7502. // mutation.
  7503. func (m *ChatSessionMutation) ClearedFields() []string {
  7504. var fields []string
  7505. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7506. fields = append(fields, chatsession.FieldDeletedAt)
  7507. }
  7508. return fields
  7509. }
  7510. // FieldCleared returns a boolean indicating if a field with the given name was
  7511. // cleared in this mutation.
  7512. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7513. _, ok := m.clearedFields[name]
  7514. return ok
  7515. }
  7516. // ClearField clears the value of the field with the given name. It returns an
  7517. // error if the field is not defined in the schema.
  7518. func (m *ChatSessionMutation) ClearField(name string) error {
  7519. switch name {
  7520. case chatsession.FieldDeletedAt:
  7521. m.ClearDeletedAt()
  7522. return nil
  7523. }
  7524. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7525. }
  7526. // ResetField resets all changes in the mutation for the field with the given name.
  7527. // It returns an error if the field is not defined in the schema.
  7528. func (m *ChatSessionMutation) ResetField(name string) error {
  7529. switch name {
  7530. case chatsession.FieldCreatedAt:
  7531. m.ResetCreatedAt()
  7532. return nil
  7533. case chatsession.FieldUpdatedAt:
  7534. m.ResetUpdatedAt()
  7535. return nil
  7536. case chatsession.FieldDeletedAt:
  7537. m.ResetDeletedAt()
  7538. return nil
  7539. case chatsession.FieldName:
  7540. m.ResetName()
  7541. return nil
  7542. case chatsession.FieldUserID:
  7543. m.ResetUserID()
  7544. return nil
  7545. case chatsession.FieldBotID:
  7546. m.ResetBotID()
  7547. return nil
  7548. case chatsession.FieldBotType:
  7549. m.ResetBotType()
  7550. return nil
  7551. }
  7552. return fmt.Errorf("unknown ChatSession field %s", name)
  7553. }
  7554. // AddedEdges returns all edge names that were set/added in this mutation.
  7555. func (m *ChatSessionMutation) AddedEdges() []string {
  7556. edges := make([]string, 0, 0)
  7557. return edges
  7558. }
  7559. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7560. // name in this mutation.
  7561. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7562. return nil
  7563. }
  7564. // RemovedEdges returns all edge names that were removed in this mutation.
  7565. func (m *ChatSessionMutation) RemovedEdges() []string {
  7566. edges := make([]string, 0, 0)
  7567. return edges
  7568. }
  7569. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7570. // the given name in this mutation.
  7571. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7572. return nil
  7573. }
  7574. // ClearedEdges returns all edge names that were cleared in this mutation.
  7575. func (m *ChatSessionMutation) ClearedEdges() []string {
  7576. edges := make([]string, 0, 0)
  7577. return edges
  7578. }
  7579. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7580. // was cleared in this mutation.
  7581. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7582. return false
  7583. }
  7584. // ClearEdge clears the value of the edge with the given name. It returns an error
  7585. // if that edge is not defined in the schema.
  7586. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7587. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7588. }
  7589. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7590. // It returns an error if the edge is not defined in the schema.
  7591. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7592. return fmt.Errorf("unknown ChatSession edge %s", name)
  7593. }
  7594. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7595. type ContactMutation struct {
  7596. config
  7597. op Op
  7598. typ string
  7599. id *uint64
  7600. created_at *time.Time
  7601. updated_at *time.Time
  7602. status *uint8
  7603. addstatus *int8
  7604. deleted_at *time.Time
  7605. wx_wxid *string
  7606. _type *int
  7607. add_type *int
  7608. wxid *string
  7609. account *string
  7610. nickname *string
  7611. markname *string
  7612. headimg *string
  7613. sex *int
  7614. addsex *int
  7615. starrole *string
  7616. dontseeit *int
  7617. adddontseeit *int
  7618. dontseeme *int
  7619. adddontseeme *int
  7620. lag *string
  7621. gid *string
  7622. gname *string
  7623. v3 *string
  7624. organization_id *uint64
  7625. addorganization_id *int64
  7626. clearedFields map[string]struct{}
  7627. contact_relationships map[uint64]struct{}
  7628. removedcontact_relationships map[uint64]struct{}
  7629. clearedcontact_relationships bool
  7630. contact_messages map[uint64]struct{}
  7631. removedcontact_messages map[uint64]struct{}
  7632. clearedcontact_messages bool
  7633. done bool
  7634. oldValue func(context.Context) (*Contact, error)
  7635. predicates []predicate.Contact
  7636. }
  7637. var _ ent.Mutation = (*ContactMutation)(nil)
  7638. // contactOption allows management of the mutation configuration using functional options.
  7639. type contactOption func(*ContactMutation)
  7640. // newContactMutation creates new mutation for the Contact entity.
  7641. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7642. m := &ContactMutation{
  7643. config: c,
  7644. op: op,
  7645. typ: TypeContact,
  7646. clearedFields: make(map[string]struct{}),
  7647. }
  7648. for _, opt := range opts {
  7649. opt(m)
  7650. }
  7651. return m
  7652. }
  7653. // withContactID sets the ID field of the mutation.
  7654. func withContactID(id uint64) contactOption {
  7655. return func(m *ContactMutation) {
  7656. var (
  7657. err error
  7658. once sync.Once
  7659. value *Contact
  7660. )
  7661. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7662. once.Do(func() {
  7663. if m.done {
  7664. err = errors.New("querying old values post mutation is not allowed")
  7665. } else {
  7666. value, err = m.Client().Contact.Get(ctx, id)
  7667. }
  7668. })
  7669. return value, err
  7670. }
  7671. m.id = &id
  7672. }
  7673. }
  7674. // withContact sets the old Contact of the mutation.
  7675. func withContact(node *Contact) contactOption {
  7676. return func(m *ContactMutation) {
  7677. m.oldValue = func(context.Context) (*Contact, error) {
  7678. return node, nil
  7679. }
  7680. m.id = &node.ID
  7681. }
  7682. }
  7683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7684. // executed in a transaction (ent.Tx), a transactional client is returned.
  7685. func (m ContactMutation) Client() *Client {
  7686. client := &Client{config: m.config}
  7687. client.init()
  7688. return client
  7689. }
  7690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7691. // it returns an error otherwise.
  7692. func (m ContactMutation) Tx() (*Tx, error) {
  7693. if _, ok := m.driver.(*txDriver); !ok {
  7694. return nil, errors.New("ent: mutation is not running in a transaction")
  7695. }
  7696. tx := &Tx{config: m.config}
  7697. tx.init()
  7698. return tx, nil
  7699. }
  7700. // SetID sets the value of the id field. Note that this
  7701. // operation is only accepted on creation of Contact entities.
  7702. func (m *ContactMutation) SetID(id uint64) {
  7703. m.id = &id
  7704. }
  7705. // ID returns the ID value in the mutation. Note that the ID is only available
  7706. // if it was provided to the builder or after it was returned from the database.
  7707. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7708. if m.id == nil {
  7709. return
  7710. }
  7711. return *m.id, true
  7712. }
  7713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7714. // That means, if the mutation is applied within a transaction with an isolation level such
  7715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7716. // or updated by the mutation.
  7717. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7718. switch {
  7719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7720. id, exists := m.ID()
  7721. if exists {
  7722. return []uint64{id}, nil
  7723. }
  7724. fallthrough
  7725. case m.op.Is(OpUpdate | OpDelete):
  7726. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7727. default:
  7728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7729. }
  7730. }
  7731. // SetCreatedAt sets the "created_at" field.
  7732. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7733. m.created_at = &t
  7734. }
  7735. // CreatedAt returns the value of the "created_at" field in the mutation.
  7736. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7737. v := m.created_at
  7738. if v == nil {
  7739. return
  7740. }
  7741. return *v, true
  7742. }
  7743. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7744. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7746. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7747. if !m.op.Is(OpUpdateOne) {
  7748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7749. }
  7750. if m.id == nil || m.oldValue == nil {
  7751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7752. }
  7753. oldValue, err := m.oldValue(ctx)
  7754. if err != nil {
  7755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7756. }
  7757. return oldValue.CreatedAt, nil
  7758. }
  7759. // ResetCreatedAt resets all changes to the "created_at" field.
  7760. func (m *ContactMutation) ResetCreatedAt() {
  7761. m.created_at = nil
  7762. }
  7763. // SetUpdatedAt sets the "updated_at" field.
  7764. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7765. m.updated_at = &t
  7766. }
  7767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7768. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7769. v := m.updated_at
  7770. if v == nil {
  7771. return
  7772. }
  7773. return *v, true
  7774. }
  7775. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7776. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7778. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7779. if !m.op.Is(OpUpdateOne) {
  7780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7781. }
  7782. if m.id == nil || m.oldValue == nil {
  7783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7784. }
  7785. oldValue, err := m.oldValue(ctx)
  7786. if err != nil {
  7787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7788. }
  7789. return oldValue.UpdatedAt, nil
  7790. }
  7791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7792. func (m *ContactMutation) ResetUpdatedAt() {
  7793. m.updated_at = nil
  7794. }
  7795. // SetStatus sets the "status" field.
  7796. func (m *ContactMutation) SetStatus(u uint8) {
  7797. m.status = &u
  7798. m.addstatus = nil
  7799. }
  7800. // Status returns the value of the "status" field in the mutation.
  7801. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7802. v := m.status
  7803. if v == nil {
  7804. return
  7805. }
  7806. return *v, true
  7807. }
  7808. // OldStatus returns the old "status" field's value of the Contact entity.
  7809. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7811. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7812. if !m.op.Is(OpUpdateOne) {
  7813. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7814. }
  7815. if m.id == nil || m.oldValue == nil {
  7816. return v, errors.New("OldStatus requires an ID field in the mutation")
  7817. }
  7818. oldValue, err := m.oldValue(ctx)
  7819. if err != nil {
  7820. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7821. }
  7822. return oldValue.Status, nil
  7823. }
  7824. // AddStatus adds u to the "status" field.
  7825. func (m *ContactMutation) AddStatus(u int8) {
  7826. if m.addstatus != nil {
  7827. *m.addstatus += u
  7828. } else {
  7829. m.addstatus = &u
  7830. }
  7831. }
  7832. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7833. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7834. v := m.addstatus
  7835. if v == nil {
  7836. return
  7837. }
  7838. return *v, true
  7839. }
  7840. // ClearStatus clears the value of the "status" field.
  7841. func (m *ContactMutation) ClearStatus() {
  7842. m.status = nil
  7843. m.addstatus = nil
  7844. m.clearedFields[contact.FieldStatus] = struct{}{}
  7845. }
  7846. // StatusCleared returns if the "status" field was cleared in this mutation.
  7847. func (m *ContactMutation) StatusCleared() bool {
  7848. _, ok := m.clearedFields[contact.FieldStatus]
  7849. return ok
  7850. }
  7851. // ResetStatus resets all changes to the "status" field.
  7852. func (m *ContactMutation) ResetStatus() {
  7853. m.status = nil
  7854. m.addstatus = nil
  7855. delete(m.clearedFields, contact.FieldStatus)
  7856. }
  7857. // SetDeletedAt sets the "deleted_at" field.
  7858. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7859. m.deleted_at = &t
  7860. }
  7861. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7862. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7863. v := m.deleted_at
  7864. if v == nil {
  7865. return
  7866. }
  7867. return *v, true
  7868. }
  7869. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7870. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7872. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7873. if !m.op.Is(OpUpdateOne) {
  7874. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7875. }
  7876. if m.id == nil || m.oldValue == nil {
  7877. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7878. }
  7879. oldValue, err := m.oldValue(ctx)
  7880. if err != nil {
  7881. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7882. }
  7883. return oldValue.DeletedAt, nil
  7884. }
  7885. // ClearDeletedAt clears the value of the "deleted_at" field.
  7886. func (m *ContactMutation) ClearDeletedAt() {
  7887. m.deleted_at = nil
  7888. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7889. }
  7890. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7891. func (m *ContactMutation) DeletedAtCleared() bool {
  7892. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7893. return ok
  7894. }
  7895. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7896. func (m *ContactMutation) ResetDeletedAt() {
  7897. m.deleted_at = nil
  7898. delete(m.clearedFields, contact.FieldDeletedAt)
  7899. }
  7900. // SetWxWxid sets the "wx_wxid" field.
  7901. func (m *ContactMutation) SetWxWxid(s string) {
  7902. m.wx_wxid = &s
  7903. }
  7904. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7905. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7906. v := m.wx_wxid
  7907. if v == nil {
  7908. return
  7909. }
  7910. return *v, true
  7911. }
  7912. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7913. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7915. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7916. if !m.op.Is(OpUpdateOne) {
  7917. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7918. }
  7919. if m.id == nil || m.oldValue == nil {
  7920. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7921. }
  7922. oldValue, err := m.oldValue(ctx)
  7923. if err != nil {
  7924. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7925. }
  7926. return oldValue.WxWxid, nil
  7927. }
  7928. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7929. func (m *ContactMutation) ResetWxWxid() {
  7930. m.wx_wxid = nil
  7931. }
  7932. // SetType sets the "type" field.
  7933. func (m *ContactMutation) SetType(i int) {
  7934. m._type = &i
  7935. m.add_type = nil
  7936. }
  7937. // GetType returns the value of the "type" field in the mutation.
  7938. func (m *ContactMutation) GetType() (r int, exists bool) {
  7939. v := m._type
  7940. if v == nil {
  7941. return
  7942. }
  7943. return *v, true
  7944. }
  7945. // OldType returns the old "type" field's value of the Contact entity.
  7946. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7948. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7949. if !m.op.Is(OpUpdateOne) {
  7950. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7951. }
  7952. if m.id == nil || m.oldValue == nil {
  7953. return v, errors.New("OldType requires an ID field in the mutation")
  7954. }
  7955. oldValue, err := m.oldValue(ctx)
  7956. if err != nil {
  7957. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7958. }
  7959. return oldValue.Type, nil
  7960. }
  7961. // AddType adds i to the "type" field.
  7962. func (m *ContactMutation) AddType(i int) {
  7963. if m.add_type != nil {
  7964. *m.add_type += i
  7965. } else {
  7966. m.add_type = &i
  7967. }
  7968. }
  7969. // AddedType returns the value that was added to the "type" field in this mutation.
  7970. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7971. v := m.add_type
  7972. if v == nil {
  7973. return
  7974. }
  7975. return *v, true
  7976. }
  7977. // ClearType clears the value of the "type" field.
  7978. func (m *ContactMutation) ClearType() {
  7979. m._type = nil
  7980. m.add_type = nil
  7981. m.clearedFields[contact.FieldType] = struct{}{}
  7982. }
  7983. // TypeCleared returns if the "type" field was cleared in this mutation.
  7984. func (m *ContactMutation) TypeCleared() bool {
  7985. _, ok := m.clearedFields[contact.FieldType]
  7986. return ok
  7987. }
  7988. // ResetType resets all changes to the "type" field.
  7989. func (m *ContactMutation) ResetType() {
  7990. m._type = nil
  7991. m.add_type = nil
  7992. delete(m.clearedFields, contact.FieldType)
  7993. }
  7994. // SetWxid sets the "wxid" field.
  7995. func (m *ContactMutation) SetWxid(s string) {
  7996. m.wxid = &s
  7997. }
  7998. // Wxid returns the value of the "wxid" field in the mutation.
  7999. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8000. v := m.wxid
  8001. if v == nil {
  8002. return
  8003. }
  8004. return *v, true
  8005. }
  8006. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8007. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8009. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8010. if !m.op.Is(OpUpdateOne) {
  8011. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8012. }
  8013. if m.id == nil || m.oldValue == nil {
  8014. return v, errors.New("OldWxid requires an ID field in the mutation")
  8015. }
  8016. oldValue, err := m.oldValue(ctx)
  8017. if err != nil {
  8018. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8019. }
  8020. return oldValue.Wxid, nil
  8021. }
  8022. // ResetWxid resets all changes to the "wxid" field.
  8023. func (m *ContactMutation) ResetWxid() {
  8024. m.wxid = nil
  8025. }
  8026. // SetAccount sets the "account" field.
  8027. func (m *ContactMutation) SetAccount(s string) {
  8028. m.account = &s
  8029. }
  8030. // Account returns the value of the "account" field in the mutation.
  8031. func (m *ContactMutation) Account() (r string, exists bool) {
  8032. v := m.account
  8033. if v == nil {
  8034. return
  8035. }
  8036. return *v, true
  8037. }
  8038. // OldAccount returns the old "account" field's value of the Contact entity.
  8039. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8041. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8042. if !m.op.Is(OpUpdateOne) {
  8043. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8044. }
  8045. if m.id == nil || m.oldValue == nil {
  8046. return v, errors.New("OldAccount requires an ID field in the mutation")
  8047. }
  8048. oldValue, err := m.oldValue(ctx)
  8049. if err != nil {
  8050. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8051. }
  8052. return oldValue.Account, nil
  8053. }
  8054. // ResetAccount resets all changes to the "account" field.
  8055. func (m *ContactMutation) ResetAccount() {
  8056. m.account = nil
  8057. }
  8058. // SetNickname sets the "nickname" field.
  8059. func (m *ContactMutation) SetNickname(s string) {
  8060. m.nickname = &s
  8061. }
  8062. // Nickname returns the value of the "nickname" field in the mutation.
  8063. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8064. v := m.nickname
  8065. if v == nil {
  8066. return
  8067. }
  8068. return *v, true
  8069. }
  8070. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8071. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8073. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8074. if !m.op.Is(OpUpdateOne) {
  8075. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8076. }
  8077. if m.id == nil || m.oldValue == nil {
  8078. return v, errors.New("OldNickname requires an ID field in the mutation")
  8079. }
  8080. oldValue, err := m.oldValue(ctx)
  8081. if err != nil {
  8082. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8083. }
  8084. return oldValue.Nickname, nil
  8085. }
  8086. // ResetNickname resets all changes to the "nickname" field.
  8087. func (m *ContactMutation) ResetNickname() {
  8088. m.nickname = nil
  8089. }
  8090. // SetMarkname sets the "markname" field.
  8091. func (m *ContactMutation) SetMarkname(s string) {
  8092. m.markname = &s
  8093. }
  8094. // Markname returns the value of the "markname" field in the mutation.
  8095. func (m *ContactMutation) Markname() (r string, exists bool) {
  8096. v := m.markname
  8097. if v == nil {
  8098. return
  8099. }
  8100. return *v, true
  8101. }
  8102. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8103. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8105. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8106. if !m.op.Is(OpUpdateOne) {
  8107. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8108. }
  8109. if m.id == nil || m.oldValue == nil {
  8110. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8111. }
  8112. oldValue, err := m.oldValue(ctx)
  8113. if err != nil {
  8114. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8115. }
  8116. return oldValue.Markname, nil
  8117. }
  8118. // ResetMarkname resets all changes to the "markname" field.
  8119. func (m *ContactMutation) ResetMarkname() {
  8120. m.markname = nil
  8121. }
  8122. // SetHeadimg sets the "headimg" field.
  8123. func (m *ContactMutation) SetHeadimg(s string) {
  8124. m.headimg = &s
  8125. }
  8126. // Headimg returns the value of the "headimg" field in the mutation.
  8127. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8128. v := m.headimg
  8129. if v == nil {
  8130. return
  8131. }
  8132. return *v, true
  8133. }
  8134. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8135. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8137. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8138. if !m.op.Is(OpUpdateOne) {
  8139. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8140. }
  8141. if m.id == nil || m.oldValue == nil {
  8142. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8143. }
  8144. oldValue, err := m.oldValue(ctx)
  8145. if err != nil {
  8146. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8147. }
  8148. return oldValue.Headimg, nil
  8149. }
  8150. // ResetHeadimg resets all changes to the "headimg" field.
  8151. func (m *ContactMutation) ResetHeadimg() {
  8152. m.headimg = nil
  8153. }
  8154. // SetSex sets the "sex" field.
  8155. func (m *ContactMutation) SetSex(i int) {
  8156. m.sex = &i
  8157. m.addsex = nil
  8158. }
  8159. // Sex returns the value of the "sex" field in the mutation.
  8160. func (m *ContactMutation) Sex() (r int, exists bool) {
  8161. v := m.sex
  8162. if v == nil {
  8163. return
  8164. }
  8165. return *v, true
  8166. }
  8167. // OldSex returns the old "sex" field's value of the Contact entity.
  8168. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8170. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8171. if !m.op.Is(OpUpdateOne) {
  8172. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8173. }
  8174. if m.id == nil || m.oldValue == nil {
  8175. return v, errors.New("OldSex requires an ID field in the mutation")
  8176. }
  8177. oldValue, err := m.oldValue(ctx)
  8178. if err != nil {
  8179. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8180. }
  8181. return oldValue.Sex, nil
  8182. }
  8183. // AddSex adds i to the "sex" field.
  8184. func (m *ContactMutation) AddSex(i int) {
  8185. if m.addsex != nil {
  8186. *m.addsex += i
  8187. } else {
  8188. m.addsex = &i
  8189. }
  8190. }
  8191. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8192. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8193. v := m.addsex
  8194. if v == nil {
  8195. return
  8196. }
  8197. return *v, true
  8198. }
  8199. // ResetSex resets all changes to the "sex" field.
  8200. func (m *ContactMutation) ResetSex() {
  8201. m.sex = nil
  8202. m.addsex = nil
  8203. }
  8204. // SetStarrole sets the "starrole" field.
  8205. func (m *ContactMutation) SetStarrole(s string) {
  8206. m.starrole = &s
  8207. }
  8208. // Starrole returns the value of the "starrole" field in the mutation.
  8209. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8210. v := m.starrole
  8211. if v == nil {
  8212. return
  8213. }
  8214. return *v, true
  8215. }
  8216. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8217. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8219. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8220. if !m.op.Is(OpUpdateOne) {
  8221. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8222. }
  8223. if m.id == nil || m.oldValue == nil {
  8224. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8225. }
  8226. oldValue, err := m.oldValue(ctx)
  8227. if err != nil {
  8228. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8229. }
  8230. return oldValue.Starrole, nil
  8231. }
  8232. // ResetStarrole resets all changes to the "starrole" field.
  8233. func (m *ContactMutation) ResetStarrole() {
  8234. m.starrole = nil
  8235. }
  8236. // SetDontseeit sets the "dontseeit" field.
  8237. func (m *ContactMutation) SetDontseeit(i int) {
  8238. m.dontseeit = &i
  8239. m.adddontseeit = nil
  8240. }
  8241. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8242. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8243. v := m.dontseeit
  8244. if v == nil {
  8245. return
  8246. }
  8247. return *v, true
  8248. }
  8249. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8250. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8252. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8253. if !m.op.Is(OpUpdateOne) {
  8254. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8255. }
  8256. if m.id == nil || m.oldValue == nil {
  8257. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8258. }
  8259. oldValue, err := m.oldValue(ctx)
  8260. if err != nil {
  8261. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8262. }
  8263. return oldValue.Dontseeit, nil
  8264. }
  8265. // AddDontseeit adds i to the "dontseeit" field.
  8266. func (m *ContactMutation) AddDontseeit(i int) {
  8267. if m.adddontseeit != nil {
  8268. *m.adddontseeit += i
  8269. } else {
  8270. m.adddontseeit = &i
  8271. }
  8272. }
  8273. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8274. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8275. v := m.adddontseeit
  8276. if v == nil {
  8277. return
  8278. }
  8279. return *v, true
  8280. }
  8281. // ResetDontseeit resets all changes to the "dontseeit" field.
  8282. func (m *ContactMutation) ResetDontseeit() {
  8283. m.dontseeit = nil
  8284. m.adddontseeit = nil
  8285. }
  8286. // SetDontseeme sets the "dontseeme" field.
  8287. func (m *ContactMutation) SetDontseeme(i int) {
  8288. m.dontseeme = &i
  8289. m.adddontseeme = nil
  8290. }
  8291. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8292. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8293. v := m.dontseeme
  8294. if v == nil {
  8295. return
  8296. }
  8297. return *v, true
  8298. }
  8299. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8300. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8302. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8303. if !m.op.Is(OpUpdateOne) {
  8304. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8305. }
  8306. if m.id == nil || m.oldValue == nil {
  8307. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8308. }
  8309. oldValue, err := m.oldValue(ctx)
  8310. if err != nil {
  8311. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8312. }
  8313. return oldValue.Dontseeme, nil
  8314. }
  8315. // AddDontseeme adds i to the "dontseeme" field.
  8316. func (m *ContactMutation) AddDontseeme(i int) {
  8317. if m.adddontseeme != nil {
  8318. *m.adddontseeme += i
  8319. } else {
  8320. m.adddontseeme = &i
  8321. }
  8322. }
  8323. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8324. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8325. v := m.adddontseeme
  8326. if v == nil {
  8327. return
  8328. }
  8329. return *v, true
  8330. }
  8331. // ResetDontseeme resets all changes to the "dontseeme" field.
  8332. func (m *ContactMutation) ResetDontseeme() {
  8333. m.dontseeme = nil
  8334. m.adddontseeme = nil
  8335. }
  8336. // SetLag sets the "lag" field.
  8337. func (m *ContactMutation) SetLag(s string) {
  8338. m.lag = &s
  8339. }
  8340. // Lag returns the value of the "lag" field in the mutation.
  8341. func (m *ContactMutation) Lag() (r string, exists bool) {
  8342. v := m.lag
  8343. if v == nil {
  8344. return
  8345. }
  8346. return *v, true
  8347. }
  8348. // OldLag returns the old "lag" field's value of the Contact entity.
  8349. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8351. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8352. if !m.op.Is(OpUpdateOne) {
  8353. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8354. }
  8355. if m.id == nil || m.oldValue == nil {
  8356. return v, errors.New("OldLag requires an ID field in the mutation")
  8357. }
  8358. oldValue, err := m.oldValue(ctx)
  8359. if err != nil {
  8360. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8361. }
  8362. return oldValue.Lag, nil
  8363. }
  8364. // ResetLag resets all changes to the "lag" field.
  8365. func (m *ContactMutation) ResetLag() {
  8366. m.lag = nil
  8367. }
  8368. // SetGid sets the "gid" field.
  8369. func (m *ContactMutation) SetGid(s string) {
  8370. m.gid = &s
  8371. }
  8372. // Gid returns the value of the "gid" field in the mutation.
  8373. func (m *ContactMutation) Gid() (r string, exists bool) {
  8374. v := m.gid
  8375. if v == nil {
  8376. return
  8377. }
  8378. return *v, true
  8379. }
  8380. // OldGid returns the old "gid" field's value of the Contact entity.
  8381. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8383. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8384. if !m.op.Is(OpUpdateOne) {
  8385. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8386. }
  8387. if m.id == nil || m.oldValue == nil {
  8388. return v, errors.New("OldGid requires an ID field in the mutation")
  8389. }
  8390. oldValue, err := m.oldValue(ctx)
  8391. if err != nil {
  8392. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8393. }
  8394. return oldValue.Gid, nil
  8395. }
  8396. // ResetGid resets all changes to the "gid" field.
  8397. func (m *ContactMutation) ResetGid() {
  8398. m.gid = nil
  8399. }
  8400. // SetGname sets the "gname" field.
  8401. func (m *ContactMutation) SetGname(s string) {
  8402. m.gname = &s
  8403. }
  8404. // Gname returns the value of the "gname" field in the mutation.
  8405. func (m *ContactMutation) Gname() (r string, exists bool) {
  8406. v := m.gname
  8407. if v == nil {
  8408. return
  8409. }
  8410. return *v, true
  8411. }
  8412. // OldGname returns the old "gname" field's value of the Contact entity.
  8413. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8415. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8416. if !m.op.Is(OpUpdateOne) {
  8417. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8418. }
  8419. if m.id == nil || m.oldValue == nil {
  8420. return v, errors.New("OldGname requires an ID field in the mutation")
  8421. }
  8422. oldValue, err := m.oldValue(ctx)
  8423. if err != nil {
  8424. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8425. }
  8426. return oldValue.Gname, nil
  8427. }
  8428. // ResetGname resets all changes to the "gname" field.
  8429. func (m *ContactMutation) ResetGname() {
  8430. m.gname = nil
  8431. }
  8432. // SetV3 sets the "v3" field.
  8433. func (m *ContactMutation) SetV3(s string) {
  8434. m.v3 = &s
  8435. }
  8436. // V3 returns the value of the "v3" field in the mutation.
  8437. func (m *ContactMutation) V3() (r string, exists bool) {
  8438. v := m.v3
  8439. if v == nil {
  8440. return
  8441. }
  8442. return *v, true
  8443. }
  8444. // OldV3 returns the old "v3" field's value of the Contact entity.
  8445. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8447. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8448. if !m.op.Is(OpUpdateOne) {
  8449. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8450. }
  8451. if m.id == nil || m.oldValue == nil {
  8452. return v, errors.New("OldV3 requires an ID field in the mutation")
  8453. }
  8454. oldValue, err := m.oldValue(ctx)
  8455. if err != nil {
  8456. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8457. }
  8458. return oldValue.V3, nil
  8459. }
  8460. // ResetV3 resets all changes to the "v3" field.
  8461. func (m *ContactMutation) ResetV3() {
  8462. m.v3 = nil
  8463. }
  8464. // SetOrganizationID sets the "organization_id" field.
  8465. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8466. m.organization_id = &u
  8467. m.addorganization_id = nil
  8468. }
  8469. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8470. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8471. v := m.organization_id
  8472. if v == nil {
  8473. return
  8474. }
  8475. return *v, true
  8476. }
  8477. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8478. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8480. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8481. if !m.op.Is(OpUpdateOne) {
  8482. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8483. }
  8484. if m.id == nil || m.oldValue == nil {
  8485. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8486. }
  8487. oldValue, err := m.oldValue(ctx)
  8488. if err != nil {
  8489. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8490. }
  8491. return oldValue.OrganizationID, nil
  8492. }
  8493. // AddOrganizationID adds u to the "organization_id" field.
  8494. func (m *ContactMutation) AddOrganizationID(u int64) {
  8495. if m.addorganization_id != nil {
  8496. *m.addorganization_id += u
  8497. } else {
  8498. m.addorganization_id = &u
  8499. }
  8500. }
  8501. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8502. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8503. v := m.addorganization_id
  8504. if v == nil {
  8505. return
  8506. }
  8507. return *v, true
  8508. }
  8509. // ClearOrganizationID clears the value of the "organization_id" field.
  8510. func (m *ContactMutation) ClearOrganizationID() {
  8511. m.organization_id = nil
  8512. m.addorganization_id = nil
  8513. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8514. }
  8515. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8516. func (m *ContactMutation) OrganizationIDCleared() bool {
  8517. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8518. return ok
  8519. }
  8520. // ResetOrganizationID resets all changes to the "organization_id" field.
  8521. func (m *ContactMutation) ResetOrganizationID() {
  8522. m.organization_id = nil
  8523. m.addorganization_id = nil
  8524. delete(m.clearedFields, contact.FieldOrganizationID)
  8525. }
  8526. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8527. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8528. if m.contact_relationships == nil {
  8529. m.contact_relationships = make(map[uint64]struct{})
  8530. }
  8531. for i := range ids {
  8532. m.contact_relationships[ids[i]] = struct{}{}
  8533. }
  8534. }
  8535. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8536. func (m *ContactMutation) ClearContactRelationships() {
  8537. m.clearedcontact_relationships = true
  8538. }
  8539. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8540. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8541. return m.clearedcontact_relationships
  8542. }
  8543. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8544. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8545. if m.removedcontact_relationships == nil {
  8546. m.removedcontact_relationships = make(map[uint64]struct{})
  8547. }
  8548. for i := range ids {
  8549. delete(m.contact_relationships, ids[i])
  8550. m.removedcontact_relationships[ids[i]] = struct{}{}
  8551. }
  8552. }
  8553. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8554. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8555. for id := range m.removedcontact_relationships {
  8556. ids = append(ids, id)
  8557. }
  8558. return
  8559. }
  8560. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8561. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8562. for id := range m.contact_relationships {
  8563. ids = append(ids, id)
  8564. }
  8565. return
  8566. }
  8567. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8568. func (m *ContactMutation) ResetContactRelationships() {
  8569. m.contact_relationships = nil
  8570. m.clearedcontact_relationships = false
  8571. m.removedcontact_relationships = nil
  8572. }
  8573. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8574. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8575. if m.contact_messages == nil {
  8576. m.contact_messages = make(map[uint64]struct{})
  8577. }
  8578. for i := range ids {
  8579. m.contact_messages[ids[i]] = struct{}{}
  8580. }
  8581. }
  8582. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8583. func (m *ContactMutation) ClearContactMessages() {
  8584. m.clearedcontact_messages = true
  8585. }
  8586. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8587. func (m *ContactMutation) ContactMessagesCleared() bool {
  8588. return m.clearedcontact_messages
  8589. }
  8590. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8591. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8592. if m.removedcontact_messages == nil {
  8593. m.removedcontact_messages = make(map[uint64]struct{})
  8594. }
  8595. for i := range ids {
  8596. delete(m.contact_messages, ids[i])
  8597. m.removedcontact_messages[ids[i]] = struct{}{}
  8598. }
  8599. }
  8600. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8601. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8602. for id := range m.removedcontact_messages {
  8603. ids = append(ids, id)
  8604. }
  8605. return
  8606. }
  8607. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8608. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8609. for id := range m.contact_messages {
  8610. ids = append(ids, id)
  8611. }
  8612. return
  8613. }
  8614. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8615. func (m *ContactMutation) ResetContactMessages() {
  8616. m.contact_messages = nil
  8617. m.clearedcontact_messages = false
  8618. m.removedcontact_messages = nil
  8619. }
  8620. // Where appends a list predicates to the ContactMutation builder.
  8621. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8622. m.predicates = append(m.predicates, ps...)
  8623. }
  8624. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8625. // users can use type-assertion to append predicates that do not depend on any generated package.
  8626. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8627. p := make([]predicate.Contact, len(ps))
  8628. for i := range ps {
  8629. p[i] = ps[i]
  8630. }
  8631. m.Where(p...)
  8632. }
  8633. // Op returns the operation name.
  8634. func (m *ContactMutation) Op() Op {
  8635. return m.op
  8636. }
  8637. // SetOp allows setting the mutation operation.
  8638. func (m *ContactMutation) SetOp(op Op) {
  8639. m.op = op
  8640. }
  8641. // Type returns the node type of this mutation (Contact).
  8642. func (m *ContactMutation) Type() string {
  8643. return m.typ
  8644. }
  8645. // Fields returns all fields that were changed during this mutation. Note that in
  8646. // order to get all numeric fields that were incremented/decremented, call
  8647. // AddedFields().
  8648. func (m *ContactMutation) Fields() []string {
  8649. fields := make([]string, 0, 20)
  8650. if m.created_at != nil {
  8651. fields = append(fields, contact.FieldCreatedAt)
  8652. }
  8653. if m.updated_at != nil {
  8654. fields = append(fields, contact.FieldUpdatedAt)
  8655. }
  8656. if m.status != nil {
  8657. fields = append(fields, contact.FieldStatus)
  8658. }
  8659. if m.deleted_at != nil {
  8660. fields = append(fields, contact.FieldDeletedAt)
  8661. }
  8662. if m.wx_wxid != nil {
  8663. fields = append(fields, contact.FieldWxWxid)
  8664. }
  8665. if m._type != nil {
  8666. fields = append(fields, contact.FieldType)
  8667. }
  8668. if m.wxid != nil {
  8669. fields = append(fields, contact.FieldWxid)
  8670. }
  8671. if m.account != nil {
  8672. fields = append(fields, contact.FieldAccount)
  8673. }
  8674. if m.nickname != nil {
  8675. fields = append(fields, contact.FieldNickname)
  8676. }
  8677. if m.markname != nil {
  8678. fields = append(fields, contact.FieldMarkname)
  8679. }
  8680. if m.headimg != nil {
  8681. fields = append(fields, contact.FieldHeadimg)
  8682. }
  8683. if m.sex != nil {
  8684. fields = append(fields, contact.FieldSex)
  8685. }
  8686. if m.starrole != nil {
  8687. fields = append(fields, contact.FieldStarrole)
  8688. }
  8689. if m.dontseeit != nil {
  8690. fields = append(fields, contact.FieldDontseeit)
  8691. }
  8692. if m.dontseeme != nil {
  8693. fields = append(fields, contact.FieldDontseeme)
  8694. }
  8695. if m.lag != nil {
  8696. fields = append(fields, contact.FieldLag)
  8697. }
  8698. if m.gid != nil {
  8699. fields = append(fields, contact.FieldGid)
  8700. }
  8701. if m.gname != nil {
  8702. fields = append(fields, contact.FieldGname)
  8703. }
  8704. if m.v3 != nil {
  8705. fields = append(fields, contact.FieldV3)
  8706. }
  8707. if m.organization_id != nil {
  8708. fields = append(fields, contact.FieldOrganizationID)
  8709. }
  8710. return fields
  8711. }
  8712. // Field returns the value of a field with the given name. The second boolean
  8713. // return value indicates that this field was not set, or was not defined in the
  8714. // schema.
  8715. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8716. switch name {
  8717. case contact.FieldCreatedAt:
  8718. return m.CreatedAt()
  8719. case contact.FieldUpdatedAt:
  8720. return m.UpdatedAt()
  8721. case contact.FieldStatus:
  8722. return m.Status()
  8723. case contact.FieldDeletedAt:
  8724. return m.DeletedAt()
  8725. case contact.FieldWxWxid:
  8726. return m.WxWxid()
  8727. case contact.FieldType:
  8728. return m.GetType()
  8729. case contact.FieldWxid:
  8730. return m.Wxid()
  8731. case contact.FieldAccount:
  8732. return m.Account()
  8733. case contact.FieldNickname:
  8734. return m.Nickname()
  8735. case contact.FieldMarkname:
  8736. return m.Markname()
  8737. case contact.FieldHeadimg:
  8738. return m.Headimg()
  8739. case contact.FieldSex:
  8740. return m.Sex()
  8741. case contact.FieldStarrole:
  8742. return m.Starrole()
  8743. case contact.FieldDontseeit:
  8744. return m.Dontseeit()
  8745. case contact.FieldDontseeme:
  8746. return m.Dontseeme()
  8747. case contact.FieldLag:
  8748. return m.Lag()
  8749. case contact.FieldGid:
  8750. return m.Gid()
  8751. case contact.FieldGname:
  8752. return m.Gname()
  8753. case contact.FieldV3:
  8754. return m.V3()
  8755. case contact.FieldOrganizationID:
  8756. return m.OrganizationID()
  8757. }
  8758. return nil, false
  8759. }
  8760. // OldField returns the old value of the field from the database. An error is
  8761. // returned if the mutation operation is not UpdateOne, or the query to the
  8762. // database failed.
  8763. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8764. switch name {
  8765. case contact.FieldCreatedAt:
  8766. return m.OldCreatedAt(ctx)
  8767. case contact.FieldUpdatedAt:
  8768. return m.OldUpdatedAt(ctx)
  8769. case contact.FieldStatus:
  8770. return m.OldStatus(ctx)
  8771. case contact.FieldDeletedAt:
  8772. return m.OldDeletedAt(ctx)
  8773. case contact.FieldWxWxid:
  8774. return m.OldWxWxid(ctx)
  8775. case contact.FieldType:
  8776. return m.OldType(ctx)
  8777. case contact.FieldWxid:
  8778. return m.OldWxid(ctx)
  8779. case contact.FieldAccount:
  8780. return m.OldAccount(ctx)
  8781. case contact.FieldNickname:
  8782. return m.OldNickname(ctx)
  8783. case contact.FieldMarkname:
  8784. return m.OldMarkname(ctx)
  8785. case contact.FieldHeadimg:
  8786. return m.OldHeadimg(ctx)
  8787. case contact.FieldSex:
  8788. return m.OldSex(ctx)
  8789. case contact.FieldStarrole:
  8790. return m.OldStarrole(ctx)
  8791. case contact.FieldDontseeit:
  8792. return m.OldDontseeit(ctx)
  8793. case contact.FieldDontseeme:
  8794. return m.OldDontseeme(ctx)
  8795. case contact.FieldLag:
  8796. return m.OldLag(ctx)
  8797. case contact.FieldGid:
  8798. return m.OldGid(ctx)
  8799. case contact.FieldGname:
  8800. return m.OldGname(ctx)
  8801. case contact.FieldV3:
  8802. return m.OldV3(ctx)
  8803. case contact.FieldOrganizationID:
  8804. return m.OldOrganizationID(ctx)
  8805. }
  8806. return nil, fmt.Errorf("unknown Contact field %s", name)
  8807. }
  8808. // SetField sets the value of a field with the given name. It returns an error if
  8809. // the field is not defined in the schema, or if the type mismatched the field
  8810. // type.
  8811. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8812. switch name {
  8813. case contact.FieldCreatedAt:
  8814. v, ok := value.(time.Time)
  8815. if !ok {
  8816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8817. }
  8818. m.SetCreatedAt(v)
  8819. return nil
  8820. case contact.FieldUpdatedAt:
  8821. v, ok := value.(time.Time)
  8822. if !ok {
  8823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8824. }
  8825. m.SetUpdatedAt(v)
  8826. return nil
  8827. case contact.FieldStatus:
  8828. v, ok := value.(uint8)
  8829. if !ok {
  8830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8831. }
  8832. m.SetStatus(v)
  8833. return nil
  8834. case contact.FieldDeletedAt:
  8835. v, ok := value.(time.Time)
  8836. if !ok {
  8837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8838. }
  8839. m.SetDeletedAt(v)
  8840. return nil
  8841. case contact.FieldWxWxid:
  8842. v, ok := value.(string)
  8843. if !ok {
  8844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8845. }
  8846. m.SetWxWxid(v)
  8847. return nil
  8848. case contact.FieldType:
  8849. v, ok := value.(int)
  8850. if !ok {
  8851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8852. }
  8853. m.SetType(v)
  8854. return nil
  8855. case contact.FieldWxid:
  8856. v, ok := value.(string)
  8857. if !ok {
  8858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8859. }
  8860. m.SetWxid(v)
  8861. return nil
  8862. case contact.FieldAccount:
  8863. v, ok := value.(string)
  8864. if !ok {
  8865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8866. }
  8867. m.SetAccount(v)
  8868. return nil
  8869. case contact.FieldNickname:
  8870. v, ok := value.(string)
  8871. if !ok {
  8872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8873. }
  8874. m.SetNickname(v)
  8875. return nil
  8876. case contact.FieldMarkname:
  8877. v, ok := value.(string)
  8878. if !ok {
  8879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8880. }
  8881. m.SetMarkname(v)
  8882. return nil
  8883. case contact.FieldHeadimg:
  8884. v, ok := value.(string)
  8885. if !ok {
  8886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8887. }
  8888. m.SetHeadimg(v)
  8889. return nil
  8890. case contact.FieldSex:
  8891. v, ok := value.(int)
  8892. if !ok {
  8893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8894. }
  8895. m.SetSex(v)
  8896. return nil
  8897. case contact.FieldStarrole:
  8898. v, ok := value.(string)
  8899. if !ok {
  8900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8901. }
  8902. m.SetStarrole(v)
  8903. return nil
  8904. case contact.FieldDontseeit:
  8905. v, ok := value.(int)
  8906. if !ok {
  8907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8908. }
  8909. m.SetDontseeit(v)
  8910. return nil
  8911. case contact.FieldDontseeme:
  8912. v, ok := value.(int)
  8913. if !ok {
  8914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8915. }
  8916. m.SetDontseeme(v)
  8917. return nil
  8918. case contact.FieldLag:
  8919. v, ok := value.(string)
  8920. if !ok {
  8921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8922. }
  8923. m.SetLag(v)
  8924. return nil
  8925. case contact.FieldGid:
  8926. v, ok := value.(string)
  8927. if !ok {
  8928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8929. }
  8930. m.SetGid(v)
  8931. return nil
  8932. case contact.FieldGname:
  8933. v, ok := value.(string)
  8934. if !ok {
  8935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8936. }
  8937. m.SetGname(v)
  8938. return nil
  8939. case contact.FieldV3:
  8940. v, ok := value.(string)
  8941. if !ok {
  8942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8943. }
  8944. m.SetV3(v)
  8945. return nil
  8946. case contact.FieldOrganizationID:
  8947. v, ok := value.(uint64)
  8948. if !ok {
  8949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8950. }
  8951. m.SetOrganizationID(v)
  8952. return nil
  8953. }
  8954. return fmt.Errorf("unknown Contact field %s", name)
  8955. }
  8956. // AddedFields returns all numeric fields that were incremented/decremented during
  8957. // this mutation.
  8958. func (m *ContactMutation) AddedFields() []string {
  8959. var fields []string
  8960. if m.addstatus != nil {
  8961. fields = append(fields, contact.FieldStatus)
  8962. }
  8963. if m.add_type != nil {
  8964. fields = append(fields, contact.FieldType)
  8965. }
  8966. if m.addsex != nil {
  8967. fields = append(fields, contact.FieldSex)
  8968. }
  8969. if m.adddontseeit != nil {
  8970. fields = append(fields, contact.FieldDontseeit)
  8971. }
  8972. if m.adddontseeme != nil {
  8973. fields = append(fields, contact.FieldDontseeme)
  8974. }
  8975. if m.addorganization_id != nil {
  8976. fields = append(fields, contact.FieldOrganizationID)
  8977. }
  8978. return fields
  8979. }
  8980. // AddedField returns the numeric value that was incremented/decremented on a field
  8981. // with the given name. The second boolean return value indicates that this field
  8982. // was not set, or was not defined in the schema.
  8983. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8984. switch name {
  8985. case contact.FieldStatus:
  8986. return m.AddedStatus()
  8987. case contact.FieldType:
  8988. return m.AddedType()
  8989. case contact.FieldSex:
  8990. return m.AddedSex()
  8991. case contact.FieldDontseeit:
  8992. return m.AddedDontseeit()
  8993. case contact.FieldDontseeme:
  8994. return m.AddedDontseeme()
  8995. case contact.FieldOrganizationID:
  8996. return m.AddedOrganizationID()
  8997. }
  8998. return nil, false
  8999. }
  9000. // AddField adds the value to the field with the given name. It returns an error if
  9001. // the field is not defined in the schema, or if the type mismatched the field
  9002. // type.
  9003. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9004. switch name {
  9005. case contact.FieldStatus:
  9006. v, ok := value.(int8)
  9007. if !ok {
  9008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9009. }
  9010. m.AddStatus(v)
  9011. return nil
  9012. case contact.FieldType:
  9013. v, ok := value.(int)
  9014. if !ok {
  9015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9016. }
  9017. m.AddType(v)
  9018. return nil
  9019. case contact.FieldSex:
  9020. v, ok := value.(int)
  9021. if !ok {
  9022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9023. }
  9024. m.AddSex(v)
  9025. return nil
  9026. case contact.FieldDontseeit:
  9027. v, ok := value.(int)
  9028. if !ok {
  9029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9030. }
  9031. m.AddDontseeit(v)
  9032. return nil
  9033. case contact.FieldDontseeme:
  9034. v, ok := value.(int)
  9035. if !ok {
  9036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9037. }
  9038. m.AddDontseeme(v)
  9039. return nil
  9040. case contact.FieldOrganizationID:
  9041. v, ok := value.(int64)
  9042. if !ok {
  9043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9044. }
  9045. m.AddOrganizationID(v)
  9046. return nil
  9047. }
  9048. return fmt.Errorf("unknown Contact numeric field %s", name)
  9049. }
  9050. // ClearedFields returns all nullable fields that were cleared during this
  9051. // mutation.
  9052. func (m *ContactMutation) ClearedFields() []string {
  9053. var fields []string
  9054. if m.FieldCleared(contact.FieldStatus) {
  9055. fields = append(fields, contact.FieldStatus)
  9056. }
  9057. if m.FieldCleared(contact.FieldDeletedAt) {
  9058. fields = append(fields, contact.FieldDeletedAt)
  9059. }
  9060. if m.FieldCleared(contact.FieldType) {
  9061. fields = append(fields, contact.FieldType)
  9062. }
  9063. if m.FieldCleared(contact.FieldOrganizationID) {
  9064. fields = append(fields, contact.FieldOrganizationID)
  9065. }
  9066. return fields
  9067. }
  9068. // FieldCleared returns a boolean indicating if a field with the given name was
  9069. // cleared in this mutation.
  9070. func (m *ContactMutation) FieldCleared(name string) bool {
  9071. _, ok := m.clearedFields[name]
  9072. return ok
  9073. }
  9074. // ClearField clears the value of the field with the given name. It returns an
  9075. // error if the field is not defined in the schema.
  9076. func (m *ContactMutation) ClearField(name string) error {
  9077. switch name {
  9078. case contact.FieldStatus:
  9079. m.ClearStatus()
  9080. return nil
  9081. case contact.FieldDeletedAt:
  9082. m.ClearDeletedAt()
  9083. return nil
  9084. case contact.FieldType:
  9085. m.ClearType()
  9086. return nil
  9087. case contact.FieldOrganizationID:
  9088. m.ClearOrganizationID()
  9089. return nil
  9090. }
  9091. return fmt.Errorf("unknown Contact nullable field %s", name)
  9092. }
  9093. // ResetField resets all changes in the mutation for the field with the given name.
  9094. // It returns an error if the field is not defined in the schema.
  9095. func (m *ContactMutation) ResetField(name string) error {
  9096. switch name {
  9097. case contact.FieldCreatedAt:
  9098. m.ResetCreatedAt()
  9099. return nil
  9100. case contact.FieldUpdatedAt:
  9101. m.ResetUpdatedAt()
  9102. return nil
  9103. case contact.FieldStatus:
  9104. m.ResetStatus()
  9105. return nil
  9106. case contact.FieldDeletedAt:
  9107. m.ResetDeletedAt()
  9108. return nil
  9109. case contact.FieldWxWxid:
  9110. m.ResetWxWxid()
  9111. return nil
  9112. case contact.FieldType:
  9113. m.ResetType()
  9114. return nil
  9115. case contact.FieldWxid:
  9116. m.ResetWxid()
  9117. return nil
  9118. case contact.FieldAccount:
  9119. m.ResetAccount()
  9120. return nil
  9121. case contact.FieldNickname:
  9122. m.ResetNickname()
  9123. return nil
  9124. case contact.FieldMarkname:
  9125. m.ResetMarkname()
  9126. return nil
  9127. case contact.FieldHeadimg:
  9128. m.ResetHeadimg()
  9129. return nil
  9130. case contact.FieldSex:
  9131. m.ResetSex()
  9132. return nil
  9133. case contact.FieldStarrole:
  9134. m.ResetStarrole()
  9135. return nil
  9136. case contact.FieldDontseeit:
  9137. m.ResetDontseeit()
  9138. return nil
  9139. case contact.FieldDontseeme:
  9140. m.ResetDontseeme()
  9141. return nil
  9142. case contact.FieldLag:
  9143. m.ResetLag()
  9144. return nil
  9145. case contact.FieldGid:
  9146. m.ResetGid()
  9147. return nil
  9148. case contact.FieldGname:
  9149. m.ResetGname()
  9150. return nil
  9151. case contact.FieldV3:
  9152. m.ResetV3()
  9153. return nil
  9154. case contact.FieldOrganizationID:
  9155. m.ResetOrganizationID()
  9156. return nil
  9157. }
  9158. return fmt.Errorf("unknown Contact field %s", name)
  9159. }
  9160. // AddedEdges returns all edge names that were set/added in this mutation.
  9161. func (m *ContactMutation) AddedEdges() []string {
  9162. edges := make([]string, 0, 2)
  9163. if m.contact_relationships != nil {
  9164. edges = append(edges, contact.EdgeContactRelationships)
  9165. }
  9166. if m.contact_messages != nil {
  9167. edges = append(edges, contact.EdgeContactMessages)
  9168. }
  9169. return edges
  9170. }
  9171. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9172. // name in this mutation.
  9173. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9174. switch name {
  9175. case contact.EdgeContactRelationships:
  9176. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9177. for id := range m.contact_relationships {
  9178. ids = append(ids, id)
  9179. }
  9180. return ids
  9181. case contact.EdgeContactMessages:
  9182. ids := make([]ent.Value, 0, len(m.contact_messages))
  9183. for id := range m.contact_messages {
  9184. ids = append(ids, id)
  9185. }
  9186. return ids
  9187. }
  9188. return nil
  9189. }
  9190. // RemovedEdges returns all edge names that were removed in this mutation.
  9191. func (m *ContactMutation) RemovedEdges() []string {
  9192. edges := make([]string, 0, 2)
  9193. if m.removedcontact_relationships != nil {
  9194. edges = append(edges, contact.EdgeContactRelationships)
  9195. }
  9196. if m.removedcontact_messages != nil {
  9197. edges = append(edges, contact.EdgeContactMessages)
  9198. }
  9199. return edges
  9200. }
  9201. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9202. // the given name in this mutation.
  9203. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9204. switch name {
  9205. case contact.EdgeContactRelationships:
  9206. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9207. for id := range m.removedcontact_relationships {
  9208. ids = append(ids, id)
  9209. }
  9210. return ids
  9211. case contact.EdgeContactMessages:
  9212. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9213. for id := range m.removedcontact_messages {
  9214. ids = append(ids, id)
  9215. }
  9216. return ids
  9217. }
  9218. return nil
  9219. }
  9220. // ClearedEdges returns all edge names that were cleared in this mutation.
  9221. func (m *ContactMutation) ClearedEdges() []string {
  9222. edges := make([]string, 0, 2)
  9223. if m.clearedcontact_relationships {
  9224. edges = append(edges, contact.EdgeContactRelationships)
  9225. }
  9226. if m.clearedcontact_messages {
  9227. edges = append(edges, contact.EdgeContactMessages)
  9228. }
  9229. return edges
  9230. }
  9231. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9232. // was cleared in this mutation.
  9233. func (m *ContactMutation) EdgeCleared(name string) bool {
  9234. switch name {
  9235. case contact.EdgeContactRelationships:
  9236. return m.clearedcontact_relationships
  9237. case contact.EdgeContactMessages:
  9238. return m.clearedcontact_messages
  9239. }
  9240. return false
  9241. }
  9242. // ClearEdge clears the value of the edge with the given name. It returns an error
  9243. // if that edge is not defined in the schema.
  9244. func (m *ContactMutation) ClearEdge(name string) error {
  9245. switch name {
  9246. }
  9247. return fmt.Errorf("unknown Contact unique edge %s", name)
  9248. }
  9249. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9250. // It returns an error if the edge is not defined in the schema.
  9251. func (m *ContactMutation) ResetEdge(name string) error {
  9252. switch name {
  9253. case contact.EdgeContactRelationships:
  9254. m.ResetContactRelationships()
  9255. return nil
  9256. case contact.EdgeContactMessages:
  9257. m.ResetContactMessages()
  9258. return nil
  9259. }
  9260. return fmt.Errorf("unknown Contact edge %s", name)
  9261. }
  9262. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  9263. type EmployeeMutation struct {
  9264. config
  9265. op Op
  9266. typ string
  9267. id *uint64
  9268. created_at *time.Time
  9269. updated_at *time.Time
  9270. deleted_at *time.Time
  9271. title *string
  9272. avatar *string
  9273. tags *string
  9274. hire_count *int
  9275. addhire_count *int
  9276. service_count *int
  9277. addservice_count *int
  9278. achievement_count *int
  9279. addachievement_count *int
  9280. intro *string
  9281. estimate *string
  9282. skill *string
  9283. ability_type *string
  9284. scene *string
  9285. switch_in *string
  9286. video_url *string
  9287. organization_id *uint64
  9288. addorganization_id *int64
  9289. category_id *uint64
  9290. addcategory_id *int64
  9291. api_base *string
  9292. api_key *string
  9293. ai_info *string
  9294. is_vip *int
  9295. addis_vip *int
  9296. chat_url *string
  9297. clearedFields map[string]struct{}
  9298. em_work_experiences map[uint64]struct{}
  9299. removedem_work_experiences map[uint64]struct{}
  9300. clearedem_work_experiences bool
  9301. em_tutorial map[uint64]struct{}
  9302. removedem_tutorial map[uint64]struct{}
  9303. clearedem_tutorial bool
  9304. done bool
  9305. oldValue func(context.Context) (*Employee, error)
  9306. predicates []predicate.Employee
  9307. }
  9308. var _ ent.Mutation = (*EmployeeMutation)(nil)
  9309. // employeeOption allows management of the mutation configuration using functional options.
  9310. type employeeOption func(*EmployeeMutation)
  9311. // newEmployeeMutation creates new mutation for the Employee entity.
  9312. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  9313. m := &EmployeeMutation{
  9314. config: c,
  9315. op: op,
  9316. typ: TypeEmployee,
  9317. clearedFields: make(map[string]struct{}),
  9318. }
  9319. for _, opt := range opts {
  9320. opt(m)
  9321. }
  9322. return m
  9323. }
  9324. // withEmployeeID sets the ID field of the mutation.
  9325. func withEmployeeID(id uint64) employeeOption {
  9326. return func(m *EmployeeMutation) {
  9327. var (
  9328. err error
  9329. once sync.Once
  9330. value *Employee
  9331. )
  9332. m.oldValue = func(ctx context.Context) (*Employee, error) {
  9333. once.Do(func() {
  9334. if m.done {
  9335. err = errors.New("querying old values post mutation is not allowed")
  9336. } else {
  9337. value, err = m.Client().Employee.Get(ctx, id)
  9338. }
  9339. })
  9340. return value, err
  9341. }
  9342. m.id = &id
  9343. }
  9344. }
  9345. // withEmployee sets the old Employee of the mutation.
  9346. func withEmployee(node *Employee) employeeOption {
  9347. return func(m *EmployeeMutation) {
  9348. m.oldValue = func(context.Context) (*Employee, error) {
  9349. return node, nil
  9350. }
  9351. m.id = &node.ID
  9352. }
  9353. }
  9354. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9355. // executed in a transaction (ent.Tx), a transactional client is returned.
  9356. func (m EmployeeMutation) Client() *Client {
  9357. client := &Client{config: m.config}
  9358. client.init()
  9359. return client
  9360. }
  9361. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9362. // it returns an error otherwise.
  9363. func (m EmployeeMutation) Tx() (*Tx, error) {
  9364. if _, ok := m.driver.(*txDriver); !ok {
  9365. return nil, errors.New("ent: mutation is not running in a transaction")
  9366. }
  9367. tx := &Tx{config: m.config}
  9368. tx.init()
  9369. return tx, nil
  9370. }
  9371. // SetID sets the value of the id field. Note that this
  9372. // operation is only accepted on creation of Employee entities.
  9373. func (m *EmployeeMutation) SetID(id uint64) {
  9374. m.id = &id
  9375. }
  9376. // ID returns the ID value in the mutation. Note that the ID is only available
  9377. // if it was provided to the builder or after it was returned from the database.
  9378. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  9379. if m.id == nil {
  9380. return
  9381. }
  9382. return *m.id, true
  9383. }
  9384. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9385. // That means, if the mutation is applied within a transaction with an isolation level such
  9386. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9387. // or updated by the mutation.
  9388. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  9389. switch {
  9390. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9391. id, exists := m.ID()
  9392. if exists {
  9393. return []uint64{id}, nil
  9394. }
  9395. fallthrough
  9396. case m.op.Is(OpUpdate | OpDelete):
  9397. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  9398. default:
  9399. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9400. }
  9401. }
  9402. // SetCreatedAt sets the "created_at" field.
  9403. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  9404. m.created_at = &t
  9405. }
  9406. // CreatedAt returns the value of the "created_at" field in the mutation.
  9407. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  9408. v := m.created_at
  9409. if v == nil {
  9410. return
  9411. }
  9412. return *v, true
  9413. }
  9414. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  9415. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9417. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9418. if !m.op.Is(OpUpdateOne) {
  9419. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9420. }
  9421. if m.id == nil || m.oldValue == nil {
  9422. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9423. }
  9424. oldValue, err := m.oldValue(ctx)
  9425. if err != nil {
  9426. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9427. }
  9428. return oldValue.CreatedAt, nil
  9429. }
  9430. // ResetCreatedAt resets all changes to the "created_at" field.
  9431. func (m *EmployeeMutation) ResetCreatedAt() {
  9432. m.created_at = nil
  9433. }
  9434. // SetUpdatedAt sets the "updated_at" field.
  9435. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  9436. m.updated_at = &t
  9437. }
  9438. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9439. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  9440. v := m.updated_at
  9441. if v == nil {
  9442. return
  9443. }
  9444. return *v, true
  9445. }
  9446. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  9447. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9449. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9450. if !m.op.Is(OpUpdateOne) {
  9451. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9452. }
  9453. if m.id == nil || m.oldValue == nil {
  9454. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9455. }
  9456. oldValue, err := m.oldValue(ctx)
  9457. if err != nil {
  9458. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9459. }
  9460. return oldValue.UpdatedAt, nil
  9461. }
  9462. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9463. func (m *EmployeeMutation) ResetUpdatedAt() {
  9464. m.updated_at = nil
  9465. }
  9466. // SetDeletedAt sets the "deleted_at" field.
  9467. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  9468. m.deleted_at = &t
  9469. }
  9470. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9471. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  9472. v := m.deleted_at
  9473. if v == nil {
  9474. return
  9475. }
  9476. return *v, true
  9477. }
  9478. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  9479. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9481. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9482. if !m.op.Is(OpUpdateOne) {
  9483. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9484. }
  9485. if m.id == nil || m.oldValue == nil {
  9486. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9487. }
  9488. oldValue, err := m.oldValue(ctx)
  9489. if err != nil {
  9490. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9491. }
  9492. return oldValue.DeletedAt, nil
  9493. }
  9494. // ClearDeletedAt clears the value of the "deleted_at" field.
  9495. func (m *EmployeeMutation) ClearDeletedAt() {
  9496. m.deleted_at = nil
  9497. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  9498. }
  9499. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9500. func (m *EmployeeMutation) DeletedAtCleared() bool {
  9501. _, ok := m.clearedFields[employee.FieldDeletedAt]
  9502. return ok
  9503. }
  9504. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9505. func (m *EmployeeMutation) ResetDeletedAt() {
  9506. m.deleted_at = nil
  9507. delete(m.clearedFields, employee.FieldDeletedAt)
  9508. }
  9509. // SetTitle sets the "title" field.
  9510. func (m *EmployeeMutation) SetTitle(s string) {
  9511. m.title = &s
  9512. }
  9513. // Title returns the value of the "title" field in the mutation.
  9514. func (m *EmployeeMutation) Title() (r string, exists bool) {
  9515. v := m.title
  9516. if v == nil {
  9517. return
  9518. }
  9519. return *v, true
  9520. }
  9521. // OldTitle returns the old "title" field's value of the Employee entity.
  9522. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9524. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  9525. if !m.op.Is(OpUpdateOne) {
  9526. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  9527. }
  9528. if m.id == nil || m.oldValue == nil {
  9529. return v, errors.New("OldTitle requires an ID field in the mutation")
  9530. }
  9531. oldValue, err := m.oldValue(ctx)
  9532. if err != nil {
  9533. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  9534. }
  9535. return oldValue.Title, nil
  9536. }
  9537. // ResetTitle resets all changes to the "title" field.
  9538. func (m *EmployeeMutation) ResetTitle() {
  9539. m.title = nil
  9540. }
  9541. // SetAvatar sets the "avatar" field.
  9542. func (m *EmployeeMutation) SetAvatar(s string) {
  9543. m.avatar = &s
  9544. }
  9545. // Avatar returns the value of the "avatar" field in the mutation.
  9546. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  9547. v := m.avatar
  9548. if v == nil {
  9549. return
  9550. }
  9551. return *v, true
  9552. }
  9553. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  9554. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9556. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  9557. if !m.op.Is(OpUpdateOne) {
  9558. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  9559. }
  9560. if m.id == nil || m.oldValue == nil {
  9561. return v, errors.New("OldAvatar requires an ID field in the mutation")
  9562. }
  9563. oldValue, err := m.oldValue(ctx)
  9564. if err != nil {
  9565. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  9566. }
  9567. return oldValue.Avatar, nil
  9568. }
  9569. // ResetAvatar resets all changes to the "avatar" field.
  9570. func (m *EmployeeMutation) ResetAvatar() {
  9571. m.avatar = nil
  9572. }
  9573. // SetTags sets the "tags" field.
  9574. func (m *EmployeeMutation) SetTags(s string) {
  9575. m.tags = &s
  9576. }
  9577. // Tags returns the value of the "tags" field in the mutation.
  9578. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  9579. v := m.tags
  9580. if v == nil {
  9581. return
  9582. }
  9583. return *v, true
  9584. }
  9585. // OldTags returns the old "tags" field's value of the Employee entity.
  9586. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9588. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  9589. if !m.op.Is(OpUpdateOne) {
  9590. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  9591. }
  9592. if m.id == nil || m.oldValue == nil {
  9593. return v, errors.New("OldTags requires an ID field in the mutation")
  9594. }
  9595. oldValue, err := m.oldValue(ctx)
  9596. if err != nil {
  9597. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  9598. }
  9599. return oldValue.Tags, nil
  9600. }
  9601. // ResetTags resets all changes to the "tags" field.
  9602. func (m *EmployeeMutation) ResetTags() {
  9603. m.tags = nil
  9604. }
  9605. // SetHireCount sets the "hire_count" field.
  9606. func (m *EmployeeMutation) SetHireCount(i int) {
  9607. m.hire_count = &i
  9608. m.addhire_count = nil
  9609. }
  9610. // HireCount returns the value of the "hire_count" field in the mutation.
  9611. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  9612. v := m.hire_count
  9613. if v == nil {
  9614. return
  9615. }
  9616. return *v, true
  9617. }
  9618. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  9619. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9621. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  9622. if !m.op.Is(OpUpdateOne) {
  9623. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  9624. }
  9625. if m.id == nil || m.oldValue == nil {
  9626. return v, errors.New("OldHireCount requires an ID field in the mutation")
  9627. }
  9628. oldValue, err := m.oldValue(ctx)
  9629. if err != nil {
  9630. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  9631. }
  9632. return oldValue.HireCount, nil
  9633. }
  9634. // AddHireCount adds i to the "hire_count" field.
  9635. func (m *EmployeeMutation) AddHireCount(i int) {
  9636. if m.addhire_count != nil {
  9637. *m.addhire_count += i
  9638. } else {
  9639. m.addhire_count = &i
  9640. }
  9641. }
  9642. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  9643. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  9644. v := m.addhire_count
  9645. if v == nil {
  9646. return
  9647. }
  9648. return *v, true
  9649. }
  9650. // ResetHireCount resets all changes to the "hire_count" field.
  9651. func (m *EmployeeMutation) ResetHireCount() {
  9652. m.hire_count = nil
  9653. m.addhire_count = nil
  9654. }
  9655. // SetServiceCount sets the "service_count" field.
  9656. func (m *EmployeeMutation) SetServiceCount(i int) {
  9657. m.service_count = &i
  9658. m.addservice_count = nil
  9659. }
  9660. // ServiceCount returns the value of the "service_count" field in the mutation.
  9661. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  9662. v := m.service_count
  9663. if v == nil {
  9664. return
  9665. }
  9666. return *v, true
  9667. }
  9668. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  9669. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9671. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  9672. if !m.op.Is(OpUpdateOne) {
  9673. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  9674. }
  9675. if m.id == nil || m.oldValue == nil {
  9676. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  9677. }
  9678. oldValue, err := m.oldValue(ctx)
  9679. if err != nil {
  9680. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  9681. }
  9682. return oldValue.ServiceCount, nil
  9683. }
  9684. // AddServiceCount adds i to the "service_count" field.
  9685. func (m *EmployeeMutation) AddServiceCount(i int) {
  9686. if m.addservice_count != nil {
  9687. *m.addservice_count += i
  9688. } else {
  9689. m.addservice_count = &i
  9690. }
  9691. }
  9692. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  9693. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  9694. v := m.addservice_count
  9695. if v == nil {
  9696. return
  9697. }
  9698. return *v, true
  9699. }
  9700. // ResetServiceCount resets all changes to the "service_count" field.
  9701. func (m *EmployeeMutation) ResetServiceCount() {
  9702. m.service_count = nil
  9703. m.addservice_count = nil
  9704. }
  9705. // SetAchievementCount sets the "achievement_count" field.
  9706. func (m *EmployeeMutation) SetAchievementCount(i int) {
  9707. m.achievement_count = &i
  9708. m.addachievement_count = nil
  9709. }
  9710. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  9711. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  9712. v := m.achievement_count
  9713. if v == nil {
  9714. return
  9715. }
  9716. return *v, true
  9717. }
  9718. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  9719. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9721. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  9722. if !m.op.Is(OpUpdateOne) {
  9723. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  9724. }
  9725. if m.id == nil || m.oldValue == nil {
  9726. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  9727. }
  9728. oldValue, err := m.oldValue(ctx)
  9729. if err != nil {
  9730. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  9731. }
  9732. return oldValue.AchievementCount, nil
  9733. }
  9734. // AddAchievementCount adds i to the "achievement_count" field.
  9735. func (m *EmployeeMutation) AddAchievementCount(i int) {
  9736. if m.addachievement_count != nil {
  9737. *m.addachievement_count += i
  9738. } else {
  9739. m.addachievement_count = &i
  9740. }
  9741. }
  9742. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  9743. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  9744. v := m.addachievement_count
  9745. if v == nil {
  9746. return
  9747. }
  9748. return *v, true
  9749. }
  9750. // ResetAchievementCount resets all changes to the "achievement_count" field.
  9751. func (m *EmployeeMutation) ResetAchievementCount() {
  9752. m.achievement_count = nil
  9753. m.addachievement_count = nil
  9754. }
  9755. // SetIntro sets the "intro" field.
  9756. func (m *EmployeeMutation) SetIntro(s string) {
  9757. m.intro = &s
  9758. }
  9759. // Intro returns the value of the "intro" field in the mutation.
  9760. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9761. v := m.intro
  9762. if v == nil {
  9763. return
  9764. }
  9765. return *v, true
  9766. }
  9767. // OldIntro returns the old "intro" field's value of the Employee entity.
  9768. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9770. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9771. if !m.op.Is(OpUpdateOne) {
  9772. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9773. }
  9774. if m.id == nil || m.oldValue == nil {
  9775. return v, errors.New("OldIntro requires an ID field in the mutation")
  9776. }
  9777. oldValue, err := m.oldValue(ctx)
  9778. if err != nil {
  9779. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9780. }
  9781. return oldValue.Intro, nil
  9782. }
  9783. // ResetIntro resets all changes to the "intro" field.
  9784. func (m *EmployeeMutation) ResetIntro() {
  9785. m.intro = nil
  9786. }
  9787. // SetEstimate sets the "estimate" field.
  9788. func (m *EmployeeMutation) SetEstimate(s string) {
  9789. m.estimate = &s
  9790. }
  9791. // Estimate returns the value of the "estimate" field in the mutation.
  9792. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9793. v := m.estimate
  9794. if v == nil {
  9795. return
  9796. }
  9797. return *v, true
  9798. }
  9799. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9800. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9802. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9803. if !m.op.Is(OpUpdateOne) {
  9804. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9805. }
  9806. if m.id == nil || m.oldValue == nil {
  9807. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9808. }
  9809. oldValue, err := m.oldValue(ctx)
  9810. if err != nil {
  9811. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9812. }
  9813. return oldValue.Estimate, nil
  9814. }
  9815. // ResetEstimate resets all changes to the "estimate" field.
  9816. func (m *EmployeeMutation) ResetEstimate() {
  9817. m.estimate = nil
  9818. }
  9819. // SetSkill sets the "skill" field.
  9820. func (m *EmployeeMutation) SetSkill(s string) {
  9821. m.skill = &s
  9822. }
  9823. // Skill returns the value of the "skill" field in the mutation.
  9824. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9825. v := m.skill
  9826. if v == nil {
  9827. return
  9828. }
  9829. return *v, true
  9830. }
  9831. // OldSkill returns the old "skill" field's value of the Employee entity.
  9832. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9834. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9835. if !m.op.Is(OpUpdateOne) {
  9836. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9837. }
  9838. if m.id == nil || m.oldValue == nil {
  9839. return v, errors.New("OldSkill requires an ID field in the mutation")
  9840. }
  9841. oldValue, err := m.oldValue(ctx)
  9842. if err != nil {
  9843. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9844. }
  9845. return oldValue.Skill, nil
  9846. }
  9847. // ResetSkill resets all changes to the "skill" field.
  9848. func (m *EmployeeMutation) ResetSkill() {
  9849. m.skill = nil
  9850. }
  9851. // SetAbilityType sets the "ability_type" field.
  9852. func (m *EmployeeMutation) SetAbilityType(s string) {
  9853. m.ability_type = &s
  9854. }
  9855. // AbilityType returns the value of the "ability_type" field in the mutation.
  9856. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9857. v := m.ability_type
  9858. if v == nil {
  9859. return
  9860. }
  9861. return *v, true
  9862. }
  9863. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9864. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9866. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9867. if !m.op.Is(OpUpdateOne) {
  9868. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9869. }
  9870. if m.id == nil || m.oldValue == nil {
  9871. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9872. }
  9873. oldValue, err := m.oldValue(ctx)
  9874. if err != nil {
  9875. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9876. }
  9877. return oldValue.AbilityType, nil
  9878. }
  9879. // ResetAbilityType resets all changes to the "ability_type" field.
  9880. func (m *EmployeeMutation) ResetAbilityType() {
  9881. m.ability_type = nil
  9882. }
  9883. // SetScene sets the "scene" field.
  9884. func (m *EmployeeMutation) SetScene(s string) {
  9885. m.scene = &s
  9886. }
  9887. // Scene returns the value of the "scene" field in the mutation.
  9888. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9889. v := m.scene
  9890. if v == nil {
  9891. return
  9892. }
  9893. return *v, true
  9894. }
  9895. // OldScene returns the old "scene" field's value of the Employee entity.
  9896. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9898. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9899. if !m.op.Is(OpUpdateOne) {
  9900. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9901. }
  9902. if m.id == nil || m.oldValue == nil {
  9903. return v, errors.New("OldScene requires an ID field in the mutation")
  9904. }
  9905. oldValue, err := m.oldValue(ctx)
  9906. if err != nil {
  9907. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9908. }
  9909. return oldValue.Scene, nil
  9910. }
  9911. // ResetScene resets all changes to the "scene" field.
  9912. func (m *EmployeeMutation) ResetScene() {
  9913. m.scene = nil
  9914. }
  9915. // SetSwitchIn sets the "switch_in" field.
  9916. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9917. m.switch_in = &s
  9918. }
  9919. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9920. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9921. v := m.switch_in
  9922. if v == nil {
  9923. return
  9924. }
  9925. return *v, true
  9926. }
  9927. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9928. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9930. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9931. if !m.op.Is(OpUpdateOne) {
  9932. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9933. }
  9934. if m.id == nil || m.oldValue == nil {
  9935. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9936. }
  9937. oldValue, err := m.oldValue(ctx)
  9938. if err != nil {
  9939. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9940. }
  9941. return oldValue.SwitchIn, nil
  9942. }
  9943. // ResetSwitchIn resets all changes to the "switch_in" field.
  9944. func (m *EmployeeMutation) ResetSwitchIn() {
  9945. m.switch_in = nil
  9946. }
  9947. // SetVideoURL sets the "video_url" field.
  9948. func (m *EmployeeMutation) SetVideoURL(s string) {
  9949. m.video_url = &s
  9950. }
  9951. // VideoURL returns the value of the "video_url" field in the mutation.
  9952. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9953. v := m.video_url
  9954. if v == nil {
  9955. return
  9956. }
  9957. return *v, true
  9958. }
  9959. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9960. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9962. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9963. if !m.op.Is(OpUpdateOne) {
  9964. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9965. }
  9966. if m.id == nil || m.oldValue == nil {
  9967. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9968. }
  9969. oldValue, err := m.oldValue(ctx)
  9970. if err != nil {
  9971. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9972. }
  9973. return oldValue.VideoURL, nil
  9974. }
  9975. // ResetVideoURL resets all changes to the "video_url" field.
  9976. func (m *EmployeeMutation) ResetVideoURL() {
  9977. m.video_url = nil
  9978. }
  9979. // SetOrganizationID sets the "organization_id" field.
  9980. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9981. m.organization_id = &u
  9982. m.addorganization_id = nil
  9983. }
  9984. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9985. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9986. v := m.organization_id
  9987. if v == nil {
  9988. return
  9989. }
  9990. return *v, true
  9991. }
  9992. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9993. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9995. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9996. if !m.op.Is(OpUpdateOne) {
  9997. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9998. }
  9999. if m.id == nil || m.oldValue == nil {
  10000. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10001. }
  10002. oldValue, err := m.oldValue(ctx)
  10003. if err != nil {
  10004. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10005. }
  10006. return oldValue.OrganizationID, nil
  10007. }
  10008. // AddOrganizationID adds u to the "organization_id" field.
  10009. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  10010. if m.addorganization_id != nil {
  10011. *m.addorganization_id += u
  10012. } else {
  10013. m.addorganization_id = &u
  10014. }
  10015. }
  10016. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10017. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  10018. v := m.addorganization_id
  10019. if v == nil {
  10020. return
  10021. }
  10022. return *v, true
  10023. }
  10024. // ResetOrganizationID resets all changes to the "organization_id" field.
  10025. func (m *EmployeeMutation) ResetOrganizationID() {
  10026. m.organization_id = nil
  10027. m.addorganization_id = nil
  10028. }
  10029. // SetCategoryID sets the "category_id" field.
  10030. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  10031. m.category_id = &u
  10032. m.addcategory_id = nil
  10033. }
  10034. // CategoryID returns the value of the "category_id" field in the mutation.
  10035. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  10036. v := m.category_id
  10037. if v == nil {
  10038. return
  10039. }
  10040. return *v, true
  10041. }
  10042. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  10043. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10045. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  10046. if !m.op.Is(OpUpdateOne) {
  10047. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  10048. }
  10049. if m.id == nil || m.oldValue == nil {
  10050. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  10051. }
  10052. oldValue, err := m.oldValue(ctx)
  10053. if err != nil {
  10054. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  10055. }
  10056. return oldValue.CategoryID, nil
  10057. }
  10058. // AddCategoryID adds u to the "category_id" field.
  10059. func (m *EmployeeMutation) AddCategoryID(u int64) {
  10060. if m.addcategory_id != nil {
  10061. *m.addcategory_id += u
  10062. } else {
  10063. m.addcategory_id = &u
  10064. }
  10065. }
  10066. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  10067. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  10068. v := m.addcategory_id
  10069. if v == nil {
  10070. return
  10071. }
  10072. return *v, true
  10073. }
  10074. // ResetCategoryID resets all changes to the "category_id" field.
  10075. func (m *EmployeeMutation) ResetCategoryID() {
  10076. m.category_id = nil
  10077. m.addcategory_id = nil
  10078. }
  10079. // SetAPIBase sets the "api_base" field.
  10080. func (m *EmployeeMutation) SetAPIBase(s string) {
  10081. m.api_base = &s
  10082. }
  10083. // APIBase returns the value of the "api_base" field in the mutation.
  10084. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  10085. v := m.api_base
  10086. if v == nil {
  10087. return
  10088. }
  10089. return *v, true
  10090. }
  10091. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  10092. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10094. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  10095. if !m.op.Is(OpUpdateOne) {
  10096. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  10097. }
  10098. if m.id == nil || m.oldValue == nil {
  10099. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  10100. }
  10101. oldValue, err := m.oldValue(ctx)
  10102. if err != nil {
  10103. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  10104. }
  10105. return oldValue.APIBase, nil
  10106. }
  10107. // ResetAPIBase resets all changes to the "api_base" field.
  10108. func (m *EmployeeMutation) ResetAPIBase() {
  10109. m.api_base = nil
  10110. }
  10111. // SetAPIKey sets the "api_key" field.
  10112. func (m *EmployeeMutation) SetAPIKey(s string) {
  10113. m.api_key = &s
  10114. }
  10115. // APIKey returns the value of the "api_key" field in the mutation.
  10116. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  10117. v := m.api_key
  10118. if v == nil {
  10119. return
  10120. }
  10121. return *v, true
  10122. }
  10123. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  10124. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10126. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  10127. if !m.op.Is(OpUpdateOne) {
  10128. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  10129. }
  10130. if m.id == nil || m.oldValue == nil {
  10131. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  10132. }
  10133. oldValue, err := m.oldValue(ctx)
  10134. if err != nil {
  10135. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  10136. }
  10137. return oldValue.APIKey, nil
  10138. }
  10139. // ResetAPIKey resets all changes to the "api_key" field.
  10140. func (m *EmployeeMutation) ResetAPIKey() {
  10141. m.api_key = nil
  10142. }
  10143. // SetAiInfo sets the "ai_info" field.
  10144. func (m *EmployeeMutation) SetAiInfo(s string) {
  10145. m.ai_info = &s
  10146. }
  10147. // AiInfo returns the value of the "ai_info" field in the mutation.
  10148. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  10149. v := m.ai_info
  10150. if v == nil {
  10151. return
  10152. }
  10153. return *v, true
  10154. }
  10155. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  10156. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10158. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  10159. if !m.op.Is(OpUpdateOne) {
  10160. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  10161. }
  10162. if m.id == nil || m.oldValue == nil {
  10163. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  10164. }
  10165. oldValue, err := m.oldValue(ctx)
  10166. if err != nil {
  10167. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  10168. }
  10169. return oldValue.AiInfo, nil
  10170. }
  10171. // ClearAiInfo clears the value of the "ai_info" field.
  10172. func (m *EmployeeMutation) ClearAiInfo() {
  10173. m.ai_info = nil
  10174. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  10175. }
  10176. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  10177. func (m *EmployeeMutation) AiInfoCleared() bool {
  10178. _, ok := m.clearedFields[employee.FieldAiInfo]
  10179. return ok
  10180. }
  10181. // ResetAiInfo resets all changes to the "ai_info" field.
  10182. func (m *EmployeeMutation) ResetAiInfo() {
  10183. m.ai_info = nil
  10184. delete(m.clearedFields, employee.FieldAiInfo)
  10185. }
  10186. // SetIsVip sets the "is_vip" field.
  10187. func (m *EmployeeMutation) SetIsVip(i int) {
  10188. m.is_vip = &i
  10189. m.addis_vip = nil
  10190. }
  10191. // IsVip returns the value of the "is_vip" field in the mutation.
  10192. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  10193. v := m.is_vip
  10194. if v == nil {
  10195. return
  10196. }
  10197. return *v, true
  10198. }
  10199. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  10200. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10202. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  10203. if !m.op.Is(OpUpdateOne) {
  10204. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  10205. }
  10206. if m.id == nil || m.oldValue == nil {
  10207. return v, errors.New("OldIsVip requires an ID field in the mutation")
  10208. }
  10209. oldValue, err := m.oldValue(ctx)
  10210. if err != nil {
  10211. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  10212. }
  10213. return oldValue.IsVip, nil
  10214. }
  10215. // AddIsVip adds i to the "is_vip" field.
  10216. func (m *EmployeeMutation) AddIsVip(i int) {
  10217. if m.addis_vip != nil {
  10218. *m.addis_vip += i
  10219. } else {
  10220. m.addis_vip = &i
  10221. }
  10222. }
  10223. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  10224. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  10225. v := m.addis_vip
  10226. if v == nil {
  10227. return
  10228. }
  10229. return *v, true
  10230. }
  10231. // ResetIsVip resets all changes to the "is_vip" field.
  10232. func (m *EmployeeMutation) ResetIsVip() {
  10233. m.is_vip = nil
  10234. m.addis_vip = nil
  10235. }
  10236. // SetChatURL sets the "chat_url" field.
  10237. func (m *EmployeeMutation) SetChatURL(s string) {
  10238. m.chat_url = &s
  10239. }
  10240. // ChatURL returns the value of the "chat_url" field in the mutation.
  10241. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  10242. v := m.chat_url
  10243. if v == nil {
  10244. return
  10245. }
  10246. return *v, true
  10247. }
  10248. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  10249. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  10250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10251. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  10252. if !m.op.Is(OpUpdateOne) {
  10253. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  10254. }
  10255. if m.id == nil || m.oldValue == nil {
  10256. return v, errors.New("OldChatURL requires an ID field in the mutation")
  10257. }
  10258. oldValue, err := m.oldValue(ctx)
  10259. if err != nil {
  10260. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  10261. }
  10262. return oldValue.ChatURL, nil
  10263. }
  10264. // ResetChatURL resets all changes to the "chat_url" field.
  10265. func (m *EmployeeMutation) ResetChatURL() {
  10266. m.chat_url = nil
  10267. }
  10268. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  10269. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  10270. if m.em_work_experiences == nil {
  10271. m.em_work_experiences = make(map[uint64]struct{})
  10272. }
  10273. for i := range ids {
  10274. m.em_work_experiences[ids[i]] = struct{}{}
  10275. }
  10276. }
  10277. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  10278. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  10279. m.clearedem_work_experiences = true
  10280. }
  10281. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  10282. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  10283. return m.clearedem_work_experiences
  10284. }
  10285. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  10286. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  10287. if m.removedem_work_experiences == nil {
  10288. m.removedem_work_experiences = make(map[uint64]struct{})
  10289. }
  10290. for i := range ids {
  10291. delete(m.em_work_experiences, ids[i])
  10292. m.removedem_work_experiences[ids[i]] = struct{}{}
  10293. }
  10294. }
  10295. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  10296. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  10297. for id := range m.removedem_work_experiences {
  10298. ids = append(ids, id)
  10299. }
  10300. return
  10301. }
  10302. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  10303. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  10304. for id := range m.em_work_experiences {
  10305. ids = append(ids, id)
  10306. }
  10307. return
  10308. }
  10309. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  10310. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  10311. m.em_work_experiences = nil
  10312. m.clearedem_work_experiences = false
  10313. m.removedem_work_experiences = nil
  10314. }
  10315. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  10316. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  10317. if m.em_tutorial == nil {
  10318. m.em_tutorial = make(map[uint64]struct{})
  10319. }
  10320. for i := range ids {
  10321. m.em_tutorial[ids[i]] = struct{}{}
  10322. }
  10323. }
  10324. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  10325. func (m *EmployeeMutation) ClearEmTutorial() {
  10326. m.clearedem_tutorial = true
  10327. }
  10328. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  10329. func (m *EmployeeMutation) EmTutorialCleared() bool {
  10330. return m.clearedem_tutorial
  10331. }
  10332. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  10333. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  10334. if m.removedem_tutorial == nil {
  10335. m.removedem_tutorial = make(map[uint64]struct{})
  10336. }
  10337. for i := range ids {
  10338. delete(m.em_tutorial, ids[i])
  10339. m.removedem_tutorial[ids[i]] = struct{}{}
  10340. }
  10341. }
  10342. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  10343. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  10344. for id := range m.removedem_tutorial {
  10345. ids = append(ids, id)
  10346. }
  10347. return
  10348. }
  10349. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  10350. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  10351. for id := range m.em_tutorial {
  10352. ids = append(ids, id)
  10353. }
  10354. return
  10355. }
  10356. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  10357. func (m *EmployeeMutation) ResetEmTutorial() {
  10358. m.em_tutorial = nil
  10359. m.clearedem_tutorial = false
  10360. m.removedem_tutorial = nil
  10361. }
  10362. // Where appends a list predicates to the EmployeeMutation builder.
  10363. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  10364. m.predicates = append(m.predicates, ps...)
  10365. }
  10366. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  10367. // users can use type-assertion to append predicates that do not depend on any generated package.
  10368. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  10369. p := make([]predicate.Employee, len(ps))
  10370. for i := range ps {
  10371. p[i] = ps[i]
  10372. }
  10373. m.Where(p...)
  10374. }
  10375. // Op returns the operation name.
  10376. func (m *EmployeeMutation) Op() Op {
  10377. return m.op
  10378. }
  10379. // SetOp allows setting the mutation operation.
  10380. func (m *EmployeeMutation) SetOp(op Op) {
  10381. m.op = op
  10382. }
  10383. // Type returns the node type of this mutation (Employee).
  10384. func (m *EmployeeMutation) Type() string {
  10385. return m.typ
  10386. }
  10387. // Fields returns all fields that were changed during this mutation. Note that in
  10388. // order to get all numeric fields that were incremented/decremented, call
  10389. // AddedFields().
  10390. func (m *EmployeeMutation) Fields() []string {
  10391. fields := make([]string, 0, 23)
  10392. if m.created_at != nil {
  10393. fields = append(fields, employee.FieldCreatedAt)
  10394. }
  10395. if m.updated_at != nil {
  10396. fields = append(fields, employee.FieldUpdatedAt)
  10397. }
  10398. if m.deleted_at != nil {
  10399. fields = append(fields, employee.FieldDeletedAt)
  10400. }
  10401. if m.title != nil {
  10402. fields = append(fields, employee.FieldTitle)
  10403. }
  10404. if m.avatar != nil {
  10405. fields = append(fields, employee.FieldAvatar)
  10406. }
  10407. if m.tags != nil {
  10408. fields = append(fields, employee.FieldTags)
  10409. }
  10410. if m.hire_count != nil {
  10411. fields = append(fields, employee.FieldHireCount)
  10412. }
  10413. if m.service_count != nil {
  10414. fields = append(fields, employee.FieldServiceCount)
  10415. }
  10416. if m.achievement_count != nil {
  10417. fields = append(fields, employee.FieldAchievementCount)
  10418. }
  10419. if m.intro != nil {
  10420. fields = append(fields, employee.FieldIntro)
  10421. }
  10422. if m.estimate != nil {
  10423. fields = append(fields, employee.FieldEstimate)
  10424. }
  10425. if m.skill != nil {
  10426. fields = append(fields, employee.FieldSkill)
  10427. }
  10428. if m.ability_type != nil {
  10429. fields = append(fields, employee.FieldAbilityType)
  10430. }
  10431. if m.scene != nil {
  10432. fields = append(fields, employee.FieldScene)
  10433. }
  10434. if m.switch_in != nil {
  10435. fields = append(fields, employee.FieldSwitchIn)
  10436. }
  10437. if m.video_url != nil {
  10438. fields = append(fields, employee.FieldVideoURL)
  10439. }
  10440. if m.organization_id != nil {
  10441. fields = append(fields, employee.FieldOrganizationID)
  10442. }
  10443. if m.category_id != nil {
  10444. fields = append(fields, employee.FieldCategoryID)
  10445. }
  10446. if m.api_base != nil {
  10447. fields = append(fields, employee.FieldAPIBase)
  10448. }
  10449. if m.api_key != nil {
  10450. fields = append(fields, employee.FieldAPIKey)
  10451. }
  10452. if m.ai_info != nil {
  10453. fields = append(fields, employee.FieldAiInfo)
  10454. }
  10455. if m.is_vip != nil {
  10456. fields = append(fields, employee.FieldIsVip)
  10457. }
  10458. if m.chat_url != nil {
  10459. fields = append(fields, employee.FieldChatURL)
  10460. }
  10461. return fields
  10462. }
  10463. // Field returns the value of a field with the given name. The second boolean
  10464. // return value indicates that this field was not set, or was not defined in the
  10465. // schema.
  10466. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  10467. switch name {
  10468. case employee.FieldCreatedAt:
  10469. return m.CreatedAt()
  10470. case employee.FieldUpdatedAt:
  10471. return m.UpdatedAt()
  10472. case employee.FieldDeletedAt:
  10473. return m.DeletedAt()
  10474. case employee.FieldTitle:
  10475. return m.Title()
  10476. case employee.FieldAvatar:
  10477. return m.Avatar()
  10478. case employee.FieldTags:
  10479. return m.Tags()
  10480. case employee.FieldHireCount:
  10481. return m.HireCount()
  10482. case employee.FieldServiceCount:
  10483. return m.ServiceCount()
  10484. case employee.FieldAchievementCount:
  10485. return m.AchievementCount()
  10486. case employee.FieldIntro:
  10487. return m.Intro()
  10488. case employee.FieldEstimate:
  10489. return m.Estimate()
  10490. case employee.FieldSkill:
  10491. return m.Skill()
  10492. case employee.FieldAbilityType:
  10493. return m.AbilityType()
  10494. case employee.FieldScene:
  10495. return m.Scene()
  10496. case employee.FieldSwitchIn:
  10497. return m.SwitchIn()
  10498. case employee.FieldVideoURL:
  10499. return m.VideoURL()
  10500. case employee.FieldOrganizationID:
  10501. return m.OrganizationID()
  10502. case employee.FieldCategoryID:
  10503. return m.CategoryID()
  10504. case employee.FieldAPIBase:
  10505. return m.APIBase()
  10506. case employee.FieldAPIKey:
  10507. return m.APIKey()
  10508. case employee.FieldAiInfo:
  10509. return m.AiInfo()
  10510. case employee.FieldIsVip:
  10511. return m.IsVip()
  10512. case employee.FieldChatURL:
  10513. return m.ChatURL()
  10514. }
  10515. return nil, false
  10516. }
  10517. // OldField returns the old value of the field from the database. An error is
  10518. // returned if the mutation operation is not UpdateOne, or the query to the
  10519. // database failed.
  10520. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10521. switch name {
  10522. case employee.FieldCreatedAt:
  10523. return m.OldCreatedAt(ctx)
  10524. case employee.FieldUpdatedAt:
  10525. return m.OldUpdatedAt(ctx)
  10526. case employee.FieldDeletedAt:
  10527. return m.OldDeletedAt(ctx)
  10528. case employee.FieldTitle:
  10529. return m.OldTitle(ctx)
  10530. case employee.FieldAvatar:
  10531. return m.OldAvatar(ctx)
  10532. case employee.FieldTags:
  10533. return m.OldTags(ctx)
  10534. case employee.FieldHireCount:
  10535. return m.OldHireCount(ctx)
  10536. case employee.FieldServiceCount:
  10537. return m.OldServiceCount(ctx)
  10538. case employee.FieldAchievementCount:
  10539. return m.OldAchievementCount(ctx)
  10540. case employee.FieldIntro:
  10541. return m.OldIntro(ctx)
  10542. case employee.FieldEstimate:
  10543. return m.OldEstimate(ctx)
  10544. case employee.FieldSkill:
  10545. return m.OldSkill(ctx)
  10546. case employee.FieldAbilityType:
  10547. return m.OldAbilityType(ctx)
  10548. case employee.FieldScene:
  10549. return m.OldScene(ctx)
  10550. case employee.FieldSwitchIn:
  10551. return m.OldSwitchIn(ctx)
  10552. case employee.FieldVideoURL:
  10553. return m.OldVideoURL(ctx)
  10554. case employee.FieldOrganizationID:
  10555. return m.OldOrganizationID(ctx)
  10556. case employee.FieldCategoryID:
  10557. return m.OldCategoryID(ctx)
  10558. case employee.FieldAPIBase:
  10559. return m.OldAPIBase(ctx)
  10560. case employee.FieldAPIKey:
  10561. return m.OldAPIKey(ctx)
  10562. case employee.FieldAiInfo:
  10563. return m.OldAiInfo(ctx)
  10564. case employee.FieldIsVip:
  10565. return m.OldIsVip(ctx)
  10566. case employee.FieldChatURL:
  10567. return m.OldChatURL(ctx)
  10568. }
  10569. return nil, fmt.Errorf("unknown Employee field %s", name)
  10570. }
  10571. // SetField sets the value of a field with the given name. It returns an error if
  10572. // the field is not defined in the schema, or if the type mismatched the field
  10573. // type.
  10574. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  10575. switch name {
  10576. case employee.FieldCreatedAt:
  10577. v, ok := value.(time.Time)
  10578. if !ok {
  10579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10580. }
  10581. m.SetCreatedAt(v)
  10582. return nil
  10583. case employee.FieldUpdatedAt:
  10584. v, ok := value.(time.Time)
  10585. if !ok {
  10586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10587. }
  10588. m.SetUpdatedAt(v)
  10589. return nil
  10590. case employee.FieldDeletedAt:
  10591. v, ok := value.(time.Time)
  10592. if !ok {
  10593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10594. }
  10595. m.SetDeletedAt(v)
  10596. return nil
  10597. case employee.FieldTitle:
  10598. v, ok := value.(string)
  10599. if !ok {
  10600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10601. }
  10602. m.SetTitle(v)
  10603. return nil
  10604. case employee.FieldAvatar:
  10605. v, ok := value.(string)
  10606. if !ok {
  10607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10608. }
  10609. m.SetAvatar(v)
  10610. return nil
  10611. case employee.FieldTags:
  10612. v, ok := value.(string)
  10613. if !ok {
  10614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10615. }
  10616. m.SetTags(v)
  10617. return nil
  10618. case employee.FieldHireCount:
  10619. v, ok := value.(int)
  10620. if !ok {
  10621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10622. }
  10623. m.SetHireCount(v)
  10624. return nil
  10625. case employee.FieldServiceCount:
  10626. v, ok := value.(int)
  10627. if !ok {
  10628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10629. }
  10630. m.SetServiceCount(v)
  10631. return nil
  10632. case employee.FieldAchievementCount:
  10633. v, ok := value.(int)
  10634. if !ok {
  10635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10636. }
  10637. m.SetAchievementCount(v)
  10638. return nil
  10639. case employee.FieldIntro:
  10640. v, ok := value.(string)
  10641. if !ok {
  10642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10643. }
  10644. m.SetIntro(v)
  10645. return nil
  10646. case employee.FieldEstimate:
  10647. v, ok := value.(string)
  10648. if !ok {
  10649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10650. }
  10651. m.SetEstimate(v)
  10652. return nil
  10653. case employee.FieldSkill:
  10654. v, ok := value.(string)
  10655. if !ok {
  10656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10657. }
  10658. m.SetSkill(v)
  10659. return nil
  10660. case employee.FieldAbilityType:
  10661. v, ok := value.(string)
  10662. if !ok {
  10663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10664. }
  10665. m.SetAbilityType(v)
  10666. return nil
  10667. case employee.FieldScene:
  10668. v, ok := value.(string)
  10669. if !ok {
  10670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10671. }
  10672. m.SetScene(v)
  10673. return nil
  10674. case employee.FieldSwitchIn:
  10675. v, ok := value.(string)
  10676. if !ok {
  10677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10678. }
  10679. m.SetSwitchIn(v)
  10680. return nil
  10681. case employee.FieldVideoURL:
  10682. v, ok := value.(string)
  10683. if !ok {
  10684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10685. }
  10686. m.SetVideoURL(v)
  10687. return nil
  10688. case employee.FieldOrganizationID:
  10689. v, ok := value.(uint64)
  10690. if !ok {
  10691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10692. }
  10693. m.SetOrganizationID(v)
  10694. return nil
  10695. case employee.FieldCategoryID:
  10696. v, ok := value.(uint64)
  10697. if !ok {
  10698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10699. }
  10700. m.SetCategoryID(v)
  10701. return nil
  10702. case employee.FieldAPIBase:
  10703. v, ok := value.(string)
  10704. if !ok {
  10705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10706. }
  10707. m.SetAPIBase(v)
  10708. return nil
  10709. case employee.FieldAPIKey:
  10710. v, ok := value.(string)
  10711. if !ok {
  10712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10713. }
  10714. m.SetAPIKey(v)
  10715. return nil
  10716. case employee.FieldAiInfo:
  10717. v, ok := value.(string)
  10718. if !ok {
  10719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10720. }
  10721. m.SetAiInfo(v)
  10722. return nil
  10723. case employee.FieldIsVip:
  10724. v, ok := value.(int)
  10725. if !ok {
  10726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10727. }
  10728. m.SetIsVip(v)
  10729. return nil
  10730. case employee.FieldChatURL:
  10731. v, ok := value.(string)
  10732. if !ok {
  10733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10734. }
  10735. m.SetChatURL(v)
  10736. return nil
  10737. }
  10738. return fmt.Errorf("unknown Employee field %s", name)
  10739. }
  10740. // AddedFields returns all numeric fields that were incremented/decremented during
  10741. // this mutation.
  10742. func (m *EmployeeMutation) AddedFields() []string {
  10743. var fields []string
  10744. if m.addhire_count != nil {
  10745. fields = append(fields, employee.FieldHireCount)
  10746. }
  10747. if m.addservice_count != nil {
  10748. fields = append(fields, employee.FieldServiceCount)
  10749. }
  10750. if m.addachievement_count != nil {
  10751. fields = append(fields, employee.FieldAchievementCount)
  10752. }
  10753. if m.addorganization_id != nil {
  10754. fields = append(fields, employee.FieldOrganizationID)
  10755. }
  10756. if m.addcategory_id != nil {
  10757. fields = append(fields, employee.FieldCategoryID)
  10758. }
  10759. if m.addis_vip != nil {
  10760. fields = append(fields, employee.FieldIsVip)
  10761. }
  10762. return fields
  10763. }
  10764. // AddedField returns the numeric value that was incremented/decremented on a field
  10765. // with the given name. The second boolean return value indicates that this field
  10766. // was not set, or was not defined in the schema.
  10767. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10768. switch name {
  10769. case employee.FieldHireCount:
  10770. return m.AddedHireCount()
  10771. case employee.FieldServiceCount:
  10772. return m.AddedServiceCount()
  10773. case employee.FieldAchievementCount:
  10774. return m.AddedAchievementCount()
  10775. case employee.FieldOrganizationID:
  10776. return m.AddedOrganizationID()
  10777. case employee.FieldCategoryID:
  10778. return m.AddedCategoryID()
  10779. case employee.FieldIsVip:
  10780. return m.AddedIsVip()
  10781. }
  10782. return nil, false
  10783. }
  10784. // AddField adds the value to the field with the given name. It returns an error if
  10785. // the field is not defined in the schema, or if the type mismatched the field
  10786. // type.
  10787. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10788. switch name {
  10789. case employee.FieldHireCount:
  10790. v, ok := value.(int)
  10791. if !ok {
  10792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10793. }
  10794. m.AddHireCount(v)
  10795. return nil
  10796. case employee.FieldServiceCount:
  10797. v, ok := value.(int)
  10798. if !ok {
  10799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10800. }
  10801. m.AddServiceCount(v)
  10802. return nil
  10803. case employee.FieldAchievementCount:
  10804. v, ok := value.(int)
  10805. if !ok {
  10806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10807. }
  10808. m.AddAchievementCount(v)
  10809. return nil
  10810. case employee.FieldOrganizationID:
  10811. v, ok := value.(int64)
  10812. if !ok {
  10813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10814. }
  10815. m.AddOrganizationID(v)
  10816. return nil
  10817. case employee.FieldCategoryID:
  10818. v, ok := value.(int64)
  10819. if !ok {
  10820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10821. }
  10822. m.AddCategoryID(v)
  10823. return nil
  10824. case employee.FieldIsVip:
  10825. v, ok := value.(int)
  10826. if !ok {
  10827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10828. }
  10829. m.AddIsVip(v)
  10830. return nil
  10831. }
  10832. return fmt.Errorf("unknown Employee numeric field %s", name)
  10833. }
  10834. // ClearedFields returns all nullable fields that were cleared during this
  10835. // mutation.
  10836. func (m *EmployeeMutation) ClearedFields() []string {
  10837. var fields []string
  10838. if m.FieldCleared(employee.FieldDeletedAt) {
  10839. fields = append(fields, employee.FieldDeletedAt)
  10840. }
  10841. if m.FieldCleared(employee.FieldAiInfo) {
  10842. fields = append(fields, employee.FieldAiInfo)
  10843. }
  10844. return fields
  10845. }
  10846. // FieldCleared returns a boolean indicating if a field with the given name was
  10847. // cleared in this mutation.
  10848. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10849. _, ok := m.clearedFields[name]
  10850. return ok
  10851. }
  10852. // ClearField clears the value of the field with the given name. It returns an
  10853. // error if the field is not defined in the schema.
  10854. func (m *EmployeeMutation) ClearField(name string) error {
  10855. switch name {
  10856. case employee.FieldDeletedAt:
  10857. m.ClearDeletedAt()
  10858. return nil
  10859. case employee.FieldAiInfo:
  10860. m.ClearAiInfo()
  10861. return nil
  10862. }
  10863. return fmt.Errorf("unknown Employee nullable field %s", name)
  10864. }
  10865. // ResetField resets all changes in the mutation for the field with the given name.
  10866. // It returns an error if the field is not defined in the schema.
  10867. func (m *EmployeeMutation) ResetField(name string) error {
  10868. switch name {
  10869. case employee.FieldCreatedAt:
  10870. m.ResetCreatedAt()
  10871. return nil
  10872. case employee.FieldUpdatedAt:
  10873. m.ResetUpdatedAt()
  10874. return nil
  10875. case employee.FieldDeletedAt:
  10876. m.ResetDeletedAt()
  10877. return nil
  10878. case employee.FieldTitle:
  10879. m.ResetTitle()
  10880. return nil
  10881. case employee.FieldAvatar:
  10882. m.ResetAvatar()
  10883. return nil
  10884. case employee.FieldTags:
  10885. m.ResetTags()
  10886. return nil
  10887. case employee.FieldHireCount:
  10888. m.ResetHireCount()
  10889. return nil
  10890. case employee.FieldServiceCount:
  10891. m.ResetServiceCount()
  10892. return nil
  10893. case employee.FieldAchievementCount:
  10894. m.ResetAchievementCount()
  10895. return nil
  10896. case employee.FieldIntro:
  10897. m.ResetIntro()
  10898. return nil
  10899. case employee.FieldEstimate:
  10900. m.ResetEstimate()
  10901. return nil
  10902. case employee.FieldSkill:
  10903. m.ResetSkill()
  10904. return nil
  10905. case employee.FieldAbilityType:
  10906. m.ResetAbilityType()
  10907. return nil
  10908. case employee.FieldScene:
  10909. m.ResetScene()
  10910. return nil
  10911. case employee.FieldSwitchIn:
  10912. m.ResetSwitchIn()
  10913. return nil
  10914. case employee.FieldVideoURL:
  10915. m.ResetVideoURL()
  10916. return nil
  10917. case employee.FieldOrganizationID:
  10918. m.ResetOrganizationID()
  10919. return nil
  10920. case employee.FieldCategoryID:
  10921. m.ResetCategoryID()
  10922. return nil
  10923. case employee.FieldAPIBase:
  10924. m.ResetAPIBase()
  10925. return nil
  10926. case employee.FieldAPIKey:
  10927. m.ResetAPIKey()
  10928. return nil
  10929. case employee.FieldAiInfo:
  10930. m.ResetAiInfo()
  10931. return nil
  10932. case employee.FieldIsVip:
  10933. m.ResetIsVip()
  10934. return nil
  10935. case employee.FieldChatURL:
  10936. m.ResetChatURL()
  10937. return nil
  10938. }
  10939. return fmt.Errorf("unknown Employee field %s", name)
  10940. }
  10941. // AddedEdges returns all edge names that were set/added in this mutation.
  10942. func (m *EmployeeMutation) AddedEdges() []string {
  10943. edges := make([]string, 0, 2)
  10944. if m.em_work_experiences != nil {
  10945. edges = append(edges, employee.EdgeEmWorkExperiences)
  10946. }
  10947. if m.em_tutorial != nil {
  10948. edges = append(edges, employee.EdgeEmTutorial)
  10949. }
  10950. return edges
  10951. }
  10952. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10953. // name in this mutation.
  10954. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10955. switch name {
  10956. case employee.EdgeEmWorkExperiences:
  10957. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10958. for id := range m.em_work_experiences {
  10959. ids = append(ids, id)
  10960. }
  10961. return ids
  10962. case employee.EdgeEmTutorial:
  10963. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10964. for id := range m.em_tutorial {
  10965. ids = append(ids, id)
  10966. }
  10967. return ids
  10968. }
  10969. return nil
  10970. }
  10971. // RemovedEdges returns all edge names that were removed in this mutation.
  10972. func (m *EmployeeMutation) RemovedEdges() []string {
  10973. edges := make([]string, 0, 2)
  10974. if m.removedem_work_experiences != nil {
  10975. edges = append(edges, employee.EdgeEmWorkExperiences)
  10976. }
  10977. if m.removedem_tutorial != nil {
  10978. edges = append(edges, employee.EdgeEmTutorial)
  10979. }
  10980. return edges
  10981. }
  10982. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10983. // the given name in this mutation.
  10984. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10985. switch name {
  10986. case employee.EdgeEmWorkExperiences:
  10987. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10988. for id := range m.removedem_work_experiences {
  10989. ids = append(ids, id)
  10990. }
  10991. return ids
  10992. case employee.EdgeEmTutorial:
  10993. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10994. for id := range m.removedem_tutorial {
  10995. ids = append(ids, id)
  10996. }
  10997. return ids
  10998. }
  10999. return nil
  11000. }
  11001. // ClearedEdges returns all edge names that were cleared in this mutation.
  11002. func (m *EmployeeMutation) ClearedEdges() []string {
  11003. edges := make([]string, 0, 2)
  11004. if m.clearedem_work_experiences {
  11005. edges = append(edges, employee.EdgeEmWorkExperiences)
  11006. }
  11007. if m.clearedem_tutorial {
  11008. edges = append(edges, employee.EdgeEmTutorial)
  11009. }
  11010. return edges
  11011. }
  11012. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11013. // was cleared in this mutation.
  11014. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  11015. switch name {
  11016. case employee.EdgeEmWorkExperiences:
  11017. return m.clearedem_work_experiences
  11018. case employee.EdgeEmTutorial:
  11019. return m.clearedem_tutorial
  11020. }
  11021. return false
  11022. }
  11023. // ClearEdge clears the value of the edge with the given name. It returns an error
  11024. // if that edge is not defined in the schema.
  11025. func (m *EmployeeMutation) ClearEdge(name string) error {
  11026. switch name {
  11027. }
  11028. return fmt.Errorf("unknown Employee unique edge %s", name)
  11029. }
  11030. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11031. // It returns an error if the edge is not defined in the schema.
  11032. func (m *EmployeeMutation) ResetEdge(name string) error {
  11033. switch name {
  11034. case employee.EdgeEmWorkExperiences:
  11035. m.ResetEmWorkExperiences()
  11036. return nil
  11037. case employee.EdgeEmTutorial:
  11038. m.ResetEmTutorial()
  11039. return nil
  11040. }
  11041. return fmt.Errorf("unknown Employee edge %s", name)
  11042. }
  11043. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  11044. type EmployeeConfigMutation struct {
  11045. config
  11046. op Op
  11047. typ string
  11048. id *uint64
  11049. created_at *time.Time
  11050. updated_at *time.Time
  11051. deleted_at *time.Time
  11052. stype *string
  11053. title *string
  11054. photo *string
  11055. organization_id *uint64
  11056. addorganization_id *int64
  11057. clearedFields map[string]struct{}
  11058. done bool
  11059. oldValue func(context.Context) (*EmployeeConfig, error)
  11060. predicates []predicate.EmployeeConfig
  11061. }
  11062. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  11063. // employeeconfigOption allows management of the mutation configuration using functional options.
  11064. type employeeconfigOption func(*EmployeeConfigMutation)
  11065. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  11066. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  11067. m := &EmployeeConfigMutation{
  11068. config: c,
  11069. op: op,
  11070. typ: TypeEmployeeConfig,
  11071. clearedFields: make(map[string]struct{}),
  11072. }
  11073. for _, opt := range opts {
  11074. opt(m)
  11075. }
  11076. return m
  11077. }
  11078. // withEmployeeConfigID sets the ID field of the mutation.
  11079. func withEmployeeConfigID(id uint64) employeeconfigOption {
  11080. return func(m *EmployeeConfigMutation) {
  11081. var (
  11082. err error
  11083. once sync.Once
  11084. value *EmployeeConfig
  11085. )
  11086. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  11087. once.Do(func() {
  11088. if m.done {
  11089. err = errors.New("querying old values post mutation is not allowed")
  11090. } else {
  11091. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  11092. }
  11093. })
  11094. return value, err
  11095. }
  11096. m.id = &id
  11097. }
  11098. }
  11099. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  11100. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  11101. return func(m *EmployeeConfigMutation) {
  11102. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  11103. return node, nil
  11104. }
  11105. m.id = &node.ID
  11106. }
  11107. }
  11108. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11109. // executed in a transaction (ent.Tx), a transactional client is returned.
  11110. func (m EmployeeConfigMutation) Client() *Client {
  11111. client := &Client{config: m.config}
  11112. client.init()
  11113. return client
  11114. }
  11115. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11116. // it returns an error otherwise.
  11117. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  11118. if _, ok := m.driver.(*txDriver); !ok {
  11119. return nil, errors.New("ent: mutation is not running in a transaction")
  11120. }
  11121. tx := &Tx{config: m.config}
  11122. tx.init()
  11123. return tx, nil
  11124. }
  11125. // SetID sets the value of the id field. Note that this
  11126. // operation is only accepted on creation of EmployeeConfig entities.
  11127. func (m *EmployeeConfigMutation) SetID(id uint64) {
  11128. m.id = &id
  11129. }
  11130. // ID returns the ID value in the mutation. Note that the ID is only available
  11131. // if it was provided to the builder or after it was returned from the database.
  11132. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  11133. if m.id == nil {
  11134. return
  11135. }
  11136. return *m.id, true
  11137. }
  11138. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11139. // That means, if the mutation is applied within a transaction with an isolation level such
  11140. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11141. // or updated by the mutation.
  11142. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  11143. switch {
  11144. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11145. id, exists := m.ID()
  11146. if exists {
  11147. return []uint64{id}, nil
  11148. }
  11149. fallthrough
  11150. case m.op.Is(OpUpdate | OpDelete):
  11151. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  11152. default:
  11153. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11154. }
  11155. }
  11156. // SetCreatedAt sets the "created_at" field.
  11157. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  11158. m.created_at = &t
  11159. }
  11160. // CreatedAt returns the value of the "created_at" field in the mutation.
  11161. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  11162. v := m.created_at
  11163. if v == nil {
  11164. return
  11165. }
  11166. return *v, true
  11167. }
  11168. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  11169. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11171. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11172. if !m.op.Is(OpUpdateOne) {
  11173. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11174. }
  11175. if m.id == nil || m.oldValue == nil {
  11176. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11177. }
  11178. oldValue, err := m.oldValue(ctx)
  11179. if err != nil {
  11180. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11181. }
  11182. return oldValue.CreatedAt, nil
  11183. }
  11184. // ResetCreatedAt resets all changes to the "created_at" field.
  11185. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  11186. m.created_at = nil
  11187. }
  11188. // SetUpdatedAt sets the "updated_at" field.
  11189. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  11190. m.updated_at = &t
  11191. }
  11192. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11193. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  11194. v := m.updated_at
  11195. if v == nil {
  11196. return
  11197. }
  11198. return *v, true
  11199. }
  11200. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  11201. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11203. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11204. if !m.op.Is(OpUpdateOne) {
  11205. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11206. }
  11207. if m.id == nil || m.oldValue == nil {
  11208. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11209. }
  11210. oldValue, err := m.oldValue(ctx)
  11211. if err != nil {
  11212. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11213. }
  11214. return oldValue.UpdatedAt, nil
  11215. }
  11216. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11217. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  11218. m.updated_at = nil
  11219. }
  11220. // SetDeletedAt sets the "deleted_at" field.
  11221. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  11222. m.deleted_at = &t
  11223. }
  11224. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11225. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  11226. v := m.deleted_at
  11227. if v == nil {
  11228. return
  11229. }
  11230. return *v, true
  11231. }
  11232. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  11233. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11235. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11236. if !m.op.Is(OpUpdateOne) {
  11237. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11238. }
  11239. if m.id == nil || m.oldValue == nil {
  11240. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11241. }
  11242. oldValue, err := m.oldValue(ctx)
  11243. if err != nil {
  11244. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11245. }
  11246. return oldValue.DeletedAt, nil
  11247. }
  11248. // ClearDeletedAt clears the value of the "deleted_at" field.
  11249. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  11250. m.deleted_at = nil
  11251. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  11252. }
  11253. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11254. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  11255. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  11256. return ok
  11257. }
  11258. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11259. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  11260. m.deleted_at = nil
  11261. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  11262. }
  11263. // SetStype sets the "stype" field.
  11264. func (m *EmployeeConfigMutation) SetStype(s string) {
  11265. m.stype = &s
  11266. }
  11267. // Stype returns the value of the "stype" field in the mutation.
  11268. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  11269. v := m.stype
  11270. if v == nil {
  11271. return
  11272. }
  11273. return *v, true
  11274. }
  11275. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  11276. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11278. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  11279. if !m.op.Is(OpUpdateOne) {
  11280. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  11281. }
  11282. if m.id == nil || m.oldValue == nil {
  11283. return v, errors.New("OldStype requires an ID field in the mutation")
  11284. }
  11285. oldValue, err := m.oldValue(ctx)
  11286. if err != nil {
  11287. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  11288. }
  11289. return oldValue.Stype, nil
  11290. }
  11291. // ResetStype resets all changes to the "stype" field.
  11292. func (m *EmployeeConfigMutation) ResetStype() {
  11293. m.stype = nil
  11294. }
  11295. // SetTitle sets the "title" field.
  11296. func (m *EmployeeConfigMutation) SetTitle(s string) {
  11297. m.title = &s
  11298. }
  11299. // Title returns the value of the "title" field in the mutation.
  11300. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  11301. v := m.title
  11302. if v == nil {
  11303. return
  11304. }
  11305. return *v, true
  11306. }
  11307. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  11308. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11310. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  11311. if !m.op.Is(OpUpdateOne) {
  11312. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11313. }
  11314. if m.id == nil || m.oldValue == nil {
  11315. return v, errors.New("OldTitle requires an ID field in the mutation")
  11316. }
  11317. oldValue, err := m.oldValue(ctx)
  11318. if err != nil {
  11319. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11320. }
  11321. return oldValue.Title, nil
  11322. }
  11323. // ResetTitle resets all changes to the "title" field.
  11324. func (m *EmployeeConfigMutation) ResetTitle() {
  11325. m.title = nil
  11326. }
  11327. // SetPhoto sets the "photo" field.
  11328. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  11329. m.photo = &s
  11330. }
  11331. // Photo returns the value of the "photo" field in the mutation.
  11332. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  11333. v := m.photo
  11334. if v == nil {
  11335. return
  11336. }
  11337. return *v, true
  11338. }
  11339. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  11340. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11342. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  11343. if !m.op.Is(OpUpdateOne) {
  11344. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  11345. }
  11346. if m.id == nil || m.oldValue == nil {
  11347. return v, errors.New("OldPhoto requires an ID field in the mutation")
  11348. }
  11349. oldValue, err := m.oldValue(ctx)
  11350. if err != nil {
  11351. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  11352. }
  11353. return oldValue.Photo, nil
  11354. }
  11355. // ResetPhoto resets all changes to the "photo" field.
  11356. func (m *EmployeeConfigMutation) ResetPhoto() {
  11357. m.photo = nil
  11358. }
  11359. // SetOrganizationID sets the "organization_id" field.
  11360. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  11361. m.organization_id = &u
  11362. m.addorganization_id = nil
  11363. }
  11364. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11365. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  11366. v := m.organization_id
  11367. if v == nil {
  11368. return
  11369. }
  11370. return *v, true
  11371. }
  11372. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  11373. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  11374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11375. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11376. if !m.op.Is(OpUpdateOne) {
  11377. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11378. }
  11379. if m.id == nil || m.oldValue == nil {
  11380. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11381. }
  11382. oldValue, err := m.oldValue(ctx)
  11383. if err != nil {
  11384. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11385. }
  11386. return oldValue.OrganizationID, nil
  11387. }
  11388. // AddOrganizationID adds u to the "organization_id" field.
  11389. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  11390. if m.addorganization_id != nil {
  11391. *m.addorganization_id += u
  11392. } else {
  11393. m.addorganization_id = &u
  11394. }
  11395. }
  11396. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11397. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  11398. v := m.addorganization_id
  11399. if v == nil {
  11400. return
  11401. }
  11402. return *v, true
  11403. }
  11404. // ClearOrganizationID clears the value of the "organization_id" field.
  11405. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  11406. m.organization_id = nil
  11407. m.addorganization_id = nil
  11408. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  11409. }
  11410. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11411. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  11412. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  11413. return ok
  11414. }
  11415. // ResetOrganizationID resets all changes to the "organization_id" field.
  11416. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  11417. m.organization_id = nil
  11418. m.addorganization_id = nil
  11419. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  11420. }
  11421. // Where appends a list predicates to the EmployeeConfigMutation builder.
  11422. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  11423. m.predicates = append(m.predicates, ps...)
  11424. }
  11425. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  11426. // users can use type-assertion to append predicates that do not depend on any generated package.
  11427. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  11428. p := make([]predicate.EmployeeConfig, len(ps))
  11429. for i := range ps {
  11430. p[i] = ps[i]
  11431. }
  11432. m.Where(p...)
  11433. }
  11434. // Op returns the operation name.
  11435. func (m *EmployeeConfigMutation) Op() Op {
  11436. return m.op
  11437. }
  11438. // SetOp allows setting the mutation operation.
  11439. func (m *EmployeeConfigMutation) SetOp(op Op) {
  11440. m.op = op
  11441. }
  11442. // Type returns the node type of this mutation (EmployeeConfig).
  11443. func (m *EmployeeConfigMutation) Type() string {
  11444. return m.typ
  11445. }
  11446. // Fields returns all fields that were changed during this mutation. Note that in
  11447. // order to get all numeric fields that were incremented/decremented, call
  11448. // AddedFields().
  11449. func (m *EmployeeConfigMutation) Fields() []string {
  11450. fields := make([]string, 0, 7)
  11451. if m.created_at != nil {
  11452. fields = append(fields, employeeconfig.FieldCreatedAt)
  11453. }
  11454. if m.updated_at != nil {
  11455. fields = append(fields, employeeconfig.FieldUpdatedAt)
  11456. }
  11457. if m.deleted_at != nil {
  11458. fields = append(fields, employeeconfig.FieldDeletedAt)
  11459. }
  11460. if m.stype != nil {
  11461. fields = append(fields, employeeconfig.FieldStype)
  11462. }
  11463. if m.title != nil {
  11464. fields = append(fields, employeeconfig.FieldTitle)
  11465. }
  11466. if m.photo != nil {
  11467. fields = append(fields, employeeconfig.FieldPhoto)
  11468. }
  11469. if m.organization_id != nil {
  11470. fields = append(fields, employeeconfig.FieldOrganizationID)
  11471. }
  11472. return fields
  11473. }
  11474. // Field returns the value of a field with the given name. The second boolean
  11475. // return value indicates that this field was not set, or was not defined in the
  11476. // schema.
  11477. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  11478. switch name {
  11479. case employeeconfig.FieldCreatedAt:
  11480. return m.CreatedAt()
  11481. case employeeconfig.FieldUpdatedAt:
  11482. return m.UpdatedAt()
  11483. case employeeconfig.FieldDeletedAt:
  11484. return m.DeletedAt()
  11485. case employeeconfig.FieldStype:
  11486. return m.Stype()
  11487. case employeeconfig.FieldTitle:
  11488. return m.Title()
  11489. case employeeconfig.FieldPhoto:
  11490. return m.Photo()
  11491. case employeeconfig.FieldOrganizationID:
  11492. return m.OrganizationID()
  11493. }
  11494. return nil, false
  11495. }
  11496. // OldField returns the old value of the field from the database. An error is
  11497. // returned if the mutation operation is not UpdateOne, or the query to the
  11498. // database failed.
  11499. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11500. switch name {
  11501. case employeeconfig.FieldCreatedAt:
  11502. return m.OldCreatedAt(ctx)
  11503. case employeeconfig.FieldUpdatedAt:
  11504. return m.OldUpdatedAt(ctx)
  11505. case employeeconfig.FieldDeletedAt:
  11506. return m.OldDeletedAt(ctx)
  11507. case employeeconfig.FieldStype:
  11508. return m.OldStype(ctx)
  11509. case employeeconfig.FieldTitle:
  11510. return m.OldTitle(ctx)
  11511. case employeeconfig.FieldPhoto:
  11512. return m.OldPhoto(ctx)
  11513. case employeeconfig.FieldOrganizationID:
  11514. return m.OldOrganizationID(ctx)
  11515. }
  11516. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  11517. }
  11518. // SetField sets the value of a field with the given name. It returns an error if
  11519. // the field is not defined in the schema, or if the type mismatched the field
  11520. // type.
  11521. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  11522. switch name {
  11523. case employeeconfig.FieldCreatedAt:
  11524. v, ok := value.(time.Time)
  11525. if !ok {
  11526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11527. }
  11528. m.SetCreatedAt(v)
  11529. return nil
  11530. case employeeconfig.FieldUpdatedAt:
  11531. v, ok := value.(time.Time)
  11532. if !ok {
  11533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11534. }
  11535. m.SetUpdatedAt(v)
  11536. return nil
  11537. case employeeconfig.FieldDeletedAt:
  11538. v, ok := value.(time.Time)
  11539. if !ok {
  11540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11541. }
  11542. m.SetDeletedAt(v)
  11543. return nil
  11544. case employeeconfig.FieldStype:
  11545. v, ok := value.(string)
  11546. if !ok {
  11547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11548. }
  11549. m.SetStype(v)
  11550. return nil
  11551. case employeeconfig.FieldTitle:
  11552. v, ok := value.(string)
  11553. if !ok {
  11554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11555. }
  11556. m.SetTitle(v)
  11557. return nil
  11558. case employeeconfig.FieldPhoto:
  11559. v, ok := value.(string)
  11560. if !ok {
  11561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11562. }
  11563. m.SetPhoto(v)
  11564. return nil
  11565. case employeeconfig.FieldOrganizationID:
  11566. v, ok := value.(uint64)
  11567. if !ok {
  11568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11569. }
  11570. m.SetOrganizationID(v)
  11571. return nil
  11572. }
  11573. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  11574. }
  11575. // AddedFields returns all numeric fields that were incremented/decremented during
  11576. // this mutation.
  11577. func (m *EmployeeConfigMutation) AddedFields() []string {
  11578. var fields []string
  11579. if m.addorganization_id != nil {
  11580. fields = append(fields, employeeconfig.FieldOrganizationID)
  11581. }
  11582. return fields
  11583. }
  11584. // AddedField returns the numeric value that was incremented/decremented on a field
  11585. // with the given name. The second boolean return value indicates that this field
  11586. // was not set, or was not defined in the schema.
  11587. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  11588. switch name {
  11589. case employeeconfig.FieldOrganizationID:
  11590. return m.AddedOrganizationID()
  11591. }
  11592. return nil, false
  11593. }
  11594. // AddField adds the value to the field with the given name. It returns an error if
  11595. // the field is not defined in the schema, or if the type mismatched the field
  11596. // type.
  11597. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  11598. switch name {
  11599. case employeeconfig.FieldOrganizationID:
  11600. v, ok := value.(int64)
  11601. if !ok {
  11602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11603. }
  11604. m.AddOrganizationID(v)
  11605. return nil
  11606. }
  11607. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  11608. }
  11609. // ClearedFields returns all nullable fields that were cleared during this
  11610. // mutation.
  11611. func (m *EmployeeConfigMutation) ClearedFields() []string {
  11612. var fields []string
  11613. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  11614. fields = append(fields, employeeconfig.FieldDeletedAt)
  11615. }
  11616. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  11617. fields = append(fields, employeeconfig.FieldOrganizationID)
  11618. }
  11619. return fields
  11620. }
  11621. // FieldCleared returns a boolean indicating if a field with the given name was
  11622. // cleared in this mutation.
  11623. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  11624. _, ok := m.clearedFields[name]
  11625. return ok
  11626. }
  11627. // ClearField clears the value of the field with the given name. It returns an
  11628. // error if the field is not defined in the schema.
  11629. func (m *EmployeeConfigMutation) ClearField(name string) error {
  11630. switch name {
  11631. case employeeconfig.FieldDeletedAt:
  11632. m.ClearDeletedAt()
  11633. return nil
  11634. case employeeconfig.FieldOrganizationID:
  11635. m.ClearOrganizationID()
  11636. return nil
  11637. }
  11638. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  11639. }
  11640. // ResetField resets all changes in the mutation for the field with the given name.
  11641. // It returns an error if the field is not defined in the schema.
  11642. func (m *EmployeeConfigMutation) ResetField(name string) error {
  11643. switch name {
  11644. case employeeconfig.FieldCreatedAt:
  11645. m.ResetCreatedAt()
  11646. return nil
  11647. case employeeconfig.FieldUpdatedAt:
  11648. m.ResetUpdatedAt()
  11649. return nil
  11650. case employeeconfig.FieldDeletedAt:
  11651. m.ResetDeletedAt()
  11652. return nil
  11653. case employeeconfig.FieldStype:
  11654. m.ResetStype()
  11655. return nil
  11656. case employeeconfig.FieldTitle:
  11657. m.ResetTitle()
  11658. return nil
  11659. case employeeconfig.FieldPhoto:
  11660. m.ResetPhoto()
  11661. return nil
  11662. case employeeconfig.FieldOrganizationID:
  11663. m.ResetOrganizationID()
  11664. return nil
  11665. }
  11666. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  11667. }
  11668. // AddedEdges returns all edge names that were set/added in this mutation.
  11669. func (m *EmployeeConfigMutation) AddedEdges() []string {
  11670. edges := make([]string, 0, 0)
  11671. return edges
  11672. }
  11673. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11674. // name in this mutation.
  11675. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  11676. return nil
  11677. }
  11678. // RemovedEdges returns all edge names that were removed in this mutation.
  11679. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  11680. edges := make([]string, 0, 0)
  11681. return edges
  11682. }
  11683. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11684. // the given name in this mutation.
  11685. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  11686. return nil
  11687. }
  11688. // ClearedEdges returns all edge names that were cleared in this mutation.
  11689. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  11690. edges := make([]string, 0, 0)
  11691. return edges
  11692. }
  11693. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11694. // was cleared in this mutation.
  11695. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  11696. return false
  11697. }
  11698. // ClearEdge clears the value of the edge with the given name. It returns an error
  11699. // if that edge is not defined in the schema.
  11700. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  11701. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  11702. }
  11703. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11704. // It returns an error if the edge is not defined in the schema.
  11705. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  11706. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  11707. }
  11708. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  11709. type LabelMutation struct {
  11710. config
  11711. op Op
  11712. typ string
  11713. id *uint64
  11714. created_at *time.Time
  11715. updated_at *time.Time
  11716. status *uint8
  11717. addstatus *int8
  11718. _type *int
  11719. add_type *int
  11720. name *string
  11721. from *int
  11722. addfrom *int
  11723. mode *int
  11724. addmode *int
  11725. conditions *string
  11726. organization_id *uint64
  11727. addorganization_id *int64
  11728. clearedFields map[string]struct{}
  11729. label_relationships map[uint64]struct{}
  11730. removedlabel_relationships map[uint64]struct{}
  11731. clearedlabel_relationships bool
  11732. done bool
  11733. oldValue func(context.Context) (*Label, error)
  11734. predicates []predicate.Label
  11735. }
  11736. var _ ent.Mutation = (*LabelMutation)(nil)
  11737. // labelOption allows management of the mutation configuration using functional options.
  11738. type labelOption func(*LabelMutation)
  11739. // newLabelMutation creates new mutation for the Label entity.
  11740. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  11741. m := &LabelMutation{
  11742. config: c,
  11743. op: op,
  11744. typ: TypeLabel,
  11745. clearedFields: make(map[string]struct{}),
  11746. }
  11747. for _, opt := range opts {
  11748. opt(m)
  11749. }
  11750. return m
  11751. }
  11752. // withLabelID sets the ID field of the mutation.
  11753. func withLabelID(id uint64) labelOption {
  11754. return func(m *LabelMutation) {
  11755. var (
  11756. err error
  11757. once sync.Once
  11758. value *Label
  11759. )
  11760. m.oldValue = func(ctx context.Context) (*Label, error) {
  11761. once.Do(func() {
  11762. if m.done {
  11763. err = errors.New("querying old values post mutation is not allowed")
  11764. } else {
  11765. value, err = m.Client().Label.Get(ctx, id)
  11766. }
  11767. })
  11768. return value, err
  11769. }
  11770. m.id = &id
  11771. }
  11772. }
  11773. // withLabel sets the old Label of the mutation.
  11774. func withLabel(node *Label) labelOption {
  11775. return func(m *LabelMutation) {
  11776. m.oldValue = func(context.Context) (*Label, error) {
  11777. return node, nil
  11778. }
  11779. m.id = &node.ID
  11780. }
  11781. }
  11782. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11783. // executed in a transaction (ent.Tx), a transactional client is returned.
  11784. func (m LabelMutation) Client() *Client {
  11785. client := &Client{config: m.config}
  11786. client.init()
  11787. return client
  11788. }
  11789. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11790. // it returns an error otherwise.
  11791. func (m LabelMutation) Tx() (*Tx, error) {
  11792. if _, ok := m.driver.(*txDriver); !ok {
  11793. return nil, errors.New("ent: mutation is not running in a transaction")
  11794. }
  11795. tx := &Tx{config: m.config}
  11796. tx.init()
  11797. return tx, nil
  11798. }
  11799. // SetID sets the value of the id field. Note that this
  11800. // operation is only accepted on creation of Label entities.
  11801. func (m *LabelMutation) SetID(id uint64) {
  11802. m.id = &id
  11803. }
  11804. // ID returns the ID value in the mutation. Note that the ID is only available
  11805. // if it was provided to the builder or after it was returned from the database.
  11806. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11807. if m.id == nil {
  11808. return
  11809. }
  11810. return *m.id, true
  11811. }
  11812. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11813. // That means, if the mutation is applied within a transaction with an isolation level such
  11814. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11815. // or updated by the mutation.
  11816. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11817. switch {
  11818. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11819. id, exists := m.ID()
  11820. if exists {
  11821. return []uint64{id}, nil
  11822. }
  11823. fallthrough
  11824. case m.op.Is(OpUpdate | OpDelete):
  11825. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11826. default:
  11827. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11828. }
  11829. }
  11830. // SetCreatedAt sets the "created_at" field.
  11831. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11832. m.created_at = &t
  11833. }
  11834. // CreatedAt returns the value of the "created_at" field in the mutation.
  11835. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11836. v := m.created_at
  11837. if v == nil {
  11838. return
  11839. }
  11840. return *v, true
  11841. }
  11842. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11843. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11845. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11846. if !m.op.Is(OpUpdateOne) {
  11847. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11848. }
  11849. if m.id == nil || m.oldValue == nil {
  11850. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11851. }
  11852. oldValue, err := m.oldValue(ctx)
  11853. if err != nil {
  11854. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11855. }
  11856. return oldValue.CreatedAt, nil
  11857. }
  11858. // ResetCreatedAt resets all changes to the "created_at" field.
  11859. func (m *LabelMutation) ResetCreatedAt() {
  11860. m.created_at = nil
  11861. }
  11862. // SetUpdatedAt sets the "updated_at" field.
  11863. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11864. m.updated_at = &t
  11865. }
  11866. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11867. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11868. v := m.updated_at
  11869. if v == nil {
  11870. return
  11871. }
  11872. return *v, true
  11873. }
  11874. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11875. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11877. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11878. if !m.op.Is(OpUpdateOne) {
  11879. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11880. }
  11881. if m.id == nil || m.oldValue == nil {
  11882. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11883. }
  11884. oldValue, err := m.oldValue(ctx)
  11885. if err != nil {
  11886. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11887. }
  11888. return oldValue.UpdatedAt, nil
  11889. }
  11890. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11891. func (m *LabelMutation) ResetUpdatedAt() {
  11892. m.updated_at = nil
  11893. }
  11894. // SetStatus sets the "status" field.
  11895. func (m *LabelMutation) SetStatus(u uint8) {
  11896. m.status = &u
  11897. m.addstatus = nil
  11898. }
  11899. // Status returns the value of the "status" field in the mutation.
  11900. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11901. v := m.status
  11902. if v == nil {
  11903. return
  11904. }
  11905. return *v, true
  11906. }
  11907. // OldStatus returns the old "status" field's value of the Label entity.
  11908. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11910. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11911. if !m.op.Is(OpUpdateOne) {
  11912. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11913. }
  11914. if m.id == nil || m.oldValue == nil {
  11915. return v, errors.New("OldStatus requires an ID field in the mutation")
  11916. }
  11917. oldValue, err := m.oldValue(ctx)
  11918. if err != nil {
  11919. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11920. }
  11921. return oldValue.Status, nil
  11922. }
  11923. // AddStatus adds u to the "status" field.
  11924. func (m *LabelMutation) AddStatus(u int8) {
  11925. if m.addstatus != nil {
  11926. *m.addstatus += u
  11927. } else {
  11928. m.addstatus = &u
  11929. }
  11930. }
  11931. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11932. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11933. v := m.addstatus
  11934. if v == nil {
  11935. return
  11936. }
  11937. return *v, true
  11938. }
  11939. // ClearStatus clears the value of the "status" field.
  11940. func (m *LabelMutation) ClearStatus() {
  11941. m.status = nil
  11942. m.addstatus = nil
  11943. m.clearedFields[label.FieldStatus] = struct{}{}
  11944. }
  11945. // StatusCleared returns if the "status" field was cleared in this mutation.
  11946. func (m *LabelMutation) StatusCleared() bool {
  11947. _, ok := m.clearedFields[label.FieldStatus]
  11948. return ok
  11949. }
  11950. // ResetStatus resets all changes to the "status" field.
  11951. func (m *LabelMutation) ResetStatus() {
  11952. m.status = nil
  11953. m.addstatus = nil
  11954. delete(m.clearedFields, label.FieldStatus)
  11955. }
  11956. // SetType sets the "type" field.
  11957. func (m *LabelMutation) SetType(i int) {
  11958. m._type = &i
  11959. m.add_type = nil
  11960. }
  11961. // GetType returns the value of the "type" field in the mutation.
  11962. func (m *LabelMutation) GetType() (r int, exists bool) {
  11963. v := m._type
  11964. if v == nil {
  11965. return
  11966. }
  11967. return *v, true
  11968. }
  11969. // OldType returns the old "type" field's value of the Label entity.
  11970. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11972. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11973. if !m.op.Is(OpUpdateOne) {
  11974. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11975. }
  11976. if m.id == nil || m.oldValue == nil {
  11977. return v, errors.New("OldType requires an ID field in the mutation")
  11978. }
  11979. oldValue, err := m.oldValue(ctx)
  11980. if err != nil {
  11981. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11982. }
  11983. return oldValue.Type, nil
  11984. }
  11985. // AddType adds i to the "type" field.
  11986. func (m *LabelMutation) AddType(i int) {
  11987. if m.add_type != nil {
  11988. *m.add_type += i
  11989. } else {
  11990. m.add_type = &i
  11991. }
  11992. }
  11993. // AddedType returns the value that was added to the "type" field in this mutation.
  11994. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11995. v := m.add_type
  11996. if v == nil {
  11997. return
  11998. }
  11999. return *v, true
  12000. }
  12001. // ResetType resets all changes to the "type" field.
  12002. func (m *LabelMutation) ResetType() {
  12003. m._type = nil
  12004. m.add_type = nil
  12005. }
  12006. // SetName sets the "name" field.
  12007. func (m *LabelMutation) SetName(s string) {
  12008. m.name = &s
  12009. }
  12010. // Name returns the value of the "name" field in the mutation.
  12011. func (m *LabelMutation) Name() (r string, exists bool) {
  12012. v := m.name
  12013. if v == nil {
  12014. return
  12015. }
  12016. return *v, true
  12017. }
  12018. // OldName returns the old "name" field's value of the Label entity.
  12019. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12021. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  12022. if !m.op.Is(OpUpdateOne) {
  12023. return v, errors.New("OldName is only allowed on UpdateOne operations")
  12024. }
  12025. if m.id == nil || m.oldValue == nil {
  12026. return v, errors.New("OldName requires an ID field in the mutation")
  12027. }
  12028. oldValue, err := m.oldValue(ctx)
  12029. if err != nil {
  12030. return v, fmt.Errorf("querying old value for OldName: %w", err)
  12031. }
  12032. return oldValue.Name, nil
  12033. }
  12034. // ResetName resets all changes to the "name" field.
  12035. func (m *LabelMutation) ResetName() {
  12036. m.name = nil
  12037. }
  12038. // SetFrom sets the "from" field.
  12039. func (m *LabelMutation) SetFrom(i int) {
  12040. m.from = &i
  12041. m.addfrom = nil
  12042. }
  12043. // From returns the value of the "from" field in the mutation.
  12044. func (m *LabelMutation) From() (r int, exists bool) {
  12045. v := m.from
  12046. if v == nil {
  12047. return
  12048. }
  12049. return *v, true
  12050. }
  12051. // OldFrom returns the old "from" field's value of the Label entity.
  12052. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12054. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  12055. if !m.op.Is(OpUpdateOne) {
  12056. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  12057. }
  12058. if m.id == nil || m.oldValue == nil {
  12059. return v, errors.New("OldFrom requires an ID field in the mutation")
  12060. }
  12061. oldValue, err := m.oldValue(ctx)
  12062. if err != nil {
  12063. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  12064. }
  12065. return oldValue.From, nil
  12066. }
  12067. // AddFrom adds i to the "from" field.
  12068. func (m *LabelMutation) AddFrom(i int) {
  12069. if m.addfrom != nil {
  12070. *m.addfrom += i
  12071. } else {
  12072. m.addfrom = &i
  12073. }
  12074. }
  12075. // AddedFrom returns the value that was added to the "from" field in this mutation.
  12076. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  12077. v := m.addfrom
  12078. if v == nil {
  12079. return
  12080. }
  12081. return *v, true
  12082. }
  12083. // ResetFrom resets all changes to the "from" field.
  12084. func (m *LabelMutation) ResetFrom() {
  12085. m.from = nil
  12086. m.addfrom = nil
  12087. }
  12088. // SetMode sets the "mode" field.
  12089. func (m *LabelMutation) SetMode(i int) {
  12090. m.mode = &i
  12091. m.addmode = nil
  12092. }
  12093. // Mode returns the value of the "mode" field in the mutation.
  12094. func (m *LabelMutation) Mode() (r int, exists bool) {
  12095. v := m.mode
  12096. if v == nil {
  12097. return
  12098. }
  12099. return *v, true
  12100. }
  12101. // OldMode returns the old "mode" field's value of the Label entity.
  12102. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12104. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  12105. if !m.op.Is(OpUpdateOne) {
  12106. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  12107. }
  12108. if m.id == nil || m.oldValue == nil {
  12109. return v, errors.New("OldMode requires an ID field in the mutation")
  12110. }
  12111. oldValue, err := m.oldValue(ctx)
  12112. if err != nil {
  12113. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  12114. }
  12115. return oldValue.Mode, nil
  12116. }
  12117. // AddMode adds i to the "mode" field.
  12118. func (m *LabelMutation) AddMode(i int) {
  12119. if m.addmode != nil {
  12120. *m.addmode += i
  12121. } else {
  12122. m.addmode = &i
  12123. }
  12124. }
  12125. // AddedMode returns the value that was added to the "mode" field in this mutation.
  12126. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  12127. v := m.addmode
  12128. if v == nil {
  12129. return
  12130. }
  12131. return *v, true
  12132. }
  12133. // ResetMode resets all changes to the "mode" field.
  12134. func (m *LabelMutation) ResetMode() {
  12135. m.mode = nil
  12136. m.addmode = nil
  12137. }
  12138. // SetConditions sets the "conditions" field.
  12139. func (m *LabelMutation) SetConditions(s string) {
  12140. m.conditions = &s
  12141. }
  12142. // Conditions returns the value of the "conditions" field in the mutation.
  12143. func (m *LabelMutation) Conditions() (r string, exists bool) {
  12144. v := m.conditions
  12145. if v == nil {
  12146. return
  12147. }
  12148. return *v, true
  12149. }
  12150. // OldConditions returns the old "conditions" field's value of the Label entity.
  12151. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12153. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  12154. if !m.op.Is(OpUpdateOne) {
  12155. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  12156. }
  12157. if m.id == nil || m.oldValue == nil {
  12158. return v, errors.New("OldConditions requires an ID field in the mutation")
  12159. }
  12160. oldValue, err := m.oldValue(ctx)
  12161. if err != nil {
  12162. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  12163. }
  12164. return oldValue.Conditions, nil
  12165. }
  12166. // ClearConditions clears the value of the "conditions" field.
  12167. func (m *LabelMutation) ClearConditions() {
  12168. m.conditions = nil
  12169. m.clearedFields[label.FieldConditions] = struct{}{}
  12170. }
  12171. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  12172. func (m *LabelMutation) ConditionsCleared() bool {
  12173. _, ok := m.clearedFields[label.FieldConditions]
  12174. return ok
  12175. }
  12176. // ResetConditions resets all changes to the "conditions" field.
  12177. func (m *LabelMutation) ResetConditions() {
  12178. m.conditions = nil
  12179. delete(m.clearedFields, label.FieldConditions)
  12180. }
  12181. // SetOrganizationID sets the "organization_id" field.
  12182. func (m *LabelMutation) SetOrganizationID(u uint64) {
  12183. m.organization_id = &u
  12184. m.addorganization_id = nil
  12185. }
  12186. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12187. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  12188. v := m.organization_id
  12189. if v == nil {
  12190. return
  12191. }
  12192. return *v, true
  12193. }
  12194. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  12195. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  12196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12197. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12198. if !m.op.Is(OpUpdateOne) {
  12199. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12200. }
  12201. if m.id == nil || m.oldValue == nil {
  12202. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12203. }
  12204. oldValue, err := m.oldValue(ctx)
  12205. if err != nil {
  12206. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12207. }
  12208. return oldValue.OrganizationID, nil
  12209. }
  12210. // AddOrganizationID adds u to the "organization_id" field.
  12211. func (m *LabelMutation) AddOrganizationID(u int64) {
  12212. if m.addorganization_id != nil {
  12213. *m.addorganization_id += u
  12214. } else {
  12215. m.addorganization_id = &u
  12216. }
  12217. }
  12218. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12219. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  12220. v := m.addorganization_id
  12221. if v == nil {
  12222. return
  12223. }
  12224. return *v, true
  12225. }
  12226. // ClearOrganizationID clears the value of the "organization_id" field.
  12227. func (m *LabelMutation) ClearOrganizationID() {
  12228. m.organization_id = nil
  12229. m.addorganization_id = nil
  12230. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  12231. }
  12232. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12233. func (m *LabelMutation) OrganizationIDCleared() bool {
  12234. _, ok := m.clearedFields[label.FieldOrganizationID]
  12235. return ok
  12236. }
  12237. // ResetOrganizationID resets all changes to the "organization_id" field.
  12238. func (m *LabelMutation) ResetOrganizationID() {
  12239. m.organization_id = nil
  12240. m.addorganization_id = nil
  12241. delete(m.clearedFields, label.FieldOrganizationID)
  12242. }
  12243. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  12244. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  12245. if m.label_relationships == nil {
  12246. m.label_relationships = make(map[uint64]struct{})
  12247. }
  12248. for i := range ids {
  12249. m.label_relationships[ids[i]] = struct{}{}
  12250. }
  12251. }
  12252. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  12253. func (m *LabelMutation) ClearLabelRelationships() {
  12254. m.clearedlabel_relationships = true
  12255. }
  12256. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  12257. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  12258. return m.clearedlabel_relationships
  12259. }
  12260. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  12261. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  12262. if m.removedlabel_relationships == nil {
  12263. m.removedlabel_relationships = make(map[uint64]struct{})
  12264. }
  12265. for i := range ids {
  12266. delete(m.label_relationships, ids[i])
  12267. m.removedlabel_relationships[ids[i]] = struct{}{}
  12268. }
  12269. }
  12270. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  12271. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  12272. for id := range m.removedlabel_relationships {
  12273. ids = append(ids, id)
  12274. }
  12275. return
  12276. }
  12277. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  12278. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  12279. for id := range m.label_relationships {
  12280. ids = append(ids, id)
  12281. }
  12282. return
  12283. }
  12284. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  12285. func (m *LabelMutation) ResetLabelRelationships() {
  12286. m.label_relationships = nil
  12287. m.clearedlabel_relationships = false
  12288. m.removedlabel_relationships = nil
  12289. }
  12290. // Where appends a list predicates to the LabelMutation builder.
  12291. func (m *LabelMutation) Where(ps ...predicate.Label) {
  12292. m.predicates = append(m.predicates, ps...)
  12293. }
  12294. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  12295. // users can use type-assertion to append predicates that do not depend on any generated package.
  12296. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  12297. p := make([]predicate.Label, len(ps))
  12298. for i := range ps {
  12299. p[i] = ps[i]
  12300. }
  12301. m.Where(p...)
  12302. }
  12303. // Op returns the operation name.
  12304. func (m *LabelMutation) Op() Op {
  12305. return m.op
  12306. }
  12307. // SetOp allows setting the mutation operation.
  12308. func (m *LabelMutation) SetOp(op Op) {
  12309. m.op = op
  12310. }
  12311. // Type returns the node type of this mutation (Label).
  12312. func (m *LabelMutation) Type() string {
  12313. return m.typ
  12314. }
  12315. // Fields returns all fields that were changed during this mutation. Note that in
  12316. // order to get all numeric fields that were incremented/decremented, call
  12317. // AddedFields().
  12318. func (m *LabelMutation) Fields() []string {
  12319. fields := make([]string, 0, 9)
  12320. if m.created_at != nil {
  12321. fields = append(fields, label.FieldCreatedAt)
  12322. }
  12323. if m.updated_at != nil {
  12324. fields = append(fields, label.FieldUpdatedAt)
  12325. }
  12326. if m.status != nil {
  12327. fields = append(fields, label.FieldStatus)
  12328. }
  12329. if m._type != nil {
  12330. fields = append(fields, label.FieldType)
  12331. }
  12332. if m.name != nil {
  12333. fields = append(fields, label.FieldName)
  12334. }
  12335. if m.from != nil {
  12336. fields = append(fields, label.FieldFrom)
  12337. }
  12338. if m.mode != nil {
  12339. fields = append(fields, label.FieldMode)
  12340. }
  12341. if m.conditions != nil {
  12342. fields = append(fields, label.FieldConditions)
  12343. }
  12344. if m.organization_id != nil {
  12345. fields = append(fields, label.FieldOrganizationID)
  12346. }
  12347. return fields
  12348. }
  12349. // Field returns the value of a field with the given name. The second boolean
  12350. // return value indicates that this field was not set, or was not defined in the
  12351. // schema.
  12352. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  12353. switch name {
  12354. case label.FieldCreatedAt:
  12355. return m.CreatedAt()
  12356. case label.FieldUpdatedAt:
  12357. return m.UpdatedAt()
  12358. case label.FieldStatus:
  12359. return m.Status()
  12360. case label.FieldType:
  12361. return m.GetType()
  12362. case label.FieldName:
  12363. return m.Name()
  12364. case label.FieldFrom:
  12365. return m.From()
  12366. case label.FieldMode:
  12367. return m.Mode()
  12368. case label.FieldConditions:
  12369. return m.Conditions()
  12370. case label.FieldOrganizationID:
  12371. return m.OrganizationID()
  12372. }
  12373. return nil, false
  12374. }
  12375. // OldField returns the old value of the field from the database. An error is
  12376. // returned if the mutation operation is not UpdateOne, or the query to the
  12377. // database failed.
  12378. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12379. switch name {
  12380. case label.FieldCreatedAt:
  12381. return m.OldCreatedAt(ctx)
  12382. case label.FieldUpdatedAt:
  12383. return m.OldUpdatedAt(ctx)
  12384. case label.FieldStatus:
  12385. return m.OldStatus(ctx)
  12386. case label.FieldType:
  12387. return m.OldType(ctx)
  12388. case label.FieldName:
  12389. return m.OldName(ctx)
  12390. case label.FieldFrom:
  12391. return m.OldFrom(ctx)
  12392. case label.FieldMode:
  12393. return m.OldMode(ctx)
  12394. case label.FieldConditions:
  12395. return m.OldConditions(ctx)
  12396. case label.FieldOrganizationID:
  12397. return m.OldOrganizationID(ctx)
  12398. }
  12399. return nil, fmt.Errorf("unknown Label field %s", name)
  12400. }
  12401. // SetField sets the value of a field with the given name. It returns an error if
  12402. // the field is not defined in the schema, or if the type mismatched the field
  12403. // type.
  12404. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  12405. switch name {
  12406. case label.FieldCreatedAt:
  12407. v, ok := value.(time.Time)
  12408. if !ok {
  12409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12410. }
  12411. m.SetCreatedAt(v)
  12412. return nil
  12413. case label.FieldUpdatedAt:
  12414. v, ok := value.(time.Time)
  12415. if !ok {
  12416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12417. }
  12418. m.SetUpdatedAt(v)
  12419. return nil
  12420. case label.FieldStatus:
  12421. v, ok := value.(uint8)
  12422. if !ok {
  12423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12424. }
  12425. m.SetStatus(v)
  12426. return nil
  12427. case label.FieldType:
  12428. v, ok := value.(int)
  12429. if !ok {
  12430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12431. }
  12432. m.SetType(v)
  12433. return nil
  12434. case label.FieldName:
  12435. v, ok := value.(string)
  12436. if !ok {
  12437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12438. }
  12439. m.SetName(v)
  12440. return nil
  12441. case label.FieldFrom:
  12442. v, ok := value.(int)
  12443. if !ok {
  12444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12445. }
  12446. m.SetFrom(v)
  12447. return nil
  12448. case label.FieldMode:
  12449. v, ok := value.(int)
  12450. if !ok {
  12451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12452. }
  12453. m.SetMode(v)
  12454. return nil
  12455. case label.FieldConditions:
  12456. v, ok := value.(string)
  12457. if !ok {
  12458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12459. }
  12460. m.SetConditions(v)
  12461. return nil
  12462. case label.FieldOrganizationID:
  12463. v, ok := value.(uint64)
  12464. if !ok {
  12465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12466. }
  12467. m.SetOrganizationID(v)
  12468. return nil
  12469. }
  12470. return fmt.Errorf("unknown Label field %s", name)
  12471. }
  12472. // AddedFields returns all numeric fields that were incremented/decremented during
  12473. // this mutation.
  12474. func (m *LabelMutation) AddedFields() []string {
  12475. var fields []string
  12476. if m.addstatus != nil {
  12477. fields = append(fields, label.FieldStatus)
  12478. }
  12479. if m.add_type != nil {
  12480. fields = append(fields, label.FieldType)
  12481. }
  12482. if m.addfrom != nil {
  12483. fields = append(fields, label.FieldFrom)
  12484. }
  12485. if m.addmode != nil {
  12486. fields = append(fields, label.FieldMode)
  12487. }
  12488. if m.addorganization_id != nil {
  12489. fields = append(fields, label.FieldOrganizationID)
  12490. }
  12491. return fields
  12492. }
  12493. // AddedField returns the numeric value that was incremented/decremented on a field
  12494. // with the given name. The second boolean return value indicates that this field
  12495. // was not set, or was not defined in the schema.
  12496. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  12497. switch name {
  12498. case label.FieldStatus:
  12499. return m.AddedStatus()
  12500. case label.FieldType:
  12501. return m.AddedType()
  12502. case label.FieldFrom:
  12503. return m.AddedFrom()
  12504. case label.FieldMode:
  12505. return m.AddedMode()
  12506. case label.FieldOrganizationID:
  12507. return m.AddedOrganizationID()
  12508. }
  12509. return nil, false
  12510. }
  12511. // AddField adds the value to the field with the given name. It returns an error if
  12512. // the field is not defined in the schema, or if the type mismatched the field
  12513. // type.
  12514. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  12515. switch name {
  12516. case label.FieldStatus:
  12517. v, ok := value.(int8)
  12518. if !ok {
  12519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12520. }
  12521. m.AddStatus(v)
  12522. return nil
  12523. case label.FieldType:
  12524. v, ok := value.(int)
  12525. if !ok {
  12526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12527. }
  12528. m.AddType(v)
  12529. return nil
  12530. case label.FieldFrom:
  12531. v, ok := value.(int)
  12532. if !ok {
  12533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12534. }
  12535. m.AddFrom(v)
  12536. return nil
  12537. case label.FieldMode:
  12538. v, ok := value.(int)
  12539. if !ok {
  12540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12541. }
  12542. m.AddMode(v)
  12543. return nil
  12544. case label.FieldOrganizationID:
  12545. v, ok := value.(int64)
  12546. if !ok {
  12547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12548. }
  12549. m.AddOrganizationID(v)
  12550. return nil
  12551. }
  12552. return fmt.Errorf("unknown Label numeric field %s", name)
  12553. }
  12554. // ClearedFields returns all nullable fields that were cleared during this
  12555. // mutation.
  12556. func (m *LabelMutation) ClearedFields() []string {
  12557. var fields []string
  12558. if m.FieldCleared(label.FieldStatus) {
  12559. fields = append(fields, label.FieldStatus)
  12560. }
  12561. if m.FieldCleared(label.FieldConditions) {
  12562. fields = append(fields, label.FieldConditions)
  12563. }
  12564. if m.FieldCleared(label.FieldOrganizationID) {
  12565. fields = append(fields, label.FieldOrganizationID)
  12566. }
  12567. return fields
  12568. }
  12569. // FieldCleared returns a boolean indicating if a field with the given name was
  12570. // cleared in this mutation.
  12571. func (m *LabelMutation) FieldCleared(name string) bool {
  12572. _, ok := m.clearedFields[name]
  12573. return ok
  12574. }
  12575. // ClearField clears the value of the field with the given name. It returns an
  12576. // error if the field is not defined in the schema.
  12577. func (m *LabelMutation) ClearField(name string) error {
  12578. switch name {
  12579. case label.FieldStatus:
  12580. m.ClearStatus()
  12581. return nil
  12582. case label.FieldConditions:
  12583. m.ClearConditions()
  12584. return nil
  12585. case label.FieldOrganizationID:
  12586. m.ClearOrganizationID()
  12587. return nil
  12588. }
  12589. return fmt.Errorf("unknown Label nullable field %s", name)
  12590. }
  12591. // ResetField resets all changes in the mutation for the field with the given name.
  12592. // It returns an error if the field is not defined in the schema.
  12593. func (m *LabelMutation) ResetField(name string) error {
  12594. switch name {
  12595. case label.FieldCreatedAt:
  12596. m.ResetCreatedAt()
  12597. return nil
  12598. case label.FieldUpdatedAt:
  12599. m.ResetUpdatedAt()
  12600. return nil
  12601. case label.FieldStatus:
  12602. m.ResetStatus()
  12603. return nil
  12604. case label.FieldType:
  12605. m.ResetType()
  12606. return nil
  12607. case label.FieldName:
  12608. m.ResetName()
  12609. return nil
  12610. case label.FieldFrom:
  12611. m.ResetFrom()
  12612. return nil
  12613. case label.FieldMode:
  12614. m.ResetMode()
  12615. return nil
  12616. case label.FieldConditions:
  12617. m.ResetConditions()
  12618. return nil
  12619. case label.FieldOrganizationID:
  12620. m.ResetOrganizationID()
  12621. return nil
  12622. }
  12623. return fmt.Errorf("unknown Label field %s", name)
  12624. }
  12625. // AddedEdges returns all edge names that were set/added in this mutation.
  12626. func (m *LabelMutation) AddedEdges() []string {
  12627. edges := make([]string, 0, 1)
  12628. if m.label_relationships != nil {
  12629. edges = append(edges, label.EdgeLabelRelationships)
  12630. }
  12631. return edges
  12632. }
  12633. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12634. // name in this mutation.
  12635. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  12636. switch name {
  12637. case label.EdgeLabelRelationships:
  12638. ids := make([]ent.Value, 0, len(m.label_relationships))
  12639. for id := range m.label_relationships {
  12640. ids = append(ids, id)
  12641. }
  12642. return ids
  12643. }
  12644. return nil
  12645. }
  12646. // RemovedEdges returns all edge names that were removed in this mutation.
  12647. func (m *LabelMutation) RemovedEdges() []string {
  12648. edges := make([]string, 0, 1)
  12649. if m.removedlabel_relationships != nil {
  12650. edges = append(edges, label.EdgeLabelRelationships)
  12651. }
  12652. return edges
  12653. }
  12654. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12655. // the given name in this mutation.
  12656. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  12657. switch name {
  12658. case label.EdgeLabelRelationships:
  12659. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  12660. for id := range m.removedlabel_relationships {
  12661. ids = append(ids, id)
  12662. }
  12663. return ids
  12664. }
  12665. return nil
  12666. }
  12667. // ClearedEdges returns all edge names that were cleared in this mutation.
  12668. func (m *LabelMutation) ClearedEdges() []string {
  12669. edges := make([]string, 0, 1)
  12670. if m.clearedlabel_relationships {
  12671. edges = append(edges, label.EdgeLabelRelationships)
  12672. }
  12673. return edges
  12674. }
  12675. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12676. // was cleared in this mutation.
  12677. func (m *LabelMutation) EdgeCleared(name string) bool {
  12678. switch name {
  12679. case label.EdgeLabelRelationships:
  12680. return m.clearedlabel_relationships
  12681. }
  12682. return false
  12683. }
  12684. // ClearEdge clears the value of the edge with the given name. It returns an error
  12685. // if that edge is not defined in the schema.
  12686. func (m *LabelMutation) ClearEdge(name string) error {
  12687. switch name {
  12688. }
  12689. return fmt.Errorf("unknown Label unique edge %s", name)
  12690. }
  12691. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12692. // It returns an error if the edge is not defined in the schema.
  12693. func (m *LabelMutation) ResetEdge(name string) error {
  12694. switch name {
  12695. case label.EdgeLabelRelationships:
  12696. m.ResetLabelRelationships()
  12697. return nil
  12698. }
  12699. return fmt.Errorf("unknown Label edge %s", name)
  12700. }
  12701. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  12702. type LabelRelationshipMutation struct {
  12703. config
  12704. op Op
  12705. typ string
  12706. id *uint64
  12707. created_at *time.Time
  12708. updated_at *time.Time
  12709. status *uint8
  12710. addstatus *int8
  12711. deleted_at *time.Time
  12712. organization_id *uint64
  12713. addorganization_id *int64
  12714. clearedFields map[string]struct{}
  12715. contacts *uint64
  12716. clearedcontacts bool
  12717. labels *uint64
  12718. clearedlabels bool
  12719. done bool
  12720. oldValue func(context.Context) (*LabelRelationship, error)
  12721. predicates []predicate.LabelRelationship
  12722. }
  12723. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  12724. // labelrelationshipOption allows management of the mutation configuration using functional options.
  12725. type labelrelationshipOption func(*LabelRelationshipMutation)
  12726. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  12727. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  12728. m := &LabelRelationshipMutation{
  12729. config: c,
  12730. op: op,
  12731. typ: TypeLabelRelationship,
  12732. clearedFields: make(map[string]struct{}),
  12733. }
  12734. for _, opt := range opts {
  12735. opt(m)
  12736. }
  12737. return m
  12738. }
  12739. // withLabelRelationshipID sets the ID field of the mutation.
  12740. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  12741. return func(m *LabelRelationshipMutation) {
  12742. var (
  12743. err error
  12744. once sync.Once
  12745. value *LabelRelationship
  12746. )
  12747. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  12748. once.Do(func() {
  12749. if m.done {
  12750. err = errors.New("querying old values post mutation is not allowed")
  12751. } else {
  12752. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12753. }
  12754. })
  12755. return value, err
  12756. }
  12757. m.id = &id
  12758. }
  12759. }
  12760. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12761. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12762. return func(m *LabelRelationshipMutation) {
  12763. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12764. return node, nil
  12765. }
  12766. m.id = &node.ID
  12767. }
  12768. }
  12769. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12770. // executed in a transaction (ent.Tx), a transactional client is returned.
  12771. func (m LabelRelationshipMutation) Client() *Client {
  12772. client := &Client{config: m.config}
  12773. client.init()
  12774. return client
  12775. }
  12776. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12777. // it returns an error otherwise.
  12778. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12779. if _, ok := m.driver.(*txDriver); !ok {
  12780. return nil, errors.New("ent: mutation is not running in a transaction")
  12781. }
  12782. tx := &Tx{config: m.config}
  12783. tx.init()
  12784. return tx, nil
  12785. }
  12786. // SetID sets the value of the id field. Note that this
  12787. // operation is only accepted on creation of LabelRelationship entities.
  12788. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12789. m.id = &id
  12790. }
  12791. // ID returns the ID value in the mutation. Note that the ID is only available
  12792. // if it was provided to the builder or after it was returned from the database.
  12793. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12794. if m.id == nil {
  12795. return
  12796. }
  12797. return *m.id, true
  12798. }
  12799. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12800. // That means, if the mutation is applied within a transaction with an isolation level such
  12801. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12802. // or updated by the mutation.
  12803. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12804. switch {
  12805. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12806. id, exists := m.ID()
  12807. if exists {
  12808. return []uint64{id}, nil
  12809. }
  12810. fallthrough
  12811. case m.op.Is(OpUpdate | OpDelete):
  12812. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12813. default:
  12814. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12815. }
  12816. }
  12817. // SetCreatedAt sets the "created_at" field.
  12818. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12819. m.created_at = &t
  12820. }
  12821. // CreatedAt returns the value of the "created_at" field in the mutation.
  12822. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12823. v := m.created_at
  12824. if v == nil {
  12825. return
  12826. }
  12827. return *v, true
  12828. }
  12829. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12830. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12832. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12833. if !m.op.Is(OpUpdateOne) {
  12834. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12835. }
  12836. if m.id == nil || m.oldValue == nil {
  12837. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12838. }
  12839. oldValue, err := m.oldValue(ctx)
  12840. if err != nil {
  12841. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12842. }
  12843. return oldValue.CreatedAt, nil
  12844. }
  12845. // ResetCreatedAt resets all changes to the "created_at" field.
  12846. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12847. m.created_at = nil
  12848. }
  12849. // SetUpdatedAt sets the "updated_at" field.
  12850. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12851. m.updated_at = &t
  12852. }
  12853. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12854. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12855. v := m.updated_at
  12856. if v == nil {
  12857. return
  12858. }
  12859. return *v, true
  12860. }
  12861. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12862. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12864. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12865. if !m.op.Is(OpUpdateOne) {
  12866. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12867. }
  12868. if m.id == nil || m.oldValue == nil {
  12869. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12870. }
  12871. oldValue, err := m.oldValue(ctx)
  12872. if err != nil {
  12873. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12874. }
  12875. return oldValue.UpdatedAt, nil
  12876. }
  12877. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12878. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12879. m.updated_at = nil
  12880. }
  12881. // SetStatus sets the "status" field.
  12882. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12883. m.status = &u
  12884. m.addstatus = nil
  12885. }
  12886. // Status returns the value of the "status" field in the mutation.
  12887. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12888. v := m.status
  12889. if v == nil {
  12890. return
  12891. }
  12892. return *v, true
  12893. }
  12894. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12895. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12897. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12898. if !m.op.Is(OpUpdateOne) {
  12899. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12900. }
  12901. if m.id == nil || m.oldValue == nil {
  12902. return v, errors.New("OldStatus requires an ID field in the mutation")
  12903. }
  12904. oldValue, err := m.oldValue(ctx)
  12905. if err != nil {
  12906. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12907. }
  12908. return oldValue.Status, nil
  12909. }
  12910. // AddStatus adds u to the "status" field.
  12911. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12912. if m.addstatus != nil {
  12913. *m.addstatus += u
  12914. } else {
  12915. m.addstatus = &u
  12916. }
  12917. }
  12918. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12919. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12920. v := m.addstatus
  12921. if v == nil {
  12922. return
  12923. }
  12924. return *v, true
  12925. }
  12926. // ClearStatus clears the value of the "status" field.
  12927. func (m *LabelRelationshipMutation) ClearStatus() {
  12928. m.status = nil
  12929. m.addstatus = nil
  12930. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12931. }
  12932. // StatusCleared returns if the "status" field was cleared in this mutation.
  12933. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12934. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12935. return ok
  12936. }
  12937. // ResetStatus resets all changes to the "status" field.
  12938. func (m *LabelRelationshipMutation) ResetStatus() {
  12939. m.status = nil
  12940. m.addstatus = nil
  12941. delete(m.clearedFields, labelrelationship.FieldStatus)
  12942. }
  12943. // SetDeletedAt sets the "deleted_at" field.
  12944. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  12945. m.deleted_at = &t
  12946. }
  12947. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12948. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  12949. v := m.deleted_at
  12950. if v == nil {
  12951. return
  12952. }
  12953. return *v, true
  12954. }
  12955. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  12956. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12958. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12959. if !m.op.Is(OpUpdateOne) {
  12960. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12961. }
  12962. if m.id == nil || m.oldValue == nil {
  12963. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12964. }
  12965. oldValue, err := m.oldValue(ctx)
  12966. if err != nil {
  12967. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12968. }
  12969. return oldValue.DeletedAt, nil
  12970. }
  12971. // ClearDeletedAt clears the value of the "deleted_at" field.
  12972. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  12973. m.deleted_at = nil
  12974. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  12975. }
  12976. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12977. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  12978. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  12979. return ok
  12980. }
  12981. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12982. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  12983. m.deleted_at = nil
  12984. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  12985. }
  12986. // SetLabelID sets the "label_id" field.
  12987. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12988. m.labels = &u
  12989. }
  12990. // LabelID returns the value of the "label_id" field in the mutation.
  12991. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12992. v := m.labels
  12993. if v == nil {
  12994. return
  12995. }
  12996. return *v, true
  12997. }
  12998. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12999. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13001. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  13002. if !m.op.Is(OpUpdateOne) {
  13003. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  13004. }
  13005. if m.id == nil || m.oldValue == nil {
  13006. return v, errors.New("OldLabelID requires an ID field in the mutation")
  13007. }
  13008. oldValue, err := m.oldValue(ctx)
  13009. if err != nil {
  13010. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  13011. }
  13012. return oldValue.LabelID, nil
  13013. }
  13014. // ResetLabelID resets all changes to the "label_id" field.
  13015. func (m *LabelRelationshipMutation) ResetLabelID() {
  13016. m.labels = nil
  13017. }
  13018. // SetContactID sets the "contact_id" field.
  13019. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  13020. m.contacts = &u
  13021. }
  13022. // ContactID returns the value of the "contact_id" field in the mutation.
  13023. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  13024. v := m.contacts
  13025. if v == nil {
  13026. return
  13027. }
  13028. return *v, true
  13029. }
  13030. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  13031. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13033. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13034. if !m.op.Is(OpUpdateOne) {
  13035. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13036. }
  13037. if m.id == nil || m.oldValue == nil {
  13038. return v, errors.New("OldContactID requires an ID field in the mutation")
  13039. }
  13040. oldValue, err := m.oldValue(ctx)
  13041. if err != nil {
  13042. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13043. }
  13044. return oldValue.ContactID, nil
  13045. }
  13046. // ResetContactID resets all changes to the "contact_id" field.
  13047. func (m *LabelRelationshipMutation) ResetContactID() {
  13048. m.contacts = nil
  13049. }
  13050. // SetOrganizationID sets the "organization_id" field.
  13051. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  13052. m.organization_id = &u
  13053. m.addorganization_id = nil
  13054. }
  13055. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13056. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  13057. v := m.organization_id
  13058. if v == nil {
  13059. return
  13060. }
  13061. return *v, true
  13062. }
  13063. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  13064. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  13065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13066. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13067. if !m.op.Is(OpUpdateOne) {
  13068. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13069. }
  13070. if m.id == nil || m.oldValue == nil {
  13071. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13072. }
  13073. oldValue, err := m.oldValue(ctx)
  13074. if err != nil {
  13075. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13076. }
  13077. return oldValue.OrganizationID, nil
  13078. }
  13079. // AddOrganizationID adds u to the "organization_id" field.
  13080. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  13081. if m.addorganization_id != nil {
  13082. *m.addorganization_id += u
  13083. } else {
  13084. m.addorganization_id = &u
  13085. }
  13086. }
  13087. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13088. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  13089. v := m.addorganization_id
  13090. if v == nil {
  13091. return
  13092. }
  13093. return *v, true
  13094. }
  13095. // ClearOrganizationID clears the value of the "organization_id" field.
  13096. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  13097. m.organization_id = nil
  13098. m.addorganization_id = nil
  13099. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  13100. }
  13101. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13102. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  13103. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  13104. return ok
  13105. }
  13106. // ResetOrganizationID resets all changes to the "organization_id" field.
  13107. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  13108. m.organization_id = nil
  13109. m.addorganization_id = nil
  13110. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  13111. }
  13112. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  13113. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  13114. m.contacts = &id
  13115. }
  13116. // ClearContacts clears the "contacts" edge to the Contact entity.
  13117. func (m *LabelRelationshipMutation) ClearContacts() {
  13118. m.clearedcontacts = true
  13119. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  13120. }
  13121. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  13122. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  13123. return m.clearedcontacts
  13124. }
  13125. // ContactsID returns the "contacts" edge ID in the mutation.
  13126. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  13127. if m.contacts != nil {
  13128. return *m.contacts, true
  13129. }
  13130. return
  13131. }
  13132. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  13133. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13134. // ContactsID instead. It exists only for internal usage by the builders.
  13135. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  13136. if id := m.contacts; id != nil {
  13137. ids = append(ids, *id)
  13138. }
  13139. return
  13140. }
  13141. // ResetContacts resets all changes to the "contacts" edge.
  13142. func (m *LabelRelationshipMutation) ResetContacts() {
  13143. m.contacts = nil
  13144. m.clearedcontacts = false
  13145. }
  13146. // SetLabelsID sets the "labels" edge to the Label entity by id.
  13147. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  13148. m.labels = &id
  13149. }
  13150. // ClearLabels clears the "labels" edge to the Label entity.
  13151. func (m *LabelRelationshipMutation) ClearLabels() {
  13152. m.clearedlabels = true
  13153. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  13154. }
  13155. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  13156. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  13157. return m.clearedlabels
  13158. }
  13159. // LabelsID returns the "labels" edge ID in the mutation.
  13160. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  13161. if m.labels != nil {
  13162. return *m.labels, true
  13163. }
  13164. return
  13165. }
  13166. // LabelsIDs returns the "labels" edge IDs in the mutation.
  13167. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13168. // LabelsID instead. It exists only for internal usage by the builders.
  13169. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  13170. if id := m.labels; id != nil {
  13171. ids = append(ids, *id)
  13172. }
  13173. return
  13174. }
  13175. // ResetLabels resets all changes to the "labels" edge.
  13176. func (m *LabelRelationshipMutation) ResetLabels() {
  13177. m.labels = nil
  13178. m.clearedlabels = false
  13179. }
  13180. // Where appends a list predicates to the LabelRelationshipMutation builder.
  13181. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  13182. m.predicates = append(m.predicates, ps...)
  13183. }
  13184. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  13185. // users can use type-assertion to append predicates that do not depend on any generated package.
  13186. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  13187. p := make([]predicate.LabelRelationship, len(ps))
  13188. for i := range ps {
  13189. p[i] = ps[i]
  13190. }
  13191. m.Where(p...)
  13192. }
  13193. // Op returns the operation name.
  13194. func (m *LabelRelationshipMutation) Op() Op {
  13195. return m.op
  13196. }
  13197. // SetOp allows setting the mutation operation.
  13198. func (m *LabelRelationshipMutation) SetOp(op Op) {
  13199. m.op = op
  13200. }
  13201. // Type returns the node type of this mutation (LabelRelationship).
  13202. func (m *LabelRelationshipMutation) Type() string {
  13203. return m.typ
  13204. }
  13205. // Fields returns all fields that were changed during this mutation. Note that in
  13206. // order to get all numeric fields that were incremented/decremented, call
  13207. // AddedFields().
  13208. func (m *LabelRelationshipMutation) Fields() []string {
  13209. fields := make([]string, 0, 7)
  13210. if m.created_at != nil {
  13211. fields = append(fields, labelrelationship.FieldCreatedAt)
  13212. }
  13213. if m.updated_at != nil {
  13214. fields = append(fields, labelrelationship.FieldUpdatedAt)
  13215. }
  13216. if m.status != nil {
  13217. fields = append(fields, labelrelationship.FieldStatus)
  13218. }
  13219. if m.deleted_at != nil {
  13220. fields = append(fields, labelrelationship.FieldDeletedAt)
  13221. }
  13222. if m.labels != nil {
  13223. fields = append(fields, labelrelationship.FieldLabelID)
  13224. }
  13225. if m.contacts != nil {
  13226. fields = append(fields, labelrelationship.FieldContactID)
  13227. }
  13228. if m.organization_id != nil {
  13229. fields = append(fields, labelrelationship.FieldOrganizationID)
  13230. }
  13231. return fields
  13232. }
  13233. // Field returns the value of a field with the given name. The second boolean
  13234. // return value indicates that this field was not set, or was not defined in the
  13235. // schema.
  13236. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  13237. switch name {
  13238. case labelrelationship.FieldCreatedAt:
  13239. return m.CreatedAt()
  13240. case labelrelationship.FieldUpdatedAt:
  13241. return m.UpdatedAt()
  13242. case labelrelationship.FieldStatus:
  13243. return m.Status()
  13244. case labelrelationship.FieldDeletedAt:
  13245. return m.DeletedAt()
  13246. case labelrelationship.FieldLabelID:
  13247. return m.LabelID()
  13248. case labelrelationship.FieldContactID:
  13249. return m.ContactID()
  13250. case labelrelationship.FieldOrganizationID:
  13251. return m.OrganizationID()
  13252. }
  13253. return nil, false
  13254. }
  13255. // OldField returns the old value of the field from the database. An error is
  13256. // returned if the mutation operation is not UpdateOne, or the query to the
  13257. // database failed.
  13258. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13259. switch name {
  13260. case labelrelationship.FieldCreatedAt:
  13261. return m.OldCreatedAt(ctx)
  13262. case labelrelationship.FieldUpdatedAt:
  13263. return m.OldUpdatedAt(ctx)
  13264. case labelrelationship.FieldStatus:
  13265. return m.OldStatus(ctx)
  13266. case labelrelationship.FieldDeletedAt:
  13267. return m.OldDeletedAt(ctx)
  13268. case labelrelationship.FieldLabelID:
  13269. return m.OldLabelID(ctx)
  13270. case labelrelationship.FieldContactID:
  13271. return m.OldContactID(ctx)
  13272. case labelrelationship.FieldOrganizationID:
  13273. return m.OldOrganizationID(ctx)
  13274. }
  13275. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  13276. }
  13277. // SetField sets the value of a field with the given name. It returns an error if
  13278. // the field is not defined in the schema, or if the type mismatched the field
  13279. // type.
  13280. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  13281. switch name {
  13282. case labelrelationship.FieldCreatedAt:
  13283. v, ok := value.(time.Time)
  13284. if !ok {
  13285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13286. }
  13287. m.SetCreatedAt(v)
  13288. return nil
  13289. case labelrelationship.FieldUpdatedAt:
  13290. v, ok := value.(time.Time)
  13291. if !ok {
  13292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13293. }
  13294. m.SetUpdatedAt(v)
  13295. return nil
  13296. case labelrelationship.FieldStatus:
  13297. v, ok := value.(uint8)
  13298. if !ok {
  13299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13300. }
  13301. m.SetStatus(v)
  13302. return nil
  13303. case labelrelationship.FieldDeletedAt:
  13304. v, ok := value.(time.Time)
  13305. if !ok {
  13306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13307. }
  13308. m.SetDeletedAt(v)
  13309. return nil
  13310. case labelrelationship.FieldLabelID:
  13311. v, ok := value.(uint64)
  13312. if !ok {
  13313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13314. }
  13315. m.SetLabelID(v)
  13316. return nil
  13317. case labelrelationship.FieldContactID:
  13318. v, ok := value.(uint64)
  13319. if !ok {
  13320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13321. }
  13322. m.SetContactID(v)
  13323. return nil
  13324. case labelrelationship.FieldOrganizationID:
  13325. v, ok := value.(uint64)
  13326. if !ok {
  13327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13328. }
  13329. m.SetOrganizationID(v)
  13330. return nil
  13331. }
  13332. return fmt.Errorf("unknown LabelRelationship field %s", name)
  13333. }
  13334. // AddedFields returns all numeric fields that were incremented/decremented during
  13335. // this mutation.
  13336. func (m *LabelRelationshipMutation) AddedFields() []string {
  13337. var fields []string
  13338. if m.addstatus != nil {
  13339. fields = append(fields, labelrelationship.FieldStatus)
  13340. }
  13341. if m.addorganization_id != nil {
  13342. fields = append(fields, labelrelationship.FieldOrganizationID)
  13343. }
  13344. return fields
  13345. }
  13346. // AddedField returns the numeric value that was incremented/decremented on a field
  13347. // with the given name. The second boolean return value indicates that this field
  13348. // was not set, or was not defined in the schema.
  13349. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  13350. switch name {
  13351. case labelrelationship.FieldStatus:
  13352. return m.AddedStatus()
  13353. case labelrelationship.FieldOrganizationID:
  13354. return m.AddedOrganizationID()
  13355. }
  13356. return nil, false
  13357. }
  13358. // AddField adds the value to the field with the given name. It returns an error if
  13359. // the field is not defined in the schema, or if the type mismatched the field
  13360. // type.
  13361. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  13362. switch name {
  13363. case labelrelationship.FieldStatus:
  13364. v, ok := value.(int8)
  13365. if !ok {
  13366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13367. }
  13368. m.AddStatus(v)
  13369. return nil
  13370. case labelrelationship.FieldOrganizationID:
  13371. v, ok := value.(int64)
  13372. if !ok {
  13373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13374. }
  13375. m.AddOrganizationID(v)
  13376. return nil
  13377. }
  13378. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  13379. }
  13380. // ClearedFields returns all nullable fields that were cleared during this
  13381. // mutation.
  13382. func (m *LabelRelationshipMutation) ClearedFields() []string {
  13383. var fields []string
  13384. if m.FieldCleared(labelrelationship.FieldStatus) {
  13385. fields = append(fields, labelrelationship.FieldStatus)
  13386. }
  13387. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  13388. fields = append(fields, labelrelationship.FieldDeletedAt)
  13389. }
  13390. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  13391. fields = append(fields, labelrelationship.FieldOrganizationID)
  13392. }
  13393. return fields
  13394. }
  13395. // FieldCleared returns a boolean indicating if a field with the given name was
  13396. // cleared in this mutation.
  13397. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  13398. _, ok := m.clearedFields[name]
  13399. return ok
  13400. }
  13401. // ClearField clears the value of the field with the given name. It returns an
  13402. // error if the field is not defined in the schema.
  13403. func (m *LabelRelationshipMutation) ClearField(name string) error {
  13404. switch name {
  13405. case labelrelationship.FieldStatus:
  13406. m.ClearStatus()
  13407. return nil
  13408. case labelrelationship.FieldDeletedAt:
  13409. m.ClearDeletedAt()
  13410. return nil
  13411. case labelrelationship.FieldOrganizationID:
  13412. m.ClearOrganizationID()
  13413. return nil
  13414. }
  13415. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  13416. }
  13417. // ResetField resets all changes in the mutation for the field with the given name.
  13418. // It returns an error if the field is not defined in the schema.
  13419. func (m *LabelRelationshipMutation) ResetField(name string) error {
  13420. switch name {
  13421. case labelrelationship.FieldCreatedAt:
  13422. m.ResetCreatedAt()
  13423. return nil
  13424. case labelrelationship.FieldUpdatedAt:
  13425. m.ResetUpdatedAt()
  13426. return nil
  13427. case labelrelationship.FieldStatus:
  13428. m.ResetStatus()
  13429. return nil
  13430. case labelrelationship.FieldDeletedAt:
  13431. m.ResetDeletedAt()
  13432. return nil
  13433. case labelrelationship.FieldLabelID:
  13434. m.ResetLabelID()
  13435. return nil
  13436. case labelrelationship.FieldContactID:
  13437. m.ResetContactID()
  13438. return nil
  13439. case labelrelationship.FieldOrganizationID:
  13440. m.ResetOrganizationID()
  13441. return nil
  13442. }
  13443. return fmt.Errorf("unknown LabelRelationship field %s", name)
  13444. }
  13445. // AddedEdges returns all edge names that were set/added in this mutation.
  13446. func (m *LabelRelationshipMutation) AddedEdges() []string {
  13447. edges := make([]string, 0, 2)
  13448. if m.contacts != nil {
  13449. edges = append(edges, labelrelationship.EdgeContacts)
  13450. }
  13451. if m.labels != nil {
  13452. edges = append(edges, labelrelationship.EdgeLabels)
  13453. }
  13454. return edges
  13455. }
  13456. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13457. // name in this mutation.
  13458. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  13459. switch name {
  13460. case labelrelationship.EdgeContacts:
  13461. if id := m.contacts; id != nil {
  13462. return []ent.Value{*id}
  13463. }
  13464. case labelrelationship.EdgeLabels:
  13465. if id := m.labels; id != nil {
  13466. return []ent.Value{*id}
  13467. }
  13468. }
  13469. return nil
  13470. }
  13471. // RemovedEdges returns all edge names that were removed in this mutation.
  13472. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  13473. edges := make([]string, 0, 2)
  13474. return edges
  13475. }
  13476. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13477. // the given name in this mutation.
  13478. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  13479. return nil
  13480. }
  13481. // ClearedEdges returns all edge names that were cleared in this mutation.
  13482. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  13483. edges := make([]string, 0, 2)
  13484. if m.clearedcontacts {
  13485. edges = append(edges, labelrelationship.EdgeContacts)
  13486. }
  13487. if m.clearedlabels {
  13488. edges = append(edges, labelrelationship.EdgeLabels)
  13489. }
  13490. return edges
  13491. }
  13492. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13493. // was cleared in this mutation.
  13494. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  13495. switch name {
  13496. case labelrelationship.EdgeContacts:
  13497. return m.clearedcontacts
  13498. case labelrelationship.EdgeLabels:
  13499. return m.clearedlabels
  13500. }
  13501. return false
  13502. }
  13503. // ClearEdge clears the value of the edge with the given name. It returns an error
  13504. // if that edge is not defined in the schema.
  13505. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  13506. switch name {
  13507. case labelrelationship.EdgeContacts:
  13508. m.ClearContacts()
  13509. return nil
  13510. case labelrelationship.EdgeLabels:
  13511. m.ClearLabels()
  13512. return nil
  13513. }
  13514. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  13515. }
  13516. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13517. // It returns an error if the edge is not defined in the schema.
  13518. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  13519. switch name {
  13520. case labelrelationship.EdgeContacts:
  13521. m.ResetContacts()
  13522. return nil
  13523. case labelrelationship.EdgeLabels:
  13524. m.ResetLabels()
  13525. return nil
  13526. }
  13527. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  13528. }
  13529. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  13530. type LabelTaggingMutation struct {
  13531. config
  13532. op Op
  13533. typ string
  13534. id *uint64
  13535. created_at *time.Time
  13536. updated_at *time.Time
  13537. status *uint8
  13538. addstatus *int8
  13539. deleted_at *time.Time
  13540. organization_id *uint64
  13541. addorganization_id *int64
  13542. _type *int
  13543. add_type *int
  13544. conditions *string
  13545. action_label_add *[]uint64
  13546. appendaction_label_add []uint64
  13547. action_label_del *[]uint64
  13548. appendaction_label_del []uint64
  13549. clearedFields map[string]struct{}
  13550. done bool
  13551. oldValue func(context.Context) (*LabelTagging, error)
  13552. predicates []predicate.LabelTagging
  13553. }
  13554. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  13555. // labeltaggingOption allows management of the mutation configuration using functional options.
  13556. type labeltaggingOption func(*LabelTaggingMutation)
  13557. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  13558. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  13559. m := &LabelTaggingMutation{
  13560. config: c,
  13561. op: op,
  13562. typ: TypeLabelTagging,
  13563. clearedFields: make(map[string]struct{}),
  13564. }
  13565. for _, opt := range opts {
  13566. opt(m)
  13567. }
  13568. return m
  13569. }
  13570. // withLabelTaggingID sets the ID field of the mutation.
  13571. func withLabelTaggingID(id uint64) labeltaggingOption {
  13572. return func(m *LabelTaggingMutation) {
  13573. var (
  13574. err error
  13575. once sync.Once
  13576. value *LabelTagging
  13577. )
  13578. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  13579. once.Do(func() {
  13580. if m.done {
  13581. err = errors.New("querying old values post mutation is not allowed")
  13582. } else {
  13583. value, err = m.Client().LabelTagging.Get(ctx, id)
  13584. }
  13585. })
  13586. return value, err
  13587. }
  13588. m.id = &id
  13589. }
  13590. }
  13591. // withLabelTagging sets the old LabelTagging of the mutation.
  13592. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  13593. return func(m *LabelTaggingMutation) {
  13594. m.oldValue = func(context.Context) (*LabelTagging, error) {
  13595. return node, nil
  13596. }
  13597. m.id = &node.ID
  13598. }
  13599. }
  13600. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13601. // executed in a transaction (ent.Tx), a transactional client is returned.
  13602. func (m LabelTaggingMutation) Client() *Client {
  13603. client := &Client{config: m.config}
  13604. client.init()
  13605. return client
  13606. }
  13607. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13608. // it returns an error otherwise.
  13609. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  13610. if _, ok := m.driver.(*txDriver); !ok {
  13611. return nil, errors.New("ent: mutation is not running in a transaction")
  13612. }
  13613. tx := &Tx{config: m.config}
  13614. tx.init()
  13615. return tx, nil
  13616. }
  13617. // SetID sets the value of the id field. Note that this
  13618. // operation is only accepted on creation of LabelTagging entities.
  13619. func (m *LabelTaggingMutation) SetID(id uint64) {
  13620. m.id = &id
  13621. }
  13622. // ID returns the ID value in the mutation. Note that the ID is only available
  13623. // if it was provided to the builder or after it was returned from the database.
  13624. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  13625. if m.id == nil {
  13626. return
  13627. }
  13628. return *m.id, true
  13629. }
  13630. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13631. // That means, if the mutation is applied within a transaction with an isolation level such
  13632. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13633. // or updated by the mutation.
  13634. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  13635. switch {
  13636. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13637. id, exists := m.ID()
  13638. if exists {
  13639. return []uint64{id}, nil
  13640. }
  13641. fallthrough
  13642. case m.op.Is(OpUpdate | OpDelete):
  13643. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  13644. default:
  13645. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13646. }
  13647. }
  13648. // SetCreatedAt sets the "created_at" field.
  13649. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  13650. m.created_at = &t
  13651. }
  13652. // CreatedAt returns the value of the "created_at" field in the mutation.
  13653. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  13654. v := m.created_at
  13655. if v == nil {
  13656. return
  13657. }
  13658. return *v, true
  13659. }
  13660. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  13661. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13663. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13664. if !m.op.Is(OpUpdateOne) {
  13665. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13666. }
  13667. if m.id == nil || m.oldValue == nil {
  13668. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13669. }
  13670. oldValue, err := m.oldValue(ctx)
  13671. if err != nil {
  13672. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13673. }
  13674. return oldValue.CreatedAt, nil
  13675. }
  13676. // ResetCreatedAt resets all changes to the "created_at" field.
  13677. func (m *LabelTaggingMutation) ResetCreatedAt() {
  13678. m.created_at = nil
  13679. }
  13680. // SetUpdatedAt sets the "updated_at" field.
  13681. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  13682. m.updated_at = &t
  13683. }
  13684. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13685. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  13686. v := m.updated_at
  13687. if v == nil {
  13688. return
  13689. }
  13690. return *v, true
  13691. }
  13692. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  13693. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13695. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13696. if !m.op.Is(OpUpdateOne) {
  13697. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13698. }
  13699. if m.id == nil || m.oldValue == nil {
  13700. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13701. }
  13702. oldValue, err := m.oldValue(ctx)
  13703. if err != nil {
  13704. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13705. }
  13706. return oldValue.UpdatedAt, nil
  13707. }
  13708. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13709. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  13710. m.updated_at = nil
  13711. }
  13712. // SetStatus sets the "status" field.
  13713. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  13714. m.status = &u
  13715. m.addstatus = nil
  13716. }
  13717. // Status returns the value of the "status" field in the mutation.
  13718. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  13719. v := m.status
  13720. if v == nil {
  13721. return
  13722. }
  13723. return *v, true
  13724. }
  13725. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  13726. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13728. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13729. if !m.op.Is(OpUpdateOne) {
  13730. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13731. }
  13732. if m.id == nil || m.oldValue == nil {
  13733. return v, errors.New("OldStatus requires an ID field in the mutation")
  13734. }
  13735. oldValue, err := m.oldValue(ctx)
  13736. if err != nil {
  13737. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13738. }
  13739. return oldValue.Status, nil
  13740. }
  13741. // AddStatus adds u to the "status" field.
  13742. func (m *LabelTaggingMutation) AddStatus(u int8) {
  13743. if m.addstatus != nil {
  13744. *m.addstatus += u
  13745. } else {
  13746. m.addstatus = &u
  13747. }
  13748. }
  13749. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13750. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  13751. v := m.addstatus
  13752. if v == nil {
  13753. return
  13754. }
  13755. return *v, true
  13756. }
  13757. // ClearStatus clears the value of the "status" field.
  13758. func (m *LabelTaggingMutation) ClearStatus() {
  13759. m.status = nil
  13760. m.addstatus = nil
  13761. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  13762. }
  13763. // StatusCleared returns if the "status" field was cleared in this mutation.
  13764. func (m *LabelTaggingMutation) StatusCleared() bool {
  13765. _, ok := m.clearedFields[labeltagging.FieldStatus]
  13766. return ok
  13767. }
  13768. // ResetStatus resets all changes to the "status" field.
  13769. func (m *LabelTaggingMutation) ResetStatus() {
  13770. m.status = nil
  13771. m.addstatus = nil
  13772. delete(m.clearedFields, labeltagging.FieldStatus)
  13773. }
  13774. // SetDeletedAt sets the "deleted_at" field.
  13775. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  13776. m.deleted_at = &t
  13777. }
  13778. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13779. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  13780. v := m.deleted_at
  13781. if v == nil {
  13782. return
  13783. }
  13784. return *v, true
  13785. }
  13786. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  13787. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13789. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13790. if !m.op.Is(OpUpdateOne) {
  13791. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13792. }
  13793. if m.id == nil || m.oldValue == nil {
  13794. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13795. }
  13796. oldValue, err := m.oldValue(ctx)
  13797. if err != nil {
  13798. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13799. }
  13800. return oldValue.DeletedAt, nil
  13801. }
  13802. // ClearDeletedAt clears the value of the "deleted_at" field.
  13803. func (m *LabelTaggingMutation) ClearDeletedAt() {
  13804. m.deleted_at = nil
  13805. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  13806. }
  13807. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13808. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  13809. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  13810. return ok
  13811. }
  13812. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13813. func (m *LabelTaggingMutation) ResetDeletedAt() {
  13814. m.deleted_at = nil
  13815. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  13816. }
  13817. // SetOrganizationID sets the "organization_id" field.
  13818. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  13819. m.organization_id = &u
  13820. m.addorganization_id = nil
  13821. }
  13822. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13823. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  13824. v := m.organization_id
  13825. if v == nil {
  13826. return
  13827. }
  13828. return *v, true
  13829. }
  13830. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  13831. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13833. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13834. if !m.op.Is(OpUpdateOne) {
  13835. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13836. }
  13837. if m.id == nil || m.oldValue == nil {
  13838. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13839. }
  13840. oldValue, err := m.oldValue(ctx)
  13841. if err != nil {
  13842. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13843. }
  13844. return oldValue.OrganizationID, nil
  13845. }
  13846. // AddOrganizationID adds u to the "organization_id" field.
  13847. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  13848. if m.addorganization_id != nil {
  13849. *m.addorganization_id += u
  13850. } else {
  13851. m.addorganization_id = &u
  13852. }
  13853. }
  13854. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13855. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  13856. v := m.addorganization_id
  13857. if v == nil {
  13858. return
  13859. }
  13860. return *v, true
  13861. }
  13862. // ResetOrganizationID resets all changes to the "organization_id" field.
  13863. func (m *LabelTaggingMutation) ResetOrganizationID() {
  13864. m.organization_id = nil
  13865. m.addorganization_id = nil
  13866. }
  13867. // SetType sets the "type" field.
  13868. func (m *LabelTaggingMutation) SetType(i int) {
  13869. m._type = &i
  13870. m.add_type = nil
  13871. }
  13872. // GetType returns the value of the "type" field in the mutation.
  13873. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  13874. v := m._type
  13875. if v == nil {
  13876. return
  13877. }
  13878. return *v, true
  13879. }
  13880. // OldType returns the old "type" field's value of the LabelTagging entity.
  13881. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13883. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  13884. if !m.op.Is(OpUpdateOne) {
  13885. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13886. }
  13887. if m.id == nil || m.oldValue == nil {
  13888. return v, errors.New("OldType requires an ID field in the mutation")
  13889. }
  13890. oldValue, err := m.oldValue(ctx)
  13891. if err != nil {
  13892. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13893. }
  13894. return oldValue.Type, nil
  13895. }
  13896. // AddType adds i to the "type" field.
  13897. func (m *LabelTaggingMutation) AddType(i int) {
  13898. if m.add_type != nil {
  13899. *m.add_type += i
  13900. } else {
  13901. m.add_type = &i
  13902. }
  13903. }
  13904. // AddedType returns the value that was added to the "type" field in this mutation.
  13905. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  13906. v := m.add_type
  13907. if v == nil {
  13908. return
  13909. }
  13910. return *v, true
  13911. }
  13912. // ResetType resets all changes to the "type" field.
  13913. func (m *LabelTaggingMutation) ResetType() {
  13914. m._type = nil
  13915. m.add_type = nil
  13916. }
  13917. // SetConditions sets the "conditions" field.
  13918. func (m *LabelTaggingMutation) SetConditions(s string) {
  13919. m.conditions = &s
  13920. }
  13921. // Conditions returns the value of the "conditions" field in the mutation.
  13922. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  13923. v := m.conditions
  13924. if v == nil {
  13925. return
  13926. }
  13927. return *v, true
  13928. }
  13929. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  13930. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13932. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  13933. if !m.op.Is(OpUpdateOne) {
  13934. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13935. }
  13936. if m.id == nil || m.oldValue == nil {
  13937. return v, errors.New("OldConditions requires an ID field in the mutation")
  13938. }
  13939. oldValue, err := m.oldValue(ctx)
  13940. if err != nil {
  13941. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13942. }
  13943. return oldValue.Conditions, nil
  13944. }
  13945. // ResetConditions resets all changes to the "conditions" field.
  13946. func (m *LabelTaggingMutation) ResetConditions() {
  13947. m.conditions = nil
  13948. }
  13949. // SetActionLabelAdd sets the "action_label_add" field.
  13950. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  13951. m.action_label_add = &u
  13952. m.appendaction_label_add = nil
  13953. }
  13954. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  13955. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  13956. v := m.action_label_add
  13957. if v == nil {
  13958. return
  13959. }
  13960. return *v, true
  13961. }
  13962. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  13963. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13965. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  13966. if !m.op.Is(OpUpdateOne) {
  13967. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  13968. }
  13969. if m.id == nil || m.oldValue == nil {
  13970. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  13971. }
  13972. oldValue, err := m.oldValue(ctx)
  13973. if err != nil {
  13974. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  13975. }
  13976. return oldValue.ActionLabelAdd, nil
  13977. }
  13978. // AppendActionLabelAdd adds u to the "action_label_add" field.
  13979. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  13980. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  13981. }
  13982. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  13983. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  13984. if len(m.appendaction_label_add) == 0 {
  13985. return nil, false
  13986. }
  13987. return m.appendaction_label_add, true
  13988. }
  13989. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  13990. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  13991. m.action_label_add = nil
  13992. m.appendaction_label_add = nil
  13993. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  13994. }
  13995. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  13996. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  13997. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  13998. return ok
  13999. }
  14000. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  14001. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  14002. m.action_label_add = nil
  14003. m.appendaction_label_add = nil
  14004. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  14005. }
  14006. // SetActionLabelDel sets the "action_label_del" field.
  14007. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  14008. m.action_label_del = &u
  14009. m.appendaction_label_del = nil
  14010. }
  14011. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  14012. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  14013. v := m.action_label_del
  14014. if v == nil {
  14015. return
  14016. }
  14017. return *v, true
  14018. }
  14019. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  14020. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  14021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14022. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  14023. if !m.op.Is(OpUpdateOne) {
  14024. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  14025. }
  14026. if m.id == nil || m.oldValue == nil {
  14027. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  14028. }
  14029. oldValue, err := m.oldValue(ctx)
  14030. if err != nil {
  14031. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  14032. }
  14033. return oldValue.ActionLabelDel, nil
  14034. }
  14035. // AppendActionLabelDel adds u to the "action_label_del" field.
  14036. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  14037. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  14038. }
  14039. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  14040. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  14041. if len(m.appendaction_label_del) == 0 {
  14042. return nil, false
  14043. }
  14044. return m.appendaction_label_del, true
  14045. }
  14046. // ClearActionLabelDel clears the value of the "action_label_del" field.
  14047. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  14048. m.action_label_del = nil
  14049. m.appendaction_label_del = nil
  14050. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  14051. }
  14052. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  14053. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  14054. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  14055. return ok
  14056. }
  14057. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  14058. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  14059. m.action_label_del = nil
  14060. m.appendaction_label_del = nil
  14061. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  14062. }
  14063. // Where appends a list predicates to the LabelTaggingMutation builder.
  14064. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  14065. m.predicates = append(m.predicates, ps...)
  14066. }
  14067. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  14068. // users can use type-assertion to append predicates that do not depend on any generated package.
  14069. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  14070. p := make([]predicate.LabelTagging, len(ps))
  14071. for i := range ps {
  14072. p[i] = ps[i]
  14073. }
  14074. m.Where(p...)
  14075. }
  14076. // Op returns the operation name.
  14077. func (m *LabelTaggingMutation) Op() Op {
  14078. return m.op
  14079. }
  14080. // SetOp allows setting the mutation operation.
  14081. func (m *LabelTaggingMutation) SetOp(op Op) {
  14082. m.op = op
  14083. }
  14084. // Type returns the node type of this mutation (LabelTagging).
  14085. func (m *LabelTaggingMutation) Type() string {
  14086. return m.typ
  14087. }
  14088. // Fields returns all fields that were changed during this mutation. Note that in
  14089. // order to get all numeric fields that were incremented/decremented, call
  14090. // AddedFields().
  14091. func (m *LabelTaggingMutation) Fields() []string {
  14092. fields := make([]string, 0, 9)
  14093. if m.created_at != nil {
  14094. fields = append(fields, labeltagging.FieldCreatedAt)
  14095. }
  14096. if m.updated_at != nil {
  14097. fields = append(fields, labeltagging.FieldUpdatedAt)
  14098. }
  14099. if m.status != nil {
  14100. fields = append(fields, labeltagging.FieldStatus)
  14101. }
  14102. if m.deleted_at != nil {
  14103. fields = append(fields, labeltagging.FieldDeletedAt)
  14104. }
  14105. if m.organization_id != nil {
  14106. fields = append(fields, labeltagging.FieldOrganizationID)
  14107. }
  14108. if m._type != nil {
  14109. fields = append(fields, labeltagging.FieldType)
  14110. }
  14111. if m.conditions != nil {
  14112. fields = append(fields, labeltagging.FieldConditions)
  14113. }
  14114. if m.action_label_add != nil {
  14115. fields = append(fields, labeltagging.FieldActionLabelAdd)
  14116. }
  14117. if m.action_label_del != nil {
  14118. fields = append(fields, labeltagging.FieldActionLabelDel)
  14119. }
  14120. return fields
  14121. }
  14122. // Field returns the value of a field with the given name. The second boolean
  14123. // return value indicates that this field was not set, or was not defined in the
  14124. // schema.
  14125. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  14126. switch name {
  14127. case labeltagging.FieldCreatedAt:
  14128. return m.CreatedAt()
  14129. case labeltagging.FieldUpdatedAt:
  14130. return m.UpdatedAt()
  14131. case labeltagging.FieldStatus:
  14132. return m.Status()
  14133. case labeltagging.FieldDeletedAt:
  14134. return m.DeletedAt()
  14135. case labeltagging.FieldOrganizationID:
  14136. return m.OrganizationID()
  14137. case labeltagging.FieldType:
  14138. return m.GetType()
  14139. case labeltagging.FieldConditions:
  14140. return m.Conditions()
  14141. case labeltagging.FieldActionLabelAdd:
  14142. return m.ActionLabelAdd()
  14143. case labeltagging.FieldActionLabelDel:
  14144. return m.ActionLabelDel()
  14145. }
  14146. return nil, false
  14147. }
  14148. // OldField returns the old value of the field from the database. An error is
  14149. // returned if the mutation operation is not UpdateOne, or the query to the
  14150. // database failed.
  14151. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14152. switch name {
  14153. case labeltagging.FieldCreatedAt:
  14154. return m.OldCreatedAt(ctx)
  14155. case labeltagging.FieldUpdatedAt:
  14156. return m.OldUpdatedAt(ctx)
  14157. case labeltagging.FieldStatus:
  14158. return m.OldStatus(ctx)
  14159. case labeltagging.FieldDeletedAt:
  14160. return m.OldDeletedAt(ctx)
  14161. case labeltagging.FieldOrganizationID:
  14162. return m.OldOrganizationID(ctx)
  14163. case labeltagging.FieldType:
  14164. return m.OldType(ctx)
  14165. case labeltagging.FieldConditions:
  14166. return m.OldConditions(ctx)
  14167. case labeltagging.FieldActionLabelAdd:
  14168. return m.OldActionLabelAdd(ctx)
  14169. case labeltagging.FieldActionLabelDel:
  14170. return m.OldActionLabelDel(ctx)
  14171. }
  14172. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  14173. }
  14174. // SetField sets the value of a field with the given name. It returns an error if
  14175. // the field is not defined in the schema, or if the type mismatched the field
  14176. // type.
  14177. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  14178. switch name {
  14179. case labeltagging.FieldCreatedAt:
  14180. v, ok := value.(time.Time)
  14181. if !ok {
  14182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14183. }
  14184. m.SetCreatedAt(v)
  14185. return nil
  14186. case labeltagging.FieldUpdatedAt:
  14187. v, ok := value.(time.Time)
  14188. if !ok {
  14189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14190. }
  14191. m.SetUpdatedAt(v)
  14192. return nil
  14193. case labeltagging.FieldStatus:
  14194. v, ok := value.(uint8)
  14195. if !ok {
  14196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14197. }
  14198. m.SetStatus(v)
  14199. return nil
  14200. case labeltagging.FieldDeletedAt:
  14201. v, ok := value.(time.Time)
  14202. if !ok {
  14203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14204. }
  14205. m.SetDeletedAt(v)
  14206. return nil
  14207. case labeltagging.FieldOrganizationID:
  14208. v, ok := value.(uint64)
  14209. if !ok {
  14210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14211. }
  14212. m.SetOrganizationID(v)
  14213. return nil
  14214. case labeltagging.FieldType:
  14215. v, ok := value.(int)
  14216. if !ok {
  14217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14218. }
  14219. m.SetType(v)
  14220. return nil
  14221. case labeltagging.FieldConditions:
  14222. v, ok := value.(string)
  14223. if !ok {
  14224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14225. }
  14226. m.SetConditions(v)
  14227. return nil
  14228. case labeltagging.FieldActionLabelAdd:
  14229. v, ok := value.([]uint64)
  14230. if !ok {
  14231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14232. }
  14233. m.SetActionLabelAdd(v)
  14234. return nil
  14235. case labeltagging.FieldActionLabelDel:
  14236. v, ok := value.([]uint64)
  14237. if !ok {
  14238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14239. }
  14240. m.SetActionLabelDel(v)
  14241. return nil
  14242. }
  14243. return fmt.Errorf("unknown LabelTagging field %s", name)
  14244. }
  14245. // AddedFields returns all numeric fields that were incremented/decremented during
  14246. // this mutation.
  14247. func (m *LabelTaggingMutation) AddedFields() []string {
  14248. var fields []string
  14249. if m.addstatus != nil {
  14250. fields = append(fields, labeltagging.FieldStatus)
  14251. }
  14252. if m.addorganization_id != nil {
  14253. fields = append(fields, labeltagging.FieldOrganizationID)
  14254. }
  14255. if m.add_type != nil {
  14256. fields = append(fields, labeltagging.FieldType)
  14257. }
  14258. return fields
  14259. }
  14260. // AddedField returns the numeric value that was incremented/decremented on a field
  14261. // with the given name. The second boolean return value indicates that this field
  14262. // was not set, or was not defined in the schema.
  14263. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  14264. switch name {
  14265. case labeltagging.FieldStatus:
  14266. return m.AddedStatus()
  14267. case labeltagging.FieldOrganizationID:
  14268. return m.AddedOrganizationID()
  14269. case labeltagging.FieldType:
  14270. return m.AddedType()
  14271. }
  14272. return nil, false
  14273. }
  14274. // AddField adds the value to the field with the given name. It returns an error if
  14275. // the field is not defined in the schema, or if the type mismatched the field
  14276. // type.
  14277. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  14278. switch name {
  14279. case labeltagging.FieldStatus:
  14280. v, ok := value.(int8)
  14281. if !ok {
  14282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14283. }
  14284. m.AddStatus(v)
  14285. return nil
  14286. case labeltagging.FieldOrganizationID:
  14287. v, ok := value.(int64)
  14288. if !ok {
  14289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14290. }
  14291. m.AddOrganizationID(v)
  14292. return nil
  14293. case labeltagging.FieldType:
  14294. v, ok := value.(int)
  14295. if !ok {
  14296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14297. }
  14298. m.AddType(v)
  14299. return nil
  14300. }
  14301. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  14302. }
  14303. // ClearedFields returns all nullable fields that were cleared during this
  14304. // mutation.
  14305. func (m *LabelTaggingMutation) ClearedFields() []string {
  14306. var fields []string
  14307. if m.FieldCleared(labeltagging.FieldStatus) {
  14308. fields = append(fields, labeltagging.FieldStatus)
  14309. }
  14310. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  14311. fields = append(fields, labeltagging.FieldDeletedAt)
  14312. }
  14313. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  14314. fields = append(fields, labeltagging.FieldActionLabelAdd)
  14315. }
  14316. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  14317. fields = append(fields, labeltagging.FieldActionLabelDel)
  14318. }
  14319. return fields
  14320. }
  14321. // FieldCleared returns a boolean indicating if a field with the given name was
  14322. // cleared in this mutation.
  14323. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  14324. _, ok := m.clearedFields[name]
  14325. return ok
  14326. }
  14327. // ClearField clears the value of the field with the given name. It returns an
  14328. // error if the field is not defined in the schema.
  14329. func (m *LabelTaggingMutation) ClearField(name string) error {
  14330. switch name {
  14331. case labeltagging.FieldStatus:
  14332. m.ClearStatus()
  14333. return nil
  14334. case labeltagging.FieldDeletedAt:
  14335. m.ClearDeletedAt()
  14336. return nil
  14337. case labeltagging.FieldActionLabelAdd:
  14338. m.ClearActionLabelAdd()
  14339. return nil
  14340. case labeltagging.FieldActionLabelDel:
  14341. m.ClearActionLabelDel()
  14342. return nil
  14343. }
  14344. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  14345. }
  14346. // ResetField resets all changes in the mutation for the field with the given name.
  14347. // It returns an error if the field is not defined in the schema.
  14348. func (m *LabelTaggingMutation) ResetField(name string) error {
  14349. switch name {
  14350. case labeltagging.FieldCreatedAt:
  14351. m.ResetCreatedAt()
  14352. return nil
  14353. case labeltagging.FieldUpdatedAt:
  14354. m.ResetUpdatedAt()
  14355. return nil
  14356. case labeltagging.FieldStatus:
  14357. m.ResetStatus()
  14358. return nil
  14359. case labeltagging.FieldDeletedAt:
  14360. m.ResetDeletedAt()
  14361. return nil
  14362. case labeltagging.FieldOrganizationID:
  14363. m.ResetOrganizationID()
  14364. return nil
  14365. case labeltagging.FieldType:
  14366. m.ResetType()
  14367. return nil
  14368. case labeltagging.FieldConditions:
  14369. m.ResetConditions()
  14370. return nil
  14371. case labeltagging.FieldActionLabelAdd:
  14372. m.ResetActionLabelAdd()
  14373. return nil
  14374. case labeltagging.FieldActionLabelDel:
  14375. m.ResetActionLabelDel()
  14376. return nil
  14377. }
  14378. return fmt.Errorf("unknown LabelTagging field %s", name)
  14379. }
  14380. // AddedEdges returns all edge names that were set/added in this mutation.
  14381. func (m *LabelTaggingMutation) AddedEdges() []string {
  14382. edges := make([]string, 0, 0)
  14383. return edges
  14384. }
  14385. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14386. // name in this mutation.
  14387. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  14388. return nil
  14389. }
  14390. // RemovedEdges returns all edge names that were removed in this mutation.
  14391. func (m *LabelTaggingMutation) RemovedEdges() []string {
  14392. edges := make([]string, 0, 0)
  14393. return edges
  14394. }
  14395. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14396. // the given name in this mutation.
  14397. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  14398. return nil
  14399. }
  14400. // ClearedEdges returns all edge names that were cleared in this mutation.
  14401. func (m *LabelTaggingMutation) ClearedEdges() []string {
  14402. edges := make([]string, 0, 0)
  14403. return edges
  14404. }
  14405. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14406. // was cleared in this mutation.
  14407. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  14408. return false
  14409. }
  14410. // ClearEdge clears the value of the edge with the given name. It returns an error
  14411. // if that edge is not defined in the schema.
  14412. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  14413. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  14414. }
  14415. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14416. // It returns an error if the edge is not defined in the schema.
  14417. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  14418. return fmt.Errorf("unknown LabelTagging edge %s", name)
  14419. }
  14420. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  14421. type MessageMutation struct {
  14422. config
  14423. op Op
  14424. typ string
  14425. id *int
  14426. wx_wxid *string
  14427. wxid *string
  14428. content *string
  14429. clearedFields map[string]struct{}
  14430. done bool
  14431. oldValue func(context.Context) (*Message, error)
  14432. predicates []predicate.Message
  14433. }
  14434. var _ ent.Mutation = (*MessageMutation)(nil)
  14435. // messageOption allows management of the mutation configuration using functional options.
  14436. type messageOption func(*MessageMutation)
  14437. // newMessageMutation creates new mutation for the Message entity.
  14438. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  14439. m := &MessageMutation{
  14440. config: c,
  14441. op: op,
  14442. typ: TypeMessage,
  14443. clearedFields: make(map[string]struct{}),
  14444. }
  14445. for _, opt := range opts {
  14446. opt(m)
  14447. }
  14448. return m
  14449. }
  14450. // withMessageID sets the ID field of the mutation.
  14451. func withMessageID(id int) messageOption {
  14452. return func(m *MessageMutation) {
  14453. var (
  14454. err error
  14455. once sync.Once
  14456. value *Message
  14457. )
  14458. m.oldValue = func(ctx context.Context) (*Message, error) {
  14459. once.Do(func() {
  14460. if m.done {
  14461. err = errors.New("querying old values post mutation is not allowed")
  14462. } else {
  14463. value, err = m.Client().Message.Get(ctx, id)
  14464. }
  14465. })
  14466. return value, err
  14467. }
  14468. m.id = &id
  14469. }
  14470. }
  14471. // withMessage sets the old Message of the mutation.
  14472. func withMessage(node *Message) messageOption {
  14473. return func(m *MessageMutation) {
  14474. m.oldValue = func(context.Context) (*Message, error) {
  14475. return node, nil
  14476. }
  14477. m.id = &node.ID
  14478. }
  14479. }
  14480. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14481. // executed in a transaction (ent.Tx), a transactional client is returned.
  14482. func (m MessageMutation) Client() *Client {
  14483. client := &Client{config: m.config}
  14484. client.init()
  14485. return client
  14486. }
  14487. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14488. // it returns an error otherwise.
  14489. func (m MessageMutation) Tx() (*Tx, error) {
  14490. if _, ok := m.driver.(*txDriver); !ok {
  14491. return nil, errors.New("ent: mutation is not running in a transaction")
  14492. }
  14493. tx := &Tx{config: m.config}
  14494. tx.init()
  14495. return tx, nil
  14496. }
  14497. // ID returns the ID value in the mutation. Note that the ID is only available
  14498. // if it was provided to the builder or after it was returned from the database.
  14499. func (m *MessageMutation) ID() (id int, exists bool) {
  14500. if m.id == nil {
  14501. return
  14502. }
  14503. return *m.id, true
  14504. }
  14505. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14506. // That means, if the mutation is applied within a transaction with an isolation level such
  14507. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14508. // or updated by the mutation.
  14509. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  14510. switch {
  14511. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14512. id, exists := m.ID()
  14513. if exists {
  14514. return []int{id}, nil
  14515. }
  14516. fallthrough
  14517. case m.op.Is(OpUpdate | OpDelete):
  14518. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  14519. default:
  14520. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14521. }
  14522. }
  14523. // SetWxWxid sets the "wx_wxid" field.
  14524. func (m *MessageMutation) SetWxWxid(s string) {
  14525. m.wx_wxid = &s
  14526. }
  14527. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  14528. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  14529. v := m.wx_wxid
  14530. if v == nil {
  14531. return
  14532. }
  14533. return *v, true
  14534. }
  14535. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  14536. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  14537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14538. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  14539. if !m.op.Is(OpUpdateOne) {
  14540. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  14541. }
  14542. if m.id == nil || m.oldValue == nil {
  14543. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  14544. }
  14545. oldValue, err := m.oldValue(ctx)
  14546. if err != nil {
  14547. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  14548. }
  14549. return oldValue.WxWxid, nil
  14550. }
  14551. // ClearWxWxid clears the value of the "wx_wxid" field.
  14552. func (m *MessageMutation) ClearWxWxid() {
  14553. m.wx_wxid = nil
  14554. m.clearedFields[message.FieldWxWxid] = struct{}{}
  14555. }
  14556. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  14557. func (m *MessageMutation) WxWxidCleared() bool {
  14558. _, ok := m.clearedFields[message.FieldWxWxid]
  14559. return ok
  14560. }
  14561. // ResetWxWxid resets all changes to the "wx_wxid" field.
  14562. func (m *MessageMutation) ResetWxWxid() {
  14563. m.wx_wxid = nil
  14564. delete(m.clearedFields, message.FieldWxWxid)
  14565. }
  14566. // SetWxid sets the "wxid" field.
  14567. func (m *MessageMutation) SetWxid(s string) {
  14568. m.wxid = &s
  14569. }
  14570. // Wxid returns the value of the "wxid" field in the mutation.
  14571. func (m *MessageMutation) Wxid() (r string, exists bool) {
  14572. v := m.wxid
  14573. if v == nil {
  14574. return
  14575. }
  14576. return *v, true
  14577. }
  14578. // OldWxid returns the old "wxid" field's value of the Message entity.
  14579. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  14580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14581. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  14582. if !m.op.Is(OpUpdateOne) {
  14583. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  14584. }
  14585. if m.id == nil || m.oldValue == nil {
  14586. return v, errors.New("OldWxid requires an ID field in the mutation")
  14587. }
  14588. oldValue, err := m.oldValue(ctx)
  14589. if err != nil {
  14590. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  14591. }
  14592. return oldValue.Wxid, nil
  14593. }
  14594. // ResetWxid resets all changes to the "wxid" field.
  14595. func (m *MessageMutation) ResetWxid() {
  14596. m.wxid = nil
  14597. }
  14598. // SetContent sets the "content" field.
  14599. func (m *MessageMutation) SetContent(s string) {
  14600. m.content = &s
  14601. }
  14602. // Content returns the value of the "content" field in the mutation.
  14603. func (m *MessageMutation) Content() (r string, exists bool) {
  14604. v := m.content
  14605. if v == nil {
  14606. return
  14607. }
  14608. return *v, true
  14609. }
  14610. // OldContent returns the old "content" field's value of the Message entity.
  14611. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  14612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14613. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  14614. if !m.op.Is(OpUpdateOne) {
  14615. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  14616. }
  14617. if m.id == nil || m.oldValue == nil {
  14618. return v, errors.New("OldContent requires an ID field in the mutation")
  14619. }
  14620. oldValue, err := m.oldValue(ctx)
  14621. if err != nil {
  14622. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  14623. }
  14624. return oldValue.Content, nil
  14625. }
  14626. // ResetContent resets all changes to the "content" field.
  14627. func (m *MessageMutation) ResetContent() {
  14628. m.content = nil
  14629. }
  14630. // Where appends a list predicates to the MessageMutation builder.
  14631. func (m *MessageMutation) Where(ps ...predicate.Message) {
  14632. m.predicates = append(m.predicates, ps...)
  14633. }
  14634. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  14635. // users can use type-assertion to append predicates that do not depend on any generated package.
  14636. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  14637. p := make([]predicate.Message, len(ps))
  14638. for i := range ps {
  14639. p[i] = ps[i]
  14640. }
  14641. m.Where(p...)
  14642. }
  14643. // Op returns the operation name.
  14644. func (m *MessageMutation) Op() Op {
  14645. return m.op
  14646. }
  14647. // SetOp allows setting the mutation operation.
  14648. func (m *MessageMutation) SetOp(op Op) {
  14649. m.op = op
  14650. }
  14651. // Type returns the node type of this mutation (Message).
  14652. func (m *MessageMutation) Type() string {
  14653. return m.typ
  14654. }
  14655. // Fields returns all fields that were changed during this mutation. Note that in
  14656. // order to get all numeric fields that were incremented/decremented, call
  14657. // AddedFields().
  14658. func (m *MessageMutation) Fields() []string {
  14659. fields := make([]string, 0, 3)
  14660. if m.wx_wxid != nil {
  14661. fields = append(fields, message.FieldWxWxid)
  14662. }
  14663. if m.wxid != nil {
  14664. fields = append(fields, message.FieldWxid)
  14665. }
  14666. if m.content != nil {
  14667. fields = append(fields, message.FieldContent)
  14668. }
  14669. return fields
  14670. }
  14671. // Field returns the value of a field with the given name. The second boolean
  14672. // return value indicates that this field was not set, or was not defined in the
  14673. // schema.
  14674. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  14675. switch name {
  14676. case message.FieldWxWxid:
  14677. return m.WxWxid()
  14678. case message.FieldWxid:
  14679. return m.Wxid()
  14680. case message.FieldContent:
  14681. return m.Content()
  14682. }
  14683. return nil, false
  14684. }
  14685. // OldField returns the old value of the field from the database. An error is
  14686. // returned if the mutation operation is not UpdateOne, or the query to the
  14687. // database failed.
  14688. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14689. switch name {
  14690. case message.FieldWxWxid:
  14691. return m.OldWxWxid(ctx)
  14692. case message.FieldWxid:
  14693. return m.OldWxid(ctx)
  14694. case message.FieldContent:
  14695. return m.OldContent(ctx)
  14696. }
  14697. return nil, fmt.Errorf("unknown Message field %s", name)
  14698. }
  14699. // SetField sets the value of a field with the given name. It returns an error if
  14700. // the field is not defined in the schema, or if the type mismatched the field
  14701. // type.
  14702. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  14703. switch name {
  14704. case message.FieldWxWxid:
  14705. v, ok := value.(string)
  14706. if !ok {
  14707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14708. }
  14709. m.SetWxWxid(v)
  14710. return nil
  14711. case message.FieldWxid:
  14712. v, ok := value.(string)
  14713. if !ok {
  14714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14715. }
  14716. m.SetWxid(v)
  14717. return nil
  14718. case message.FieldContent:
  14719. v, ok := value.(string)
  14720. if !ok {
  14721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14722. }
  14723. m.SetContent(v)
  14724. return nil
  14725. }
  14726. return fmt.Errorf("unknown Message field %s", name)
  14727. }
  14728. // AddedFields returns all numeric fields that were incremented/decremented during
  14729. // this mutation.
  14730. func (m *MessageMutation) AddedFields() []string {
  14731. return nil
  14732. }
  14733. // AddedField returns the numeric value that was incremented/decremented on a field
  14734. // with the given name. The second boolean return value indicates that this field
  14735. // was not set, or was not defined in the schema.
  14736. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  14737. return nil, false
  14738. }
  14739. // AddField adds the value to the field with the given name. It returns an error if
  14740. // the field is not defined in the schema, or if the type mismatched the field
  14741. // type.
  14742. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  14743. switch name {
  14744. }
  14745. return fmt.Errorf("unknown Message numeric field %s", name)
  14746. }
  14747. // ClearedFields returns all nullable fields that were cleared during this
  14748. // mutation.
  14749. func (m *MessageMutation) ClearedFields() []string {
  14750. var fields []string
  14751. if m.FieldCleared(message.FieldWxWxid) {
  14752. fields = append(fields, message.FieldWxWxid)
  14753. }
  14754. return fields
  14755. }
  14756. // FieldCleared returns a boolean indicating if a field with the given name was
  14757. // cleared in this mutation.
  14758. func (m *MessageMutation) FieldCleared(name string) bool {
  14759. _, ok := m.clearedFields[name]
  14760. return ok
  14761. }
  14762. // ClearField clears the value of the field with the given name. It returns an
  14763. // error if the field is not defined in the schema.
  14764. func (m *MessageMutation) ClearField(name string) error {
  14765. switch name {
  14766. case message.FieldWxWxid:
  14767. m.ClearWxWxid()
  14768. return nil
  14769. }
  14770. return fmt.Errorf("unknown Message nullable field %s", name)
  14771. }
  14772. // ResetField resets all changes in the mutation for the field with the given name.
  14773. // It returns an error if the field is not defined in the schema.
  14774. func (m *MessageMutation) ResetField(name string) error {
  14775. switch name {
  14776. case message.FieldWxWxid:
  14777. m.ResetWxWxid()
  14778. return nil
  14779. case message.FieldWxid:
  14780. m.ResetWxid()
  14781. return nil
  14782. case message.FieldContent:
  14783. m.ResetContent()
  14784. return nil
  14785. }
  14786. return fmt.Errorf("unknown Message field %s", name)
  14787. }
  14788. // AddedEdges returns all edge names that were set/added in this mutation.
  14789. func (m *MessageMutation) AddedEdges() []string {
  14790. edges := make([]string, 0, 0)
  14791. return edges
  14792. }
  14793. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14794. // name in this mutation.
  14795. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  14796. return nil
  14797. }
  14798. // RemovedEdges returns all edge names that were removed in this mutation.
  14799. func (m *MessageMutation) RemovedEdges() []string {
  14800. edges := make([]string, 0, 0)
  14801. return edges
  14802. }
  14803. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14804. // the given name in this mutation.
  14805. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  14806. return nil
  14807. }
  14808. // ClearedEdges returns all edge names that were cleared in this mutation.
  14809. func (m *MessageMutation) ClearedEdges() []string {
  14810. edges := make([]string, 0, 0)
  14811. return edges
  14812. }
  14813. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14814. // was cleared in this mutation.
  14815. func (m *MessageMutation) EdgeCleared(name string) bool {
  14816. return false
  14817. }
  14818. // ClearEdge clears the value of the edge with the given name. It returns an error
  14819. // if that edge is not defined in the schema.
  14820. func (m *MessageMutation) ClearEdge(name string) error {
  14821. return fmt.Errorf("unknown Message unique edge %s", name)
  14822. }
  14823. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14824. // It returns an error if the edge is not defined in the schema.
  14825. func (m *MessageMutation) ResetEdge(name string) error {
  14826. return fmt.Errorf("unknown Message edge %s", name)
  14827. }
  14828. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  14829. type MessageRecordsMutation struct {
  14830. config
  14831. op Op
  14832. typ string
  14833. id *uint64
  14834. created_at *time.Time
  14835. updated_at *time.Time
  14836. status *uint8
  14837. addstatus *int8
  14838. bot_wxid *string
  14839. contact_type *int
  14840. addcontact_type *int
  14841. contact_wxid *string
  14842. content_type *int
  14843. addcontent_type *int
  14844. content *string
  14845. meta *custom_types.Meta
  14846. error_detail *string
  14847. send_time *time.Time
  14848. source_type *int
  14849. addsource_type *int
  14850. organization_id *uint64
  14851. addorganization_id *int64
  14852. clearedFields map[string]struct{}
  14853. sop_stage *uint64
  14854. clearedsop_stage bool
  14855. sop_node *uint64
  14856. clearedsop_node bool
  14857. message_contact *uint64
  14858. clearedmessage_contact bool
  14859. done bool
  14860. oldValue func(context.Context) (*MessageRecords, error)
  14861. predicates []predicate.MessageRecords
  14862. }
  14863. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  14864. // messagerecordsOption allows management of the mutation configuration using functional options.
  14865. type messagerecordsOption func(*MessageRecordsMutation)
  14866. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  14867. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  14868. m := &MessageRecordsMutation{
  14869. config: c,
  14870. op: op,
  14871. typ: TypeMessageRecords,
  14872. clearedFields: make(map[string]struct{}),
  14873. }
  14874. for _, opt := range opts {
  14875. opt(m)
  14876. }
  14877. return m
  14878. }
  14879. // withMessageRecordsID sets the ID field of the mutation.
  14880. func withMessageRecordsID(id uint64) messagerecordsOption {
  14881. return func(m *MessageRecordsMutation) {
  14882. var (
  14883. err error
  14884. once sync.Once
  14885. value *MessageRecords
  14886. )
  14887. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  14888. once.Do(func() {
  14889. if m.done {
  14890. err = errors.New("querying old values post mutation is not allowed")
  14891. } else {
  14892. value, err = m.Client().MessageRecords.Get(ctx, id)
  14893. }
  14894. })
  14895. return value, err
  14896. }
  14897. m.id = &id
  14898. }
  14899. }
  14900. // withMessageRecords sets the old MessageRecords of the mutation.
  14901. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  14902. return func(m *MessageRecordsMutation) {
  14903. m.oldValue = func(context.Context) (*MessageRecords, error) {
  14904. return node, nil
  14905. }
  14906. m.id = &node.ID
  14907. }
  14908. }
  14909. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14910. // executed in a transaction (ent.Tx), a transactional client is returned.
  14911. func (m MessageRecordsMutation) Client() *Client {
  14912. client := &Client{config: m.config}
  14913. client.init()
  14914. return client
  14915. }
  14916. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14917. // it returns an error otherwise.
  14918. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  14919. if _, ok := m.driver.(*txDriver); !ok {
  14920. return nil, errors.New("ent: mutation is not running in a transaction")
  14921. }
  14922. tx := &Tx{config: m.config}
  14923. tx.init()
  14924. return tx, nil
  14925. }
  14926. // SetID sets the value of the id field. Note that this
  14927. // operation is only accepted on creation of MessageRecords entities.
  14928. func (m *MessageRecordsMutation) SetID(id uint64) {
  14929. m.id = &id
  14930. }
  14931. // ID returns the ID value in the mutation. Note that the ID is only available
  14932. // if it was provided to the builder or after it was returned from the database.
  14933. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  14934. if m.id == nil {
  14935. return
  14936. }
  14937. return *m.id, true
  14938. }
  14939. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14940. // That means, if the mutation is applied within a transaction with an isolation level such
  14941. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14942. // or updated by the mutation.
  14943. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  14944. switch {
  14945. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14946. id, exists := m.ID()
  14947. if exists {
  14948. return []uint64{id}, nil
  14949. }
  14950. fallthrough
  14951. case m.op.Is(OpUpdate | OpDelete):
  14952. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  14953. default:
  14954. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14955. }
  14956. }
  14957. // SetCreatedAt sets the "created_at" field.
  14958. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  14959. m.created_at = &t
  14960. }
  14961. // CreatedAt returns the value of the "created_at" field in the mutation.
  14962. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  14963. v := m.created_at
  14964. if v == nil {
  14965. return
  14966. }
  14967. return *v, true
  14968. }
  14969. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  14970. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14972. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14973. if !m.op.Is(OpUpdateOne) {
  14974. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14975. }
  14976. if m.id == nil || m.oldValue == nil {
  14977. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14978. }
  14979. oldValue, err := m.oldValue(ctx)
  14980. if err != nil {
  14981. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14982. }
  14983. return oldValue.CreatedAt, nil
  14984. }
  14985. // ResetCreatedAt resets all changes to the "created_at" field.
  14986. func (m *MessageRecordsMutation) ResetCreatedAt() {
  14987. m.created_at = nil
  14988. }
  14989. // SetUpdatedAt sets the "updated_at" field.
  14990. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  14991. m.updated_at = &t
  14992. }
  14993. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14994. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  14995. v := m.updated_at
  14996. if v == nil {
  14997. return
  14998. }
  14999. return *v, true
  15000. }
  15001. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  15002. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15004. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15005. if !m.op.Is(OpUpdateOne) {
  15006. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15007. }
  15008. if m.id == nil || m.oldValue == nil {
  15009. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15010. }
  15011. oldValue, err := m.oldValue(ctx)
  15012. if err != nil {
  15013. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15014. }
  15015. return oldValue.UpdatedAt, nil
  15016. }
  15017. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15018. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  15019. m.updated_at = nil
  15020. }
  15021. // SetStatus sets the "status" field.
  15022. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  15023. m.status = &u
  15024. m.addstatus = nil
  15025. }
  15026. // Status returns the value of the "status" field in the mutation.
  15027. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  15028. v := m.status
  15029. if v == nil {
  15030. return
  15031. }
  15032. return *v, true
  15033. }
  15034. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  15035. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15037. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15038. if !m.op.Is(OpUpdateOne) {
  15039. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15040. }
  15041. if m.id == nil || m.oldValue == nil {
  15042. return v, errors.New("OldStatus requires an ID field in the mutation")
  15043. }
  15044. oldValue, err := m.oldValue(ctx)
  15045. if err != nil {
  15046. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15047. }
  15048. return oldValue.Status, nil
  15049. }
  15050. // AddStatus adds u to the "status" field.
  15051. func (m *MessageRecordsMutation) AddStatus(u int8) {
  15052. if m.addstatus != nil {
  15053. *m.addstatus += u
  15054. } else {
  15055. m.addstatus = &u
  15056. }
  15057. }
  15058. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15059. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  15060. v := m.addstatus
  15061. if v == nil {
  15062. return
  15063. }
  15064. return *v, true
  15065. }
  15066. // ClearStatus clears the value of the "status" field.
  15067. func (m *MessageRecordsMutation) ClearStatus() {
  15068. m.status = nil
  15069. m.addstatus = nil
  15070. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  15071. }
  15072. // StatusCleared returns if the "status" field was cleared in this mutation.
  15073. func (m *MessageRecordsMutation) StatusCleared() bool {
  15074. _, ok := m.clearedFields[messagerecords.FieldStatus]
  15075. return ok
  15076. }
  15077. // ResetStatus resets all changes to the "status" field.
  15078. func (m *MessageRecordsMutation) ResetStatus() {
  15079. m.status = nil
  15080. m.addstatus = nil
  15081. delete(m.clearedFields, messagerecords.FieldStatus)
  15082. }
  15083. // SetBotWxid sets the "bot_wxid" field.
  15084. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  15085. m.bot_wxid = &s
  15086. }
  15087. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  15088. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  15089. v := m.bot_wxid
  15090. if v == nil {
  15091. return
  15092. }
  15093. return *v, true
  15094. }
  15095. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  15096. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15098. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  15099. if !m.op.Is(OpUpdateOne) {
  15100. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  15101. }
  15102. if m.id == nil || m.oldValue == nil {
  15103. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  15104. }
  15105. oldValue, err := m.oldValue(ctx)
  15106. if err != nil {
  15107. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  15108. }
  15109. return oldValue.BotWxid, nil
  15110. }
  15111. // ResetBotWxid resets all changes to the "bot_wxid" field.
  15112. func (m *MessageRecordsMutation) ResetBotWxid() {
  15113. m.bot_wxid = nil
  15114. }
  15115. // SetContactID sets the "contact_id" field.
  15116. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  15117. m.message_contact = &u
  15118. }
  15119. // ContactID returns the value of the "contact_id" field in the mutation.
  15120. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  15121. v := m.message_contact
  15122. if v == nil {
  15123. return
  15124. }
  15125. return *v, true
  15126. }
  15127. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  15128. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15130. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15131. if !m.op.Is(OpUpdateOne) {
  15132. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15133. }
  15134. if m.id == nil || m.oldValue == nil {
  15135. return v, errors.New("OldContactID requires an ID field in the mutation")
  15136. }
  15137. oldValue, err := m.oldValue(ctx)
  15138. if err != nil {
  15139. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  15140. }
  15141. return oldValue.ContactID, nil
  15142. }
  15143. // ClearContactID clears the value of the "contact_id" field.
  15144. func (m *MessageRecordsMutation) ClearContactID() {
  15145. m.message_contact = nil
  15146. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  15147. }
  15148. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  15149. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  15150. _, ok := m.clearedFields[messagerecords.FieldContactID]
  15151. return ok
  15152. }
  15153. // ResetContactID resets all changes to the "contact_id" field.
  15154. func (m *MessageRecordsMutation) ResetContactID() {
  15155. m.message_contact = nil
  15156. delete(m.clearedFields, messagerecords.FieldContactID)
  15157. }
  15158. // SetContactType sets the "contact_type" field.
  15159. func (m *MessageRecordsMutation) SetContactType(i int) {
  15160. m.contact_type = &i
  15161. m.addcontact_type = nil
  15162. }
  15163. // ContactType returns the value of the "contact_type" field in the mutation.
  15164. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  15165. v := m.contact_type
  15166. if v == nil {
  15167. return
  15168. }
  15169. return *v, true
  15170. }
  15171. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  15172. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15174. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  15175. if !m.op.Is(OpUpdateOne) {
  15176. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  15177. }
  15178. if m.id == nil || m.oldValue == nil {
  15179. return v, errors.New("OldContactType requires an ID field in the mutation")
  15180. }
  15181. oldValue, err := m.oldValue(ctx)
  15182. if err != nil {
  15183. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  15184. }
  15185. return oldValue.ContactType, nil
  15186. }
  15187. // AddContactType adds i to the "contact_type" field.
  15188. func (m *MessageRecordsMutation) AddContactType(i int) {
  15189. if m.addcontact_type != nil {
  15190. *m.addcontact_type += i
  15191. } else {
  15192. m.addcontact_type = &i
  15193. }
  15194. }
  15195. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  15196. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  15197. v := m.addcontact_type
  15198. if v == nil {
  15199. return
  15200. }
  15201. return *v, true
  15202. }
  15203. // ResetContactType resets all changes to the "contact_type" field.
  15204. func (m *MessageRecordsMutation) ResetContactType() {
  15205. m.contact_type = nil
  15206. m.addcontact_type = nil
  15207. }
  15208. // SetContactWxid sets the "contact_wxid" field.
  15209. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  15210. m.contact_wxid = &s
  15211. }
  15212. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  15213. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  15214. v := m.contact_wxid
  15215. if v == nil {
  15216. return
  15217. }
  15218. return *v, true
  15219. }
  15220. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  15221. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15223. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  15224. if !m.op.Is(OpUpdateOne) {
  15225. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  15226. }
  15227. if m.id == nil || m.oldValue == nil {
  15228. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  15229. }
  15230. oldValue, err := m.oldValue(ctx)
  15231. if err != nil {
  15232. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  15233. }
  15234. return oldValue.ContactWxid, nil
  15235. }
  15236. // ResetContactWxid resets all changes to the "contact_wxid" field.
  15237. func (m *MessageRecordsMutation) ResetContactWxid() {
  15238. m.contact_wxid = nil
  15239. }
  15240. // SetContentType sets the "content_type" field.
  15241. func (m *MessageRecordsMutation) SetContentType(i int) {
  15242. m.content_type = &i
  15243. m.addcontent_type = nil
  15244. }
  15245. // ContentType returns the value of the "content_type" field in the mutation.
  15246. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  15247. v := m.content_type
  15248. if v == nil {
  15249. return
  15250. }
  15251. return *v, true
  15252. }
  15253. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  15254. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15256. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  15257. if !m.op.Is(OpUpdateOne) {
  15258. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  15259. }
  15260. if m.id == nil || m.oldValue == nil {
  15261. return v, errors.New("OldContentType requires an ID field in the mutation")
  15262. }
  15263. oldValue, err := m.oldValue(ctx)
  15264. if err != nil {
  15265. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  15266. }
  15267. return oldValue.ContentType, nil
  15268. }
  15269. // AddContentType adds i to the "content_type" field.
  15270. func (m *MessageRecordsMutation) AddContentType(i int) {
  15271. if m.addcontent_type != nil {
  15272. *m.addcontent_type += i
  15273. } else {
  15274. m.addcontent_type = &i
  15275. }
  15276. }
  15277. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  15278. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  15279. v := m.addcontent_type
  15280. if v == nil {
  15281. return
  15282. }
  15283. return *v, true
  15284. }
  15285. // ResetContentType resets all changes to the "content_type" field.
  15286. func (m *MessageRecordsMutation) ResetContentType() {
  15287. m.content_type = nil
  15288. m.addcontent_type = nil
  15289. }
  15290. // SetContent sets the "content" field.
  15291. func (m *MessageRecordsMutation) SetContent(s string) {
  15292. m.content = &s
  15293. }
  15294. // Content returns the value of the "content" field in the mutation.
  15295. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  15296. v := m.content
  15297. if v == nil {
  15298. return
  15299. }
  15300. return *v, true
  15301. }
  15302. // OldContent returns the old "content" field's value of the MessageRecords entity.
  15303. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15305. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  15306. if !m.op.Is(OpUpdateOne) {
  15307. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  15308. }
  15309. if m.id == nil || m.oldValue == nil {
  15310. return v, errors.New("OldContent requires an ID field in the mutation")
  15311. }
  15312. oldValue, err := m.oldValue(ctx)
  15313. if err != nil {
  15314. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  15315. }
  15316. return oldValue.Content, nil
  15317. }
  15318. // ResetContent resets all changes to the "content" field.
  15319. func (m *MessageRecordsMutation) ResetContent() {
  15320. m.content = nil
  15321. }
  15322. // SetMeta sets the "meta" field.
  15323. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  15324. m.meta = &ct
  15325. }
  15326. // Meta returns the value of the "meta" field in the mutation.
  15327. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  15328. v := m.meta
  15329. if v == nil {
  15330. return
  15331. }
  15332. return *v, true
  15333. }
  15334. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  15335. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15337. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  15338. if !m.op.Is(OpUpdateOne) {
  15339. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  15340. }
  15341. if m.id == nil || m.oldValue == nil {
  15342. return v, errors.New("OldMeta requires an ID field in the mutation")
  15343. }
  15344. oldValue, err := m.oldValue(ctx)
  15345. if err != nil {
  15346. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  15347. }
  15348. return oldValue.Meta, nil
  15349. }
  15350. // ClearMeta clears the value of the "meta" field.
  15351. func (m *MessageRecordsMutation) ClearMeta() {
  15352. m.meta = nil
  15353. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  15354. }
  15355. // MetaCleared returns if the "meta" field was cleared in this mutation.
  15356. func (m *MessageRecordsMutation) MetaCleared() bool {
  15357. _, ok := m.clearedFields[messagerecords.FieldMeta]
  15358. return ok
  15359. }
  15360. // ResetMeta resets all changes to the "meta" field.
  15361. func (m *MessageRecordsMutation) ResetMeta() {
  15362. m.meta = nil
  15363. delete(m.clearedFields, messagerecords.FieldMeta)
  15364. }
  15365. // SetErrorDetail sets the "error_detail" field.
  15366. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  15367. m.error_detail = &s
  15368. }
  15369. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  15370. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  15371. v := m.error_detail
  15372. if v == nil {
  15373. return
  15374. }
  15375. return *v, true
  15376. }
  15377. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  15378. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15380. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  15381. if !m.op.Is(OpUpdateOne) {
  15382. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  15383. }
  15384. if m.id == nil || m.oldValue == nil {
  15385. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  15386. }
  15387. oldValue, err := m.oldValue(ctx)
  15388. if err != nil {
  15389. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  15390. }
  15391. return oldValue.ErrorDetail, nil
  15392. }
  15393. // ResetErrorDetail resets all changes to the "error_detail" field.
  15394. func (m *MessageRecordsMutation) ResetErrorDetail() {
  15395. m.error_detail = nil
  15396. }
  15397. // SetSendTime sets the "send_time" field.
  15398. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  15399. m.send_time = &t
  15400. }
  15401. // SendTime returns the value of the "send_time" field in the mutation.
  15402. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  15403. v := m.send_time
  15404. if v == nil {
  15405. return
  15406. }
  15407. return *v, true
  15408. }
  15409. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  15410. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15412. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  15413. if !m.op.Is(OpUpdateOne) {
  15414. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  15415. }
  15416. if m.id == nil || m.oldValue == nil {
  15417. return v, errors.New("OldSendTime requires an ID field in the mutation")
  15418. }
  15419. oldValue, err := m.oldValue(ctx)
  15420. if err != nil {
  15421. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  15422. }
  15423. return oldValue.SendTime, nil
  15424. }
  15425. // ClearSendTime clears the value of the "send_time" field.
  15426. func (m *MessageRecordsMutation) ClearSendTime() {
  15427. m.send_time = nil
  15428. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  15429. }
  15430. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  15431. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  15432. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  15433. return ok
  15434. }
  15435. // ResetSendTime resets all changes to the "send_time" field.
  15436. func (m *MessageRecordsMutation) ResetSendTime() {
  15437. m.send_time = nil
  15438. delete(m.clearedFields, messagerecords.FieldSendTime)
  15439. }
  15440. // SetSourceType sets the "source_type" field.
  15441. func (m *MessageRecordsMutation) SetSourceType(i int) {
  15442. m.source_type = &i
  15443. m.addsource_type = nil
  15444. }
  15445. // SourceType returns the value of the "source_type" field in the mutation.
  15446. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  15447. v := m.source_type
  15448. if v == nil {
  15449. return
  15450. }
  15451. return *v, true
  15452. }
  15453. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  15454. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15456. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  15457. if !m.op.Is(OpUpdateOne) {
  15458. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  15459. }
  15460. if m.id == nil || m.oldValue == nil {
  15461. return v, errors.New("OldSourceType requires an ID field in the mutation")
  15462. }
  15463. oldValue, err := m.oldValue(ctx)
  15464. if err != nil {
  15465. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  15466. }
  15467. return oldValue.SourceType, nil
  15468. }
  15469. // AddSourceType adds i to the "source_type" field.
  15470. func (m *MessageRecordsMutation) AddSourceType(i int) {
  15471. if m.addsource_type != nil {
  15472. *m.addsource_type += i
  15473. } else {
  15474. m.addsource_type = &i
  15475. }
  15476. }
  15477. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  15478. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  15479. v := m.addsource_type
  15480. if v == nil {
  15481. return
  15482. }
  15483. return *v, true
  15484. }
  15485. // ResetSourceType resets all changes to the "source_type" field.
  15486. func (m *MessageRecordsMutation) ResetSourceType() {
  15487. m.source_type = nil
  15488. m.addsource_type = nil
  15489. }
  15490. // SetSourceID sets the "source_id" field.
  15491. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  15492. m.sop_stage = &u
  15493. }
  15494. // SourceID returns the value of the "source_id" field in the mutation.
  15495. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  15496. v := m.sop_stage
  15497. if v == nil {
  15498. return
  15499. }
  15500. return *v, true
  15501. }
  15502. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  15503. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15505. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  15506. if !m.op.Is(OpUpdateOne) {
  15507. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  15508. }
  15509. if m.id == nil || m.oldValue == nil {
  15510. return v, errors.New("OldSourceID requires an ID field in the mutation")
  15511. }
  15512. oldValue, err := m.oldValue(ctx)
  15513. if err != nil {
  15514. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  15515. }
  15516. return oldValue.SourceID, nil
  15517. }
  15518. // ClearSourceID clears the value of the "source_id" field.
  15519. func (m *MessageRecordsMutation) ClearSourceID() {
  15520. m.sop_stage = nil
  15521. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  15522. }
  15523. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  15524. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  15525. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  15526. return ok
  15527. }
  15528. // ResetSourceID resets all changes to the "source_id" field.
  15529. func (m *MessageRecordsMutation) ResetSourceID() {
  15530. m.sop_stage = nil
  15531. delete(m.clearedFields, messagerecords.FieldSourceID)
  15532. }
  15533. // SetSubSourceID sets the "sub_source_id" field.
  15534. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  15535. m.sop_node = &u
  15536. }
  15537. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  15538. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  15539. v := m.sop_node
  15540. if v == nil {
  15541. return
  15542. }
  15543. return *v, true
  15544. }
  15545. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  15546. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15548. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  15549. if !m.op.Is(OpUpdateOne) {
  15550. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  15551. }
  15552. if m.id == nil || m.oldValue == nil {
  15553. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  15554. }
  15555. oldValue, err := m.oldValue(ctx)
  15556. if err != nil {
  15557. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  15558. }
  15559. return oldValue.SubSourceID, nil
  15560. }
  15561. // ClearSubSourceID clears the value of the "sub_source_id" field.
  15562. func (m *MessageRecordsMutation) ClearSubSourceID() {
  15563. m.sop_node = nil
  15564. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  15565. }
  15566. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  15567. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  15568. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  15569. return ok
  15570. }
  15571. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  15572. func (m *MessageRecordsMutation) ResetSubSourceID() {
  15573. m.sop_node = nil
  15574. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  15575. }
  15576. // SetOrganizationID sets the "organization_id" field.
  15577. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  15578. m.organization_id = &u
  15579. m.addorganization_id = nil
  15580. }
  15581. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15582. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  15583. v := m.organization_id
  15584. if v == nil {
  15585. return
  15586. }
  15587. return *v, true
  15588. }
  15589. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  15590. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15592. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15593. if !m.op.Is(OpUpdateOne) {
  15594. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15595. }
  15596. if m.id == nil || m.oldValue == nil {
  15597. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15598. }
  15599. oldValue, err := m.oldValue(ctx)
  15600. if err != nil {
  15601. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15602. }
  15603. return oldValue.OrganizationID, nil
  15604. }
  15605. // AddOrganizationID adds u to the "organization_id" field.
  15606. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  15607. if m.addorganization_id != nil {
  15608. *m.addorganization_id += u
  15609. } else {
  15610. m.addorganization_id = &u
  15611. }
  15612. }
  15613. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15614. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  15615. v := m.addorganization_id
  15616. if v == nil {
  15617. return
  15618. }
  15619. return *v, true
  15620. }
  15621. // ClearOrganizationID clears the value of the "organization_id" field.
  15622. func (m *MessageRecordsMutation) ClearOrganizationID() {
  15623. m.organization_id = nil
  15624. m.addorganization_id = nil
  15625. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  15626. }
  15627. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15628. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  15629. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  15630. return ok
  15631. }
  15632. // ResetOrganizationID resets all changes to the "organization_id" field.
  15633. func (m *MessageRecordsMutation) ResetOrganizationID() {
  15634. m.organization_id = nil
  15635. m.addorganization_id = nil
  15636. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  15637. }
  15638. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  15639. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  15640. m.sop_stage = &id
  15641. }
  15642. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  15643. func (m *MessageRecordsMutation) ClearSopStage() {
  15644. m.clearedsop_stage = true
  15645. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  15646. }
  15647. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  15648. func (m *MessageRecordsMutation) SopStageCleared() bool {
  15649. return m.SourceIDCleared() || m.clearedsop_stage
  15650. }
  15651. // SopStageID returns the "sop_stage" edge ID in the mutation.
  15652. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  15653. if m.sop_stage != nil {
  15654. return *m.sop_stage, true
  15655. }
  15656. return
  15657. }
  15658. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  15659. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15660. // SopStageID instead. It exists only for internal usage by the builders.
  15661. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  15662. if id := m.sop_stage; id != nil {
  15663. ids = append(ids, *id)
  15664. }
  15665. return
  15666. }
  15667. // ResetSopStage resets all changes to the "sop_stage" edge.
  15668. func (m *MessageRecordsMutation) ResetSopStage() {
  15669. m.sop_stage = nil
  15670. m.clearedsop_stage = false
  15671. }
  15672. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  15673. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  15674. m.sop_node = &id
  15675. }
  15676. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  15677. func (m *MessageRecordsMutation) ClearSopNode() {
  15678. m.clearedsop_node = true
  15679. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  15680. }
  15681. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  15682. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  15683. return m.SubSourceIDCleared() || m.clearedsop_node
  15684. }
  15685. // SopNodeID returns the "sop_node" edge ID in the mutation.
  15686. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  15687. if m.sop_node != nil {
  15688. return *m.sop_node, true
  15689. }
  15690. return
  15691. }
  15692. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  15693. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15694. // SopNodeID instead. It exists only for internal usage by the builders.
  15695. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  15696. if id := m.sop_node; id != nil {
  15697. ids = append(ids, *id)
  15698. }
  15699. return
  15700. }
  15701. // ResetSopNode resets all changes to the "sop_node" edge.
  15702. func (m *MessageRecordsMutation) ResetSopNode() {
  15703. m.sop_node = nil
  15704. m.clearedsop_node = false
  15705. }
  15706. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  15707. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  15708. m.message_contact = &id
  15709. }
  15710. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  15711. func (m *MessageRecordsMutation) ClearMessageContact() {
  15712. m.clearedmessage_contact = true
  15713. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  15714. }
  15715. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  15716. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  15717. return m.ContactIDCleared() || m.clearedmessage_contact
  15718. }
  15719. // MessageContactID returns the "message_contact" edge ID in the mutation.
  15720. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  15721. if m.message_contact != nil {
  15722. return *m.message_contact, true
  15723. }
  15724. return
  15725. }
  15726. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  15727. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15728. // MessageContactID instead. It exists only for internal usage by the builders.
  15729. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  15730. if id := m.message_contact; id != nil {
  15731. ids = append(ids, *id)
  15732. }
  15733. return
  15734. }
  15735. // ResetMessageContact resets all changes to the "message_contact" edge.
  15736. func (m *MessageRecordsMutation) ResetMessageContact() {
  15737. m.message_contact = nil
  15738. m.clearedmessage_contact = false
  15739. }
  15740. // Where appends a list predicates to the MessageRecordsMutation builder.
  15741. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  15742. m.predicates = append(m.predicates, ps...)
  15743. }
  15744. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  15745. // users can use type-assertion to append predicates that do not depend on any generated package.
  15746. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  15747. p := make([]predicate.MessageRecords, len(ps))
  15748. for i := range ps {
  15749. p[i] = ps[i]
  15750. }
  15751. m.Where(p...)
  15752. }
  15753. // Op returns the operation name.
  15754. func (m *MessageRecordsMutation) Op() Op {
  15755. return m.op
  15756. }
  15757. // SetOp allows setting the mutation operation.
  15758. func (m *MessageRecordsMutation) SetOp(op Op) {
  15759. m.op = op
  15760. }
  15761. // Type returns the node type of this mutation (MessageRecords).
  15762. func (m *MessageRecordsMutation) Type() string {
  15763. return m.typ
  15764. }
  15765. // Fields returns all fields that were changed during this mutation. Note that in
  15766. // order to get all numeric fields that were incremented/decremented, call
  15767. // AddedFields().
  15768. func (m *MessageRecordsMutation) Fields() []string {
  15769. fields := make([]string, 0, 16)
  15770. if m.created_at != nil {
  15771. fields = append(fields, messagerecords.FieldCreatedAt)
  15772. }
  15773. if m.updated_at != nil {
  15774. fields = append(fields, messagerecords.FieldUpdatedAt)
  15775. }
  15776. if m.status != nil {
  15777. fields = append(fields, messagerecords.FieldStatus)
  15778. }
  15779. if m.bot_wxid != nil {
  15780. fields = append(fields, messagerecords.FieldBotWxid)
  15781. }
  15782. if m.message_contact != nil {
  15783. fields = append(fields, messagerecords.FieldContactID)
  15784. }
  15785. if m.contact_type != nil {
  15786. fields = append(fields, messagerecords.FieldContactType)
  15787. }
  15788. if m.contact_wxid != nil {
  15789. fields = append(fields, messagerecords.FieldContactWxid)
  15790. }
  15791. if m.content_type != nil {
  15792. fields = append(fields, messagerecords.FieldContentType)
  15793. }
  15794. if m.content != nil {
  15795. fields = append(fields, messagerecords.FieldContent)
  15796. }
  15797. if m.meta != nil {
  15798. fields = append(fields, messagerecords.FieldMeta)
  15799. }
  15800. if m.error_detail != nil {
  15801. fields = append(fields, messagerecords.FieldErrorDetail)
  15802. }
  15803. if m.send_time != nil {
  15804. fields = append(fields, messagerecords.FieldSendTime)
  15805. }
  15806. if m.source_type != nil {
  15807. fields = append(fields, messagerecords.FieldSourceType)
  15808. }
  15809. if m.sop_stage != nil {
  15810. fields = append(fields, messagerecords.FieldSourceID)
  15811. }
  15812. if m.sop_node != nil {
  15813. fields = append(fields, messagerecords.FieldSubSourceID)
  15814. }
  15815. if m.organization_id != nil {
  15816. fields = append(fields, messagerecords.FieldOrganizationID)
  15817. }
  15818. return fields
  15819. }
  15820. // Field returns the value of a field with the given name. The second boolean
  15821. // return value indicates that this field was not set, or was not defined in the
  15822. // schema.
  15823. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  15824. switch name {
  15825. case messagerecords.FieldCreatedAt:
  15826. return m.CreatedAt()
  15827. case messagerecords.FieldUpdatedAt:
  15828. return m.UpdatedAt()
  15829. case messagerecords.FieldStatus:
  15830. return m.Status()
  15831. case messagerecords.FieldBotWxid:
  15832. return m.BotWxid()
  15833. case messagerecords.FieldContactID:
  15834. return m.ContactID()
  15835. case messagerecords.FieldContactType:
  15836. return m.ContactType()
  15837. case messagerecords.FieldContactWxid:
  15838. return m.ContactWxid()
  15839. case messagerecords.FieldContentType:
  15840. return m.ContentType()
  15841. case messagerecords.FieldContent:
  15842. return m.Content()
  15843. case messagerecords.FieldMeta:
  15844. return m.Meta()
  15845. case messagerecords.FieldErrorDetail:
  15846. return m.ErrorDetail()
  15847. case messagerecords.FieldSendTime:
  15848. return m.SendTime()
  15849. case messagerecords.FieldSourceType:
  15850. return m.SourceType()
  15851. case messagerecords.FieldSourceID:
  15852. return m.SourceID()
  15853. case messagerecords.FieldSubSourceID:
  15854. return m.SubSourceID()
  15855. case messagerecords.FieldOrganizationID:
  15856. return m.OrganizationID()
  15857. }
  15858. return nil, false
  15859. }
  15860. // OldField returns the old value of the field from the database. An error is
  15861. // returned if the mutation operation is not UpdateOne, or the query to the
  15862. // database failed.
  15863. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15864. switch name {
  15865. case messagerecords.FieldCreatedAt:
  15866. return m.OldCreatedAt(ctx)
  15867. case messagerecords.FieldUpdatedAt:
  15868. return m.OldUpdatedAt(ctx)
  15869. case messagerecords.FieldStatus:
  15870. return m.OldStatus(ctx)
  15871. case messagerecords.FieldBotWxid:
  15872. return m.OldBotWxid(ctx)
  15873. case messagerecords.FieldContactID:
  15874. return m.OldContactID(ctx)
  15875. case messagerecords.FieldContactType:
  15876. return m.OldContactType(ctx)
  15877. case messagerecords.FieldContactWxid:
  15878. return m.OldContactWxid(ctx)
  15879. case messagerecords.FieldContentType:
  15880. return m.OldContentType(ctx)
  15881. case messagerecords.FieldContent:
  15882. return m.OldContent(ctx)
  15883. case messagerecords.FieldMeta:
  15884. return m.OldMeta(ctx)
  15885. case messagerecords.FieldErrorDetail:
  15886. return m.OldErrorDetail(ctx)
  15887. case messagerecords.FieldSendTime:
  15888. return m.OldSendTime(ctx)
  15889. case messagerecords.FieldSourceType:
  15890. return m.OldSourceType(ctx)
  15891. case messagerecords.FieldSourceID:
  15892. return m.OldSourceID(ctx)
  15893. case messagerecords.FieldSubSourceID:
  15894. return m.OldSubSourceID(ctx)
  15895. case messagerecords.FieldOrganizationID:
  15896. return m.OldOrganizationID(ctx)
  15897. }
  15898. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  15899. }
  15900. // SetField sets the value of a field with the given name. It returns an error if
  15901. // the field is not defined in the schema, or if the type mismatched the field
  15902. // type.
  15903. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  15904. switch name {
  15905. case messagerecords.FieldCreatedAt:
  15906. v, ok := value.(time.Time)
  15907. if !ok {
  15908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15909. }
  15910. m.SetCreatedAt(v)
  15911. return nil
  15912. case messagerecords.FieldUpdatedAt:
  15913. v, ok := value.(time.Time)
  15914. if !ok {
  15915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15916. }
  15917. m.SetUpdatedAt(v)
  15918. return nil
  15919. case messagerecords.FieldStatus:
  15920. v, ok := value.(uint8)
  15921. if !ok {
  15922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15923. }
  15924. m.SetStatus(v)
  15925. return nil
  15926. case messagerecords.FieldBotWxid:
  15927. v, ok := value.(string)
  15928. if !ok {
  15929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15930. }
  15931. m.SetBotWxid(v)
  15932. return nil
  15933. case messagerecords.FieldContactID:
  15934. v, ok := value.(uint64)
  15935. if !ok {
  15936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15937. }
  15938. m.SetContactID(v)
  15939. return nil
  15940. case messagerecords.FieldContactType:
  15941. v, ok := value.(int)
  15942. if !ok {
  15943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15944. }
  15945. m.SetContactType(v)
  15946. return nil
  15947. case messagerecords.FieldContactWxid:
  15948. v, ok := value.(string)
  15949. if !ok {
  15950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15951. }
  15952. m.SetContactWxid(v)
  15953. return nil
  15954. case messagerecords.FieldContentType:
  15955. v, ok := value.(int)
  15956. if !ok {
  15957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15958. }
  15959. m.SetContentType(v)
  15960. return nil
  15961. case messagerecords.FieldContent:
  15962. v, ok := value.(string)
  15963. if !ok {
  15964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15965. }
  15966. m.SetContent(v)
  15967. return nil
  15968. case messagerecords.FieldMeta:
  15969. v, ok := value.(custom_types.Meta)
  15970. if !ok {
  15971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15972. }
  15973. m.SetMeta(v)
  15974. return nil
  15975. case messagerecords.FieldErrorDetail:
  15976. v, ok := value.(string)
  15977. if !ok {
  15978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15979. }
  15980. m.SetErrorDetail(v)
  15981. return nil
  15982. case messagerecords.FieldSendTime:
  15983. v, ok := value.(time.Time)
  15984. if !ok {
  15985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15986. }
  15987. m.SetSendTime(v)
  15988. return nil
  15989. case messagerecords.FieldSourceType:
  15990. v, ok := value.(int)
  15991. if !ok {
  15992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15993. }
  15994. m.SetSourceType(v)
  15995. return nil
  15996. case messagerecords.FieldSourceID:
  15997. v, ok := value.(uint64)
  15998. if !ok {
  15999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16000. }
  16001. m.SetSourceID(v)
  16002. return nil
  16003. case messagerecords.FieldSubSourceID:
  16004. v, ok := value.(uint64)
  16005. if !ok {
  16006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16007. }
  16008. m.SetSubSourceID(v)
  16009. return nil
  16010. case messagerecords.FieldOrganizationID:
  16011. v, ok := value.(uint64)
  16012. if !ok {
  16013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16014. }
  16015. m.SetOrganizationID(v)
  16016. return nil
  16017. }
  16018. return fmt.Errorf("unknown MessageRecords field %s", name)
  16019. }
  16020. // AddedFields returns all numeric fields that were incremented/decremented during
  16021. // this mutation.
  16022. func (m *MessageRecordsMutation) AddedFields() []string {
  16023. var fields []string
  16024. if m.addstatus != nil {
  16025. fields = append(fields, messagerecords.FieldStatus)
  16026. }
  16027. if m.addcontact_type != nil {
  16028. fields = append(fields, messagerecords.FieldContactType)
  16029. }
  16030. if m.addcontent_type != nil {
  16031. fields = append(fields, messagerecords.FieldContentType)
  16032. }
  16033. if m.addsource_type != nil {
  16034. fields = append(fields, messagerecords.FieldSourceType)
  16035. }
  16036. if m.addorganization_id != nil {
  16037. fields = append(fields, messagerecords.FieldOrganizationID)
  16038. }
  16039. return fields
  16040. }
  16041. // AddedField returns the numeric value that was incremented/decremented on a field
  16042. // with the given name. The second boolean return value indicates that this field
  16043. // was not set, or was not defined in the schema.
  16044. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  16045. switch name {
  16046. case messagerecords.FieldStatus:
  16047. return m.AddedStatus()
  16048. case messagerecords.FieldContactType:
  16049. return m.AddedContactType()
  16050. case messagerecords.FieldContentType:
  16051. return m.AddedContentType()
  16052. case messagerecords.FieldSourceType:
  16053. return m.AddedSourceType()
  16054. case messagerecords.FieldOrganizationID:
  16055. return m.AddedOrganizationID()
  16056. }
  16057. return nil, false
  16058. }
  16059. // AddField adds the value to the field with the given name. It returns an error if
  16060. // the field is not defined in the schema, or if the type mismatched the field
  16061. // type.
  16062. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  16063. switch name {
  16064. case messagerecords.FieldStatus:
  16065. v, ok := value.(int8)
  16066. if !ok {
  16067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16068. }
  16069. m.AddStatus(v)
  16070. return nil
  16071. case messagerecords.FieldContactType:
  16072. v, ok := value.(int)
  16073. if !ok {
  16074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16075. }
  16076. m.AddContactType(v)
  16077. return nil
  16078. case messagerecords.FieldContentType:
  16079. v, ok := value.(int)
  16080. if !ok {
  16081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16082. }
  16083. m.AddContentType(v)
  16084. return nil
  16085. case messagerecords.FieldSourceType:
  16086. v, ok := value.(int)
  16087. if !ok {
  16088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16089. }
  16090. m.AddSourceType(v)
  16091. return nil
  16092. case messagerecords.FieldOrganizationID:
  16093. v, ok := value.(int64)
  16094. if !ok {
  16095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16096. }
  16097. m.AddOrganizationID(v)
  16098. return nil
  16099. }
  16100. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  16101. }
  16102. // ClearedFields returns all nullable fields that were cleared during this
  16103. // mutation.
  16104. func (m *MessageRecordsMutation) ClearedFields() []string {
  16105. var fields []string
  16106. if m.FieldCleared(messagerecords.FieldStatus) {
  16107. fields = append(fields, messagerecords.FieldStatus)
  16108. }
  16109. if m.FieldCleared(messagerecords.FieldContactID) {
  16110. fields = append(fields, messagerecords.FieldContactID)
  16111. }
  16112. if m.FieldCleared(messagerecords.FieldMeta) {
  16113. fields = append(fields, messagerecords.FieldMeta)
  16114. }
  16115. if m.FieldCleared(messagerecords.FieldSendTime) {
  16116. fields = append(fields, messagerecords.FieldSendTime)
  16117. }
  16118. if m.FieldCleared(messagerecords.FieldSourceID) {
  16119. fields = append(fields, messagerecords.FieldSourceID)
  16120. }
  16121. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  16122. fields = append(fields, messagerecords.FieldSubSourceID)
  16123. }
  16124. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  16125. fields = append(fields, messagerecords.FieldOrganizationID)
  16126. }
  16127. return fields
  16128. }
  16129. // FieldCleared returns a boolean indicating if a field with the given name was
  16130. // cleared in this mutation.
  16131. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  16132. _, ok := m.clearedFields[name]
  16133. return ok
  16134. }
  16135. // ClearField clears the value of the field with the given name. It returns an
  16136. // error if the field is not defined in the schema.
  16137. func (m *MessageRecordsMutation) ClearField(name string) error {
  16138. switch name {
  16139. case messagerecords.FieldStatus:
  16140. m.ClearStatus()
  16141. return nil
  16142. case messagerecords.FieldContactID:
  16143. m.ClearContactID()
  16144. return nil
  16145. case messagerecords.FieldMeta:
  16146. m.ClearMeta()
  16147. return nil
  16148. case messagerecords.FieldSendTime:
  16149. m.ClearSendTime()
  16150. return nil
  16151. case messagerecords.FieldSourceID:
  16152. m.ClearSourceID()
  16153. return nil
  16154. case messagerecords.FieldSubSourceID:
  16155. m.ClearSubSourceID()
  16156. return nil
  16157. case messagerecords.FieldOrganizationID:
  16158. m.ClearOrganizationID()
  16159. return nil
  16160. }
  16161. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  16162. }
  16163. // ResetField resets all changes in the mutation for the field with the given name.
  16164. // It returns an error if the field is not defined in the schema.
  16165. func (m *MessageRecordsMutation) ResetField(name string) error {
  16166. switch name {
  16167. case messagerecords.FieldCreatedAt:
  16168. m.ResetCreatedAt()
  16169. return nil
  16170. case messagerecords.FieldUpdatedAt:
  16171. m.ResetUpdatedAt()
  16172. return nil
  16173. case messagerecords.FieldStatus:
  16174. m.ResetStatus()
  16175. return nil
  16176. case messagerecords.FieldBotWxid:
  16177. m.ResetBotWxid()
  16178. return nil
  16179. case messagerecords.FieldContactID:
  16180. m.ResetContactID()
  16181. return nil
  16182. case messagerecords.FieldContactType:
  16183. m.ResetContactType()
  16184. return nil
  16185. case messagerecords.FieldContactWxid:
  16186. m.ResetContactWxid()
  16187. return nil
  16188. case messagerecords.FieldContentType:
  16189. m.ResetContentType()
  16190. return nil
  16191. case messagerecords.FieldContent:
  16192. m.ResetContent()
  16193. return nil
  16194. case messagerecords.FieldMeta:
  16195. m.ResetMeta()
  16196. return nil
  16197. case messagerecords.FieldErrorDetail:
  16198. m.ResetErrorDetail()
  16199. return nil
  16200. case messagerecords.FieldSendTime:
  16201. m.ResetSendTime()
  16202. return nil
  16203. case messagerecords.FieldSourceType:
  16204. m.ResetSourceType()
  16205. return nil
  16206. case messagerecords.FieldSourceID:
  16207. m.ResetSourceID()
  16208. return nil
  16209. case messagerecords.FieldSubSourceID:
  16210. m.ResetSubSourceID()
  16211. return nil
  16212. case messagerecords.FieldOrganizationID:
  16213. m.ResetOrganizationID()
  16214. return nil
  16215. }
  16216. return fmt.Errorf("unknown MessageRecords field %s", name)
  16217. }
  16218. // AddedEdges returns all edge names that were set/added in this mutation.
  16219. func (m *MessageRecordsMutation) AddedEdges() []string {
  16220. edges := make([]string, 0, 3)
  16221. if m.sop_stage != nil {
  16222. edges = append(edges, messagerecords.EdgeSopStage)
  16223. }
  16224. if m.sop_node != nil {
  16225. edges = append(edges, messagerecords.EdgeSopNode)
  16226. }
  16227. if m.message_contact != nil {
  16228. edges = append(edges, messagerecords.EdgeMessageContact)
  16229. }
  16230. return edges
  16231. }
  16232. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16233. // name in this mutation.
  16234. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  16235. switch name {
  16236. case messagerecords.EdgeSopStage:
  16237. if id := m.sop_stage; id != nil {
  16238. return []ent.Value{*id}
  16239. }
  16240. case messagerecords.EdgeSopNode:
  16241. if id := m.sop_node; id != nil {
  16242. return []ent.Value{*id}
  16243. }
  16244. case messagerecords.EdgeMessageContact:
  16245. if id := m.message_contact; id != nil {
  16246. return []ent.Value{*id}
  16247. }
  16248. }
  16249. return nil
  16250. }
  16251. // RemovedEdges returns all edge names that were removed in this mutation.
  16252. func (m *MessageRecordsMutation) RemovedEdges() []string {
  16253. edges := make([]string, 0, 3)
  16254. return edges
  16255. }
  16256. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16257. // the given name in this mutation.
  16258. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  16259. return nil
  16260. }
  16261. // ClearedEdges returns all edge names that were cleared in this mutation.
  16262. func (m *MessageRecordsMutation) ClearedEdges() []string {
  16263. edges := make([]string, 0, 3)
  16264. if m.clearedsop_stage {
  16265. edges = append(edges, messagerecords.EdgeSopStage)
  16266. }
  16267. if m.clearedsop_node {
  16268. edges = append(edges, messagerecords.EdgeSopNode)
  16269. }
  16270. if m.clearedmessage_contact {
  16271. edges = append(edges, messagerecords.EdgeMessageContact)
  16272. }
  16273. return edges
  16274. }
  16275. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16276. // was cleared in this mutation.
  16277. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  16278. switch name {
  16279. case messagerecords.EdgeSopStage:
  16280. return m.clearedsop_stage
  16281. case messagerecords.EdgeSopNode:
  16282. return m.clearedsop_node
  16283. case messagerecords.EdgeMessageContact:
  16284. return m.clearedmessage_contact
  16285. }
  16286. return false
  16287. }
  16288. // ClearEdge clears the value of the edge with the given name. It returns an error
  16289. // if that edge is not defined in the schema.
  16290. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  16291. switch name {
  16292. case messagerecords.EdgeSopStage:
  16293. m.ClearSopStage()
  16294. return nil
  16295. case messagerecords.EdgeSopNode:
  16296. m.ClearSopNode()
  16297. return nil
  16298. case messagerecords.EdgeMessageContact:
  16299. m.ClearMessageContact()
  16300. return nil
  16301. }
  16302. return fmt.Errorf("unknown MessageRecords 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 *MessageRecordsMutation) ResetEdge(name string) error {
  16307. switch name {
  16308. case messagerecords.EdgeSopStage:
  16309. m.ResetSopStage()
  16310. return nil
  16311. case messagerecords.EdgeSopNode:
  16312. m.ResetSopNode()
  16313. return nil
  16314. case messagerecords.EdgeMessageContact:
  16315. m.ResetMessageContact()
  16316. return nil
  16317. }
  16318. return fmt.Errorf("unknown MessageRecords edge %s", name)
  16319. }
  16320. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  16321. type MsgMutation struct {
  16322. config
  16323. op Op
  16324. typ string
  16325. id *uint64
  16326. created_at *time.Time
  16327. updated_at *time.Time
  16328. deleted_at *time.Time
  16329. status *uint8
  16330. addstatus *int8
  16331. fromwxid *string
  16332. toid *string
  16333. msgtype *int32
  16334. addmsgtype *int32
  16335. msg *string
  16336. batch_no *string
  16337. clearedFields map[string]struct{}
  16338. done bool
  16339. oldValue func(context.Context) (*Msg, error)
  16340. predicates []predicate.Msg
  16341. }
  16342. var _ ent.Mutation = (*MsgMutation)(nil)
  16343. // msgOption allows management of the mutation configuration using functional options.
  16344. type msgOption func(*MsgMutation)
  16345. // newMsgMutation creates new mutation for the Msg entity.
  16346. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  16347. m := &MsgMutation{
  16348. config: c,
  16349. op: op,
  16350. typ: TypeMsg,
  16351. clearedFields: make(map[string]struct{}),
  16352. }
  16353. for _, opt := range opts {
  16354. opt(m)
  16355. }
  16356. return m
  16357. }
  16358. // withMsgID sets the ID field of the mutation.
  16359. func withMsgID(id uint64) msgOption {
  16360. return func(m *MsgMutation) {
  16361. var (
  16362. err error
  16363. once sync.Once
  16364. value *Msg
  16365. )
  16366. m.oldValue = func(ctx context.Context) (*Msg, error) {
  16367. once.Do(func() {
  16368. if m.done {
  16369. err = errors.New("querying old values post mutation is not allowed")
  16370. } else {
  16371. value, err = m.Client().Msg.Get(ctx, id)
  16372. }
  16373. })
  16374. return value, err
  16375. }
  16376. m.id = &id
  16377. }
  16378. }
  16379. // withMsg sets the old Msg of the mutation.
  16380. func withMsg(node *Msg) msgOption {
  16381. return func(m *MsgMutation) {
  16382. m.oldValue = func(context.Context) (*Msg, error) {
  16383. return node, nil
  16384. }
  16385. m.id = &node.ID
  16386. }
  16387. }
  16388. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16389. // executed in a transaction (ent.Tx), a transactional client is returned.
  16390. func (m MsgMutation) Client() *Client {
  16391. client := &Client{config: m.config}
  16392. client.init()
  16393. return client
  16394. }
  16395. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16396. // it returns an error otherwise.
  16397. func (m MsgMutation) Tx() (*Tx, error) {
  16398. if _, ok := m.driver.(*txDriver); !ok {
  16399. return nil, errors.New("ent: mutation is not running in a transaction")
  16400. }
  16401. tx := &Tx{config: m.config}
  16402. tx.init()
  16403. return tx, nil
  16404. }
  16405. // SetID sets the value of the id field. Note that this
  16406. // operation is only accepted on creation of Msg entities.
  16407. func (m *MsgMutation) SetID(id uint64) {
  16408. m.id = &id
  16409. }
  16410. // ID returns the ID value in the mutation. Note that the ID is only available
  16411. // if it was provided to the builder or after it was returned from the database.
  16412. func (m *MsgMutation) ID() (id uint64, exists bool) {
  16413. if m.id == nil {
  16414. return
  16415. }
  16416. return *m.id, true
  16417. }
  16418. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16419. // That means, if the mutation is applied within a transaction with an isolation level such
  16420. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16421. // or updated by the mutation.
  16422. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  16423. switch {
  16424. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16425. id, exists := m.ID()
  16426. if exists {
  16427. return []uint64{id}, nil
  16428. }
  16429. fallthrough
  16430. case m.op.Is(OpUpdate | OpDelete):
  16431. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  16432. default:
  16433. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16434. }
  16435. }
  16436. // SetCreatedAt sets the "created_at" field.
  16437. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  16438. m.created_at = &t
  16439. }
  16440. // CreatedAt returns the value of the "created_at" field in the mutation.
  16441. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  16442. v := m.created_at
  16443. if v == nil {
  16444. return
  16445. }
  16446. return *v, true
  16447. }
  16448. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  16449. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16451. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16452. if !m.op.Is(OpUpdateOne) {
  16453. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16454. }
  16455. if m.id == nil || m.oldValue == nil {
  16456. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16457. }
  16458. oldValue, err := m.oldValue(ctx)
  16459. if err != nil {
  16460. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16461. }
  16462. return oldValue.CreatedAt, nil
  16463. }
  16464. // ResetCreatedAt resets all changes to the "created_at" field.
  16465. func (m *MsgMutation) ResetCreatedAt() {
  16466. m.created_at = nil
  16467. }
  16468. // SetUpdatedAt sets the "updated_at" field.
  16469. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  16470. m.updated_at = &t
  16471. }
  16472. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16473. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  16474. v := m.updated_at
  16475. if v == nil {
  16476. return
  16477. }
  16478. return *v, true
  16479. }
  16480. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  16481. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16483. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16484. if !m.op.Is(OpUpdateOne) {
  16485. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16486. }
  16487. if m.id == nil || m.oldValue == nil {
  16488. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16489. }
  16490. oldValue, err := m.oldValue(ctx)
  16491. if err != nil {
  16492. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16493. }
  16494. return oldValue.UpdatedAt, nil
  16495. }
  16496. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16497. func (m *MsgMutation) ResetUpdatedAt() {
  16498. m.updated_at = nil
  16499. }
  16500. // SetDeletedAt sets the "deleted_at" field.
  16501. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  16502. m.deleted_at = &t
  16503. }
  16504. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16505. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  16506. v := m.deleted_at
  16507. if v == nil {
  16508. return
  16509. }
  16510. return *v, true
  16511. }
  16512. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  16513. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16515. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16516. if !m.op.Is(OpUpdateOne) {
  16517. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16518. }
  16519. if m.id == nil || m.oldValue == nil {
  16520. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16521. }
  16522. oldValue, err := m.oldValue(ctx)
  16523. if err != nil {
  16524. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16525. }
  16526. return oldValue.DeletedAt, nil
  16527. }
  16528. // ClearDeletedAt clears the value of the "deleted_at" field.
  16529. func (m *MsgMutation) ClearDeletedAt() {
  16530. m.deleted_at = nil
  16531. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  16532. }
  16533. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16534. func (m *MsgMutation) DeletedAtCleared() bool {
  16535. _, ok := m.clearedFields[msg.FieldDeletedAt]
  16536. return ok
  16537. }
  16538. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16539. func (m *MsgMutation) ResetDeletedAt() {
  16540. m.deleted_at = nil
  16541. delete(m.clearedFields, msg.FieldDeletedAt)
  16542. }
  16543. // SetStatus sets the "status" field.
  16544. func (m *MsgMutation) SetStatus(u uint8) {
  16545. m.status = &u
  16546. m.addstatus = nil
  16547. }
  16548. // Status returns the value of the "status" field in the mutation.
  16549. func (m *MsgMutation) Status() (r uint8, exists bool) {
  16550. v := m.status
  16551. if v == nil {
  16552. return
  16553. }
  16554. return *v, true
  16555. }
  16556. // OldStatus returns the old "status" field's value of the Msg entity.
  16557. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16559. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16560. if !m.op.Is(OpUpdateOne) {
  16561. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16562. }
  16563. if m.id == nil || m.oldValue == nil {
  16564. return v, errors.New("OldStatus requires an ID field in the mutation")
  16565. }
  16566. oldValue, err := m.oldValue(ctx)
  16567. if err != nil {
  16568. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16569. }
  16570. return oldValue.Status, nil
  16571. }
  16572. // AddStatus adds u to the "status" field.
  16573. func (m *MsgMutation) AddStatus(u int8) {
  16574. if m.addstatus != nil {
  16575. *m.addstatus += u
  16576. } else {
  16577. m.addstatus = &u
  16578. }
  16579. }
  16580. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16581. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  16582. v := m.addstatus
  16583. if v == nil {
  16584. return
  16585. }
  16586. return *v, true
  16587. }
  16588. // ClearStatus clears the value of the "status" field.
  16589. func (m *MsgMutation) ClearStatus() {
  16590. m.status = nil
  16591. m.addstatus = nil
  16592. m.clearedFields[msg.FieldStatus] = struct{}{}
  16593. }
  16594. // StatusCleared returns if the "status" field was cleared in this mutation.
  16595. func (m *MsgMutation) StatusCleared() bool {
  16596. _, ok := m.clearedFields[msg.FieldStatus]
  16597. return ok
  16598. }
  16599. // ResetStatus resets all changes to the "status" field.
  16600. func (m *MsgMutation) ResetStatus() {
  16601. m.status = nil
  16602. m.addstatus = nil
  16603. delete(m.clearedFields, msg.FieldStatus)
  16604. }
  16605. // SetFromwxid sets the "fromwxid" field.
  16606. func (m *MsgMutation) SetFromwxid(s string) {
  16607. m.fromwxid = &s
  16608. }
  16609. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  16610. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  16611. v := m.fromwxid
  16612. if v == nil {
  16613. return
  16614. }
  16615. return *v, true
  16616. }
  16617. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  16618. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16620. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  16621. if !m.op.Is(OpUpdateOne) {
  16622. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  16623. }
  16624. if m.id == nil || m.oldValue == nil {
  16625. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  16626. }
  16627. oldValue, err := m.oldValue(ctx)
  16628. if err != nil {
  16629. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  16630. }
  16631. return oldValue.Fromwxid, nil
  16632. }
  16633. // ClearFromwxid clears the value of the "fromwxid" field.
  16634. func (m *MsgMutation) ClearFromwxid() {
  16635. m.fromwxid = nil
  16636. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  16637. }
  16638. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  16639. func (m *MsgMutation) FromwxidCleared() bool {
  16640. _, ok := m.clearedFields[msg.FieldFromwxid]
  16641. return ok
  16642. }
  16643. // ResetFromwxid resets all changes to the "fromwxid" field.
  16644. func (m *MsgMutation) ResetFromwxid() {
  16645. m.fromwxid = nil
  16646. delete(m.clearedFields, msg.FieldFromwxid)
  16647. }
  16648. // SetToid sets the "toid" field.
  16649. func (m *MsgMutation) SetToid(s string) {
  16650. m.toid = &s
  16651. }
  16652. // Toid returns the value of the "toid" field in the mutation.
  16653. func (m *MsgMutation) Toid() (r string, exists bool) {
  16654. v := m.toid
  16655. if v == nil {
  16656. return
  16657. }
  16658. return *v, true
  16659. }
  16660. // OldToid returns the old "toid" field's value of the Msg entity.
  16661. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16663. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  16664. if !m.op.Is(OpUpdateOne) {
  16665. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  16666. }
  16667. if m.id == nil || m.oldValue == nil {
  16668. return v, errors.New("OldToid requires an ID field in the mutation")
  16669. }
  16670. oldValue, err := m.oldValue(ctx)
  16671. if err != nil {
  16672. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  16673. }
  16674. return oldValue.Toid, nil
  16675. }
  16676. // ClearToid clears the value of the "toid" field.
  16677. func (m *MsgMutation) ClearToid() {
  16678. m.toid = nil
  16679. m.clearedFields[msg.FieldToid] = struct{}{}
  16680. }
  16681. // ToidCleared returns if the "toid" field was cleared in this mutation.
  16682. func (m *MsgMutation) ToidCleared() bool {
  16683. _, ok := m.clearedFields[msg.FieldToid]
  16684. return ok
  16685. }
  16686. // ResetToid resets all changes to the "toid" field.
  16687. func (m *MsgMutation) ResetToid() {
  16688. m.toid = nil
  16689. delete(m.clearedFields, msg.FieldToid)
  16690. }
  16691. // SetMsgtype sets the "msgtype" field.
  16692. func (m *MsgMutation) SetMsgtype(i int32) {
  16693. m.msgtype = &i
  16694. m.addmsgtype = nil
  16695. }
  16696. // Msgtype returns the value of the "msgtype" field in the mutation.
  16697. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  16698. v := m.msgtype
  16699. if v == nil {
  16700. return
  16701. }
  16702. return *v, true
  16703. }
  16704. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  16705. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16707. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  16708. if !m.op.Is(OpUpdateOne) {
  16709. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  16710. }
  16711. if m.id == nil || m.oldValue == nil {
  16712. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  16713. }
  16714. oldValue, err := m.oldValue(ctx)
  16715. if err != nil {
  16716. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  16717. }
  16718. return oldValue.Msgtype, nil
  16719. }
  16720. // AddMsgtype adds i to the "msgtype" field.
  16721. func (m *MsgMutation) AddMsgtype(i int32) {
  16722. if m.addmsgtype != nil {
  16723. *m.addmsgtype += i
  16724. } else {
  16725. m.addmsgtype = &i
  16726. }
  16727. }
  16728. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  16729. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  16730. v := m.addmsgtype
  16731. if v == nil {
  16732. return
  16733. }
  16734. return *v, true
  16735. }
  16736. // ClearMsgtype clears the value of the "msgtype" field.
  16737. func (m *MsgMutation) ClearMsgtype() {
  16738. m.msgtype = nil
  16739. m.addmsgtype = nil
  16740. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  16741. }
  16742. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  16743. func (m *MsgMutation) MsgtypeCleared() bool {
  16744. _, ok := m.clearedFields[msg.FieldMsgtype]
  16745. return ok
  16746. }
  16747. // ResetMsgtype resets all changes to the "msgtype" field.
  16748. func (m *MsgMutation) ResetMsgtype() {
  16749. m.msgtype = nil
  16750. m.addmsgtype = nil
  16751. delete(m.clearedFields, msg.FieldMsgtype)
  16752. }
  16753. // SetMsg sets the "msg" field.
  16754. func (m *MsgMutation) SetMsg(s string) {
  16755. m.msg = &s
  16756. }
  16757. // Msg returns the value of the "msg" field in the mutation.
  16758. func (m *MsgMutation) Msg() (r string, exists bool) {
  16759. v := m.msg
  16760. if v == nil {
  16761. return
  16762. }
  16763. return *v, true
  16764. }
  16765. // OldMsg returns the old "msg" field's value of the Msg entity.
  16766. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16768. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  16769. if !m.op.Is(OpUpdateOne) {
  16770. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  16771. }
  16772. if m.id == nil || m.oldValue == nil {
  16773. return v, errors.New("OldMsg requires an ID field in the mutation")
  16774. }
  16775. oldValue, err := m.oldValue(ctx)
  16776. if err != nil {
  16777. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  16778. }
  16779. return oldValue.Msg, nil
  16780. }
  16781. // ClearMsg clears the value of the "msg" field.
  16782. func (m *MsgMutation) ClearMsg() {
  16783. m.msg = nil
  16784. m.clearedFields[msg.FieldMsg] = struct{}{}
  16785. }
  16786. // MsgCleared returns if the "msg" field was cleared in this mutation.
  16787. func (m *MsgMutation) MsgCleared() bool {
  16788. _, ok := m.clearedFields[msg.FieldMsg]
  16789. return ok
  16790. }
  16791. // ResetMsg resets all changes to the "msg" field.
  16792. func (m *MsgMutation) ResetMsg() {
  16793. m.msg = nil
  16794. delete(m.clearedFields, msg.FieldMsg)
  16795. }
  16796. // SetBatchNo sets the "batch_no" field.
  16797. func (m *MsgMutation) SetBatchNo(s string) {
  16798. m.batch_no = &s
  16799. }
  16800. // BatchNo returns the value of the "batch_no" field in the mutation.
  16801. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  16802. v := m.batch_no
  16803. if v == nil {
  16804. return
  16805. }
  16806. return *v, true
  16807. }
  16808. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  16809. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  16810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16811. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  16812. if !m.op.Is(OpUpdateOne) {
  16813. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  16814. }
  16815. if m.id == nil || m.oldValue == nil {
  16816. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  16817. }
  16818. oldValue, err := m.oldValue(ctx)
  16819. if err != nil {
  16820. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  16821. }
  16822. return oldValue.BatchNo, nil
  16823. }
  16824. // ClearBatchNo clears the value of the "batch_no" field.
  16825. func (m *MsgMutation) ClearBatchNo() {
  16826. m.batch_no = nil
  16827. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  16828. }
  16829. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  16830. func (m *MsgMutation) BatchNoCleared() bool {
  16831. _, ok := m.clearedFields[msg.FieldBatchNo]
  16832. return ok
  16833. }
  16834. // ResetBatchNo resets all changes to the "batch_no" field.
  16835. func (m *MsgMutation) ResetBatchNo() {
  16836. m.batch_no = nil
  16837. delete(m.clearedFields, msg.FieldBatchNo)
  16838. }
  16839. // Where appends a list predicates to the MsgMutation builder.
  16840. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  16841. m.predicates = append(m.predicates, ps...)
  16842. }
  16843. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  16844. // users can use type-assertion to append predicates that do not depend on any generated package.
  16845. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  16846. p := make([]predicate.Msg, len(ps))
  16847. for i := range ps {
  16848. p[i] = ps[i]
  16849. }
  16850. m.Where(p...)
  16851. }
  16852. // Op returns the operation name.
  16853. func (m *MsgMutation) Op() Op {
  16854. return m.op
  16855. }
  16856. // SetOp allows setting the mutation operation.
  16857. func (m *MsgMutation) SetOp(op Op) {
  16858. m.op = op
  16859. }
  16860. // Type returns the node type of this mutation (Msg).
  16861. func (m *MsgMutation) Type() string {
  16862. return m.typ
  16863. }
  16864. // Fields returns all fields that were changed during this mutation. Note that in
  16865. // order to get all numeric fields that were incremented/decremented, call
  16866. // AddedFields().
  16867. func (m *MsgMutation) Fields() []string {
  16868. fields := make([]string, 0, 9)
  16869. if m.created_at != nil {
  16870. fields = append(fields, msg.FieldCreatedAt)
  16871. }
  16872. if m.updated_at != nil {
  16873. fields = append(fields, msg.FieldUpdatedAt)
  16874. }
  16875. if m.deleted_at != nil {
  16876. fields = append(fields, msg.FieldDeletedAt)
  16877. }
  16878. if m.status != nil {
  16879. fields = append(fields, msg.FieldStatus)
  16880. }
  16881. if m.fromwxid != nil {
  16882. fields = append(fields, msg.FieldFromwxid)
  16883. }
  16884. if m.toid != nil {
  16885. fields = append(fields, msg.FieldToid)
  16886. }
  16887. if m.msgtype != nil {
  16888. fields = append(fields, msg.FieldMsgtype)
  16889. }
  16890. if m.msg != nil {
  16891. fields = append(fields, msg.FieldMsg)
  16892. }
  16893. if m.batch_no != nil {
  16894. fields = append(fields, msg.FieldBatchNo)
  16895. }
  16896. return fields
  16897. }
  16898. // Field returns the value of a field with the given name. The second boolean
  16899. // return value indicates that this field was not set, or was not defined in the
  16900. // schema.
  16901. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  16902. switch name {
  16903. case msg.FieldCreatedAt:
  16904. return m.CreatedAt()
  16905. case msg.FieldUpdatedAt:
  16906. return m.UpdatedAt()
  16907. case msg.FieldDeletedAt:
  16908. return m.DeletedAt()
  16909. case msg.FieldStatus:
  16910. return m.Status()
  16911. case msg.FieldFromwxid:
  16912. return m.Fromwxid()
  16913. case msg.FieldToid:
  16914. return m.Toid()
  16915. case msg.FieldMsgtype:
  16916. return m.Msgtype()
  16917. case msg.FieldMsg:
  16918. return m.Msg()
  16919. case msg.FieldBatchNo:
  16920. return m.BatchNo()
  16921. }
  16922. return nil, false
  16923. }
  16924. // OldField returns the old value of the field from the database. An error is
  16925. // returned if the mutation operation is not UpdateOne, or the query to the
  16926. // database failed.
  16927. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16928. switch name {
  16929. case msg.FieldCreatedAt:
  16930. return m.OldCreatedAt(ctx)
  16931. case msg.FieldUpdatedAt:
  16932. return m.OldUpdatedAt(ctx)
  16933. case msg.FieldDeletedAt:
  16934. return m.OldDeletedAt(ctx)
  16935. case msg.FieldStatus:
  16936. return m.OldStatus(ctx)
  16937. case msg.FieldFromwxid:
  16938. return m.OldFromwxid(ctx)
  16939. case msg.FieldToid:
  16940. return m.OldToid(ctx)
  16941. case msg.FieldMsgtype:
  16942. return m.OldMsgtype(ctx)
  16943. case msg.FieldMsg:
  16944. return m.OldMsg(ctx)
  16945. case msg.FieldBatchNo:
  16946. return m.OldBatchNo(ctx)
  16947. }
  16948. return nil, fmt.Errorf("unknown Msg field %s", name)
  16949. }
  16950. // SetField sets the value of a field with the given name. It returns an error if
  16951. // the field is not defined in the schema, or if the type mismatched the field
  16952. // type.
  16953. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  16954. switch name {
  16955. case msg.FieldCreatedAt:
  16956. v, ok := value.(time.Time)
  16957. if !ok {
  16958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16959. }
  16960. m.SetCreatedAt(v)
  16961. return nil
  16962. case msg.FieldUpdatedAt:
  16963. v, ok := value.(time.Time)
  16964. if !ok {
  16965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16966. }
  16967. m.SetUpdatedAt(v)
  16968. return nil
  16969. case msg.FieldDeletedAt:
  16970. v, ok := value.(time.Time)
  16971. if !ok {
  16972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16973. }
  16974. m.SetDeletedAt(v)
  16975. return nil
  16976. case msg.FieldStatus:
  16977. v, ok := value.(uint8)
  16978. if !ok {
  16979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16980. }
  16981. m.SetStatus(v)
  16982. return nil
  16983. case msg.FieldFromwxid:
  16984. v, ok := value.(string)
  16985. if !ok {
  16986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16987. }
  16988. m.SetFromwxid(v)
  16989. return nil
  16990. case msg.FieldToid:
  16991. v, ok := value.(string)
  16992. if !ok {
  16993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16994. }
  16995. m.SetToid(v)
  16996. return nil
  16997. case msg.FieldMsgtype:
  16998. v, ok := value.(int32)
  16999. if !ok {
  17000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17001. }
  17002. m.SetMsgtype(v)
  17003. return nil
  17004. case msg.FieldMsg:
  17005. v, ok := value.(string)
  17006. if !ok {
  17007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17008. }
  17009. m.SetMsg(v)
  17010. return nil
  17011. case msg.FieldBatchNo:
  17012. v, ok := value.(string)
  17013. if !ok {
  17014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17015. }
  17016. m.SetBatchNo(v)
  17017. return nil
  17018. }
  17019. return fmt.Errorf("unknown Msg field %s", name)
  17020. }
  17021. // AddedFields returns all numeric fields that were incremented/decremented during
  17022. // this mutation.
  17023. func (m *MsgMutation) AddedFields() []string {
  17024. var fields []string
  17025. if m.addstatus != nil {
  17026. fields = append(fields, msg.FieldStatus)
  17027. }
  17028. if m.addmsgtype != nil {
  17029. fields = append(fields, msg.FieldMsgtype)
  17030. }
  17031. return fields
  17032. }
  17033. // AddedField returns the numeric value that was incremented/decremented on a field
  17034. // with the given name. The second boolean return value indicates that this field
  17035. // was not set, or was not defined in the schema.
  17036. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  17037. switch name {
  17038. case msg.FieldStatus:
  17039. return m.AddedStatus()
  17040. case msg.FieldMsgtype:
  17041. return m.AddedMsgtype()
  17042. }
  17043. return nil, false
  17044. }
  17045. // AddField adds the value to the field with the given name. It returns an error if
  17046. // the field is not defined in the schema, or if the type mismatched the field
  17047. // type.
  17048. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  17049. switch name {
  17050. case msg.FieldStatus:
  17051. v, ok := value.(int8)
  17052. if !ok {
  17053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17054. }
  17055. m.AddStatus(v)
  17056. return nil
  17057. case msg.FieldMsgtype:
  17058. v, ok := value.(int32)
  17059. if !ok {
  17060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17061. }
  17062. m.AddMsgtype(v)
  17063. return nil
  17064. }
  17065. return fmt.Errorf("unknown Msg numeric field %s", name)
  17066. }
  17067. // ClearedFields returns all nullable fields that were cleared during this
  17068. // mutation.
  17069. func (m *MsgMutation) ClearedFields() []string {
  17070. var fields []string
  17071. if m.FieldCleared(msg.FieldDeletedAt) {
  17072. fields = append(fields, msg.FieldDeletedAt)
  17073. }
  17074. if m.FieldCleared(msg.FieldStatus) {
  17075. fields = append(fields, msg.FieldStatus)
  17076. }
  17077. if m.FieldCleared(msg.FieldFromwxid) {
  17078. fields = append(fields, msg.FieldFromwxid)
  17079. }
  17080. if m.FieldCleared(msg.FieldToid) {
  17081. fields = append(fields, msg.FieldToid)
  17082. }
  17083. if m.FieldCleared(msg.FieldMsgtype) {
  17084. fields = append(fields, msg.FieldMsgtype)
  17085. }
  17086. if m.FieldCleared(msg.FieldMsg) {
  17087. fields = append(fields, msg.FieldMsg)
  17088. }
  17089. if m.FieldCleared(msg.FieldBatchNo) {
  17090. fields = append(fields, msg.FieldBatchNo)
  17091. }
  17092. return fields
  17093. }
  17094. // FieldCleared returns a boolean indicating if a field with the given name was
  17095. // cleared in this mutation.
  17096. func (m *MsgMutation) FieldCleared(name string) bool {
  17097. _, ok := m.clearedFields[name]
  17098. return ok
  17099. }
  17100. // ClearField clears the value of the field with the given name. It returns an
  17101. // error if the field is not defined in the schema.
  17102. func (m *MsgMutation) ClearField(name string) error {
  17103. switch name {
  17104. case msg.FieldDeletedAt:
  17105. m.ClearDeletedAt()
  17106. return nil
  17107. case msg.FieldStatus:
  17108. m.ClearStatus()
  17109. return nil
  17110. case msg.FieldFromwxid:
  17111. m.ClearFromwxid()
  17112. return nil
  17113. case msg.FieldToid:
  17114. m.ClearToid()
  17115. return nil
  17116. case msg.FieldMsgtype:
  17117. m.ClearMsgtype()
  17118. return nil
  17119. case msg.FieldMsg:
  17120. m.ClearMsg()
  17121. return nil
  17122. case msg.FieldBatchNo:
  17123. m.ClearBatchNo()
  17124. return nil
  17125. }
  17126. return fmt.Errorf("unknown Msg nullable field %s", name)
  17127. }
  17128. // ResetField resets all changes in the mutation for the field with the given name.
  17129. // It returns an error if the field is not defined in the schema.
  17130. func (m *MsgMutation) ResetField(name string) error {
  17131. switch name {
  17132. case msg.FieldCreatedAt:
  17133. m.ResetCreatedAt()
  17134. return nil
  17135. case msg.FieldUpdatedAt:
  17136. m.ResetUpdatedAt()
  17137. return nil
  17138. case msg.FieldDeletedAt:
  17139. m.ResetDeletedAt()
  17140. return nil
  17141. case msg.FieldStatus:
  17142. m.ResetStatus()
  17143. return nil
  17144. case msg.FieldFromwxid:
  17145. m.ResetFromwxid()
  17146. return nil
  17147. case msg.FieldToid:
  17148. m.ResetToid()
  17149. return nil
  17150. case msg.FieldMsgtype:
  17151. m.ResetMsgtype()
  17152. return nil
  17153. case msg.FieldMsg:
  17154. m.ResetMsg()
  17155. return nil
  17156. case msg.FieldBatchNo:
  17157. m.ResetBatchNo()
  17158. return nil
  17159. }
  17160. return fmt.Errorf("unknown Msg field %s", name)
  17161. }
  17162. // AddedEdges returns all edge names that were set/added in this mutation.
  17163. func (m *MsgMutation) AddedEdges() []string {
  17164. edges := make([]string, 0, 0)
  17165. return edges
  17166. }
  17167. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17168. // name in this mutation.
  17169. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  17170. return nil
  17171. }
  17172. // RemovedEdges returns all edge names that were removed in this mutation.
  17173. func (m *MsgMutation) RemovedEdges() []string {
  17174. edges := make([]string, 0, 0)
  17175. return edges
  17176. }
  17177. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17178. // the given name in this mutation.
  17179. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  17180. return nil
  17181. }
  17182. // ClearedEdges returns all edge names that were cleared in this mutation.
  17183. func (m *MsgMutation) ClearedEdges() []string {
  17184. edges := make([]string, 0, 0)
  17185. return edges
  17186. }
  17187. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17188. // was cleared in this mutation.
  17189. func (m *MsgMutation) EdgeCleared(name string) bool {
  17190. return false
  17191. }
  17192. // ClearEdge clears the value of the edge with the given name. It returns an error
  17193. // if that edge is not defined in the schema.
  17194. func (m *MsgMutation) ClearEdge(name string) error {
  17195. return fmt.Errorf("unknown Msg unique edge %s", name)
  17196. }
  17197. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17198. // It returns an error if the edge is not defined in the schema.
  17199. func (m *MsgMutation) ResetEdge(name string) error {
  17200. return fmt.Errorf("unknown Msg edge %s", name)
  17201. }
  17202. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  17203. type ServerMutation struct {
  17204. config
  17205. op Op
  17206. typ string
  17207. id *uint64
  17208. created_at *time.Time
  17209. updated_at *time.Time
  17210. status *uint8
  17211. addstatus *int8
  17212. deleted_at *time.Time
  17213. name *string
  17214. public_ip *string
  17215. private_ip *string
  17216. admin_port *string
  17217. clearedFields map[string]struct{}
  17218. wxs map[uint64]struct{}
  17219. removedwxs map[uint64]struct{}
  17220. clearedwxs bool
  17221. done bool
  17222. oldValue func(context.Context) (*Server, error)
  17223. predicates []predicate.Server
  17224. }
  17225. var _ ent.Mutation = (*ServerMutation)(nil)
  17226. // serverOption allows management of the mutation configuration using functional options.
  17227. type serverOption func(*ServerMutation)
  17228. // newServerMutation creates new mutation for the Server entity.
  17229. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  17230. m := &ServerMutation{
  17231. config: c,
  17232. op: op,
  17233. typ: TypeServer,
  17234. clearedFields: make(map[string]struct{}),
  17235. }
  17236. for _, opt := range opts {
  17237. opt(m)
  17238. }
  17239. return m
  17240. }
  17241. // withServerID sets the ID field of the mutation.
  17242. func withServerID(id uint64) serverOption {
  17243. return func(m *ServerMutation) {
  17244. var (
  17245. err error
  17246. once sync.Once
  17247. value *Server
  17248. )
  17249. m.oldValue = func(ctx context.Context) (*Server, error) {
  17250. once.Do(func() {
  17251. if m.done {
  17252. err = errors.New("querying old values post mutation is not allowed")
  17253. } else {
  17254. value, err = m.Client().Server.Get(ctx, id)
  17255. }
  17256. })
  17257. return value, err
  17258. }
  17259. m.id = &id
  17260. }
  17261. }
  17262. // withServer sets the old Server of the mutation.
  17263. func withServer(node *Server) serverOption {
  17264. return func(m *ServerMutation) {
  17265. m.oldValue = func(context.Context) (*Server, error) {
  17266. return node, nil
  17267. }
  17268. m.id = &node.ID
  17269. }
  17270. }
  17271. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17272. // executed in a transaction (ent.Tx), a transactional client is returned.
  17273. func (m ServerMutation) Client() *Client {
  17274. client := &Client{config: m.config}
  17275. client.init()
  17276. return client
  17277. }
  17278. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17279. // it returns an error otherwise.
  17280. func (m ServerMutation) Tx() (*Tx, error) {
  17281. if _, ok := m.driver.(*txDriver); !ok {
  17282. return nil, errors.New("ent: mutation is not running in a transaction")
  17283. }
  17284. tx := &Tx{config: m.config}
  17285. tx.init()
  17286. return tx, nil
  17287. }
  17288. // SetID sets the value of the id field. Note that this
  17289. // operation is only accepted on creation of Server entities.
  17290. func (m *ServerMutation) SetID(id uint64) {
  17291. m.id = &id
  17292. }
  17293. // ID returns the ID value in the mutation. Note that the ID is only available
  17294. // if it was provided to the builder or after it was returned from the database.
  17295. func (m *ServerMutation) ID() (id uint64, exists bool) {
  17296. if m.id == nil {
  17297. return
  17298. }
  17299. return *m.id, true
  17300. }
  17301. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17302. // That means, if the mutation is applied within a transaction with an isolation level such
  17303. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17304. // or updated by the mutation.
  17305. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  17306. switch {
  17307. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17308. id, exists := m.ID()
  17309. if exists {
  17310. return []uint64{id}, nil
  17311. }
  17312. fallthrough
  17313. case m.op.Is(OpUpdate | OpDelete):
  17314. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  17315. default:
  17316. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17317. }
  17318. }
  17319. // SetCreatedAt sets the "created_at" field.
  17320. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  17321. m.created_at = &t
  17322. }
  17323. // CreatedAt returns the value of the "created_at" field in the mutation.
  17324. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  17325. v := m.created_at
  17326. if v == nil {
  17327. return
  17328. }
  17329. return *v, true
  17330. }
  17331. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  17332. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17334. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17335. if !m.op.Is(OpUpdateOne) {
  17336. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17337. }
  17338. if m.id == nil || m.oldValue == nil {
  17339. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17340. }
  17341. oldValue, err := m.oldValue(ctx)
  17342. if err != nil {
  17343. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17344. }
  17345. return oldValue.CreatedAt, nil
  17346. }
  17347. // ResetCreatedAt resets all changes to the "created_at" field.
  17348. func (m *ServerMutation) ResetCreatedAt() {
  17349. m.created_at = nil
  17350. }
  17351. // SetUpdatedAt sets the "updated_at" field.
  17352. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  17353. m.updated_at = &t
  17354. }
  17355. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17356. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  17357. v := m.updated_at
  17358. if v == nil {
  17359. return
  17360. }
  17361. return *v, true
  17362. }
  17363. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  17364. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17366. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17367. if !m.op.Is(OpUpdateOne) {
  17368. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17369. }
  17370. if m.id == nil || m.oldValue == nil {
  17371. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17372. }
  17373. oldValue, err := m.oldValue(ctx)
  17374. if err != nil {
  17375. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17376. }
  17377. return oldValue.UpdatedAt, nil
  17378. }
  17379. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17380. func (m *ServerMutation) ResetUpdatedAt() {
  17381. m.updated_at = nil
  17382. }
  17383. // SetStatus sets the "status" field.
  17384. func (m *ServerMutation) SetStatus(u uint8) {
  17385. m.status = &u
  17386. m.addstatus = nil
  17387. }
  17388. // Status returns the value of the "status" field in the mutation.
  17389. func (m *ServerMutation) Status() (r uint8, exists bool) {
  17390. v := m.status
  17391. if v == nil {
  17392. return
  17393. }
  17394. return *v, true
  17395. }
  17396. // OldStatus returns the old "status" field's value of the Server entity.
  17397. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17399. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17400. if !m.op.Is(OpUpdateOne) {
  17401. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17402. }
  17403. if m.id == nil || m.oldValue == nil {
  17404. return v, errors.New("OldStatus requires an ID field in the mutation")
  17405. }
  17406. oldValue, err := m.oldValue(ctx)
  17407. if err != nil {
  17408. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17409. }
  17410. return oldValue.Status, nil
  17411. }
  17412. // AddStatus adds u to the "status" field.
  17413. func (m *ServerMutation) AddStatus(u int8) {
  17414. if m.addstatus != nil {
  17415. *m.addstatus += u
  17416. } else {
  17417. m.addstatus = &u
  17418. }
  17419. }
  17420. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17421. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  17422. v := m.addstatus
  17423. if v == nil {
  17424. return
  17425. }
  17426. return *v, true
  17427. }
  17428. // ClearStatus clears the value of the "status" field.
  17429. func (m *ServerMutation) ClearStatus() {
  17430. m.status = nil
  17431. m.addstatus = nil
  17432. m.clearedFields[server.FieldStatus] = struct{}{}
  17433. }
  17434. // StatusCleared returns if the "status" field was cleared in this mutation.
  17435. func (m *ServerMutation) StatusCleared() bool {
  17436. _, ok := m.clearedFields[server.FieldStatus]
  17437. return ok
  17438. }
  17439. // ResetStatus resets all changes to the "status" field.
  17440. func (m *ServerMutation) ResetStatus() {
  17441. m.status = nil
  17442. m.addstatus = nil
  17443. delete(m.clearedFields, server.FieldStatus)
  17444. }
  17445. // SetDeletedAt sets the "deleted_at" field.
  17446. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  17447. m.deleted_at = &t
  17448. }
  17449. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17450. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  17451. v := m.deleted_at
  17452. if v == nil {
  17453. return
  17454. }
  17455. return *v, true
  17456. }
  17457. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  17458. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17460. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17461. if !m.op.Is(OpUpdateOne) {
  17462. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17463. }
  17464. if m.id == nil || m.oldValue == nil {
  17465. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17466. }
  17467. oldValue, err := m.oldValue(ctx)
  17468. if err != nil {
  17469. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17470. }
  17471. return oldValue.DeletedAt, nil
  17472. }
  17473. // ClearDeletedAt clears the value of the "deleted_at" field.
  17474. func (m *ServerMutation) ClearDeletedAt() {
  17475. m.deleted_at = nil
  17476. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  17477. }
  17478. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17479. func (m *ServerMutation) DeletedAtCleared() bool {
  17480. _, ok := m.clearedFields[server.FieldDeletedAt]
  17481. return ok
  17482. }
  17483. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17484. func (m *ServerMutation) ResetDeletedAt() {
  17485. m.deleted_at = nil
  17486. delete(m.clearedFields, server.FieldDeletedAt)
  17487. }
  17488. // SetName sets the "name" field.
  17489. func (m *ServerMutation) SetName(s string) {
  17490. m.name = &s
  17491. }
  17492. // Name returns the value of the "name" field in the mutation.
  17493. func (m *ServerMutation) Name() (r string, exists bool) {
  17494. v := m.name
  17495. if v == nil {
  17496. return
  17497. }
  17498. return *v, true
  17499. }
  17500. // OldName returns the old "name" field's value of the Server entity.
  17501. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17503. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  17504. if !m.op.Is(OpUpdateOne) {
  17505. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17506. }
  17507. if m.id == nil || m.oldValue == nil {
  17508. return v, errors.New("OldName requires an ID field in the mutation")
  17509. }
  17510. oldValue, err := m.oldValue(ctx)
  17511. if err != nil {
  17512. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17513. }
  17514. return oldValue.Name, nil
  17515. }
  17516. // ResetName resets all changes to the "name" field.
  17517. func (m *ServerMutation) ResetName() {
  17518. m.name = nil
  17519. }
  17520. // SetPublicIP sets the "public_ip" field.
  17521. func (m *ServerMutation) SetPublicIP(s string) {
  17522. m.public_ip = &s
  17523. }
  17524. // PublicIP returns the value of the "public_ip" field in the mutation.
  17525. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  17526. v := m.public_ip
  17527. if v == nil {
  17528. return
  17529. }
  17530. return *v, true
  17531. }
  17532. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  17533. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17535. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  17536. if !m.op.Is(OpUpdateOne) {
  17537. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  17538. }
  17539. if m.id == nil || m.oldValue == nil {
  17540. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  17541. }
  17542. oldValue, err := m.oldValue(ctx)
  17543. if err != nil {
  17544. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  17545. }
  17546. return oldValue.PublicIP, nil
  17547. }
  17548. // ResetPublicIP resets all changes to the "public_ip" field.
  17549. func (m *ServerMutation) ResetPublicIP() {
  17550. m.public_ip = nil
  17551. }
  17552. // SetPrivateIP sets the "private_ip" field.
  17553. func (m *ServerMutation) SetPrivateIP(s string) {
  17554. m.private_ip = &s
  17555. }
  17556. // PrivateIP returns the value of the "private_ip" field in the mutation.
  17557. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  17558. v := m.private_ip
  17559. if v == nil {
  17560. return
  17561. }
  17562. return *v, true
  17563. }
  17564. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  17565. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17567. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  17568. if !m.op.Is(OpUpdateOne) {
  17569. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  17570. }
  17571. if m.id == nil || m.oldValue == nil {
  17572. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  17573. }
  17574. oldValue, err := m.oldValue(ctx)
  17575. if err != nil {
  17576. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  17577. }
  17578. return oldValue.PrivateIP, nil
  17579. }
  17580. // ResetPrivateIP resets all changes to the "private_ip" field.
  17581. func (m *ServerMutation) ResetPrivateIP() {
  17582. m.private_ip = nil
  17583. }
  17584. // SetAdminPort sets the "admin_port" field.
  17585. func (m *ServerMutation) SetAdminPort(s string) {
  17586. m.admin_port = &s
  17587. }
  17588. // AdminPort returns the value of the "admin_port" field in the mutation.
  17589. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  17590. v := m.admin_port
  17591. if v == nil {
  17592. return
  17593. }
  17594. return *v, true
  17595. }
  17596. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  17597. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  17598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17599. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  17600. if !m.op.Is(OpUpdateOne) {
  17601. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  17602. }
  17603. if m.id == nil || m.oldValue == nil {
  17604. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  17605. }
  17606. oldValue, err := m.oldValue(ctx)
  17607. if err != nil {
  17608. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  17609. }
  17610. return oldValue.AdminPort, nil
  17611. }
  17612. // ResetAdminPort resets all changes to the "admin_port" field.
  17613. func (m *ServerMutation) ResetAdminPort() {
  17614. m.admin_port = nil
  17615. }
  17616. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  17617. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  17618. if m.wxs == nil {
  17619. m.wxs = make(map[uint64]struct{})
  17620. }
  17621. for i := range ids {
  17622. m.wxs[ids[i]] = struct{}{}
  17623. }
  17624. }
  17625. // ClearWxs clears the "wxs" edge to the Wx entity.
  17626. func (m *ServerMutation) ClearWxs() {
  17627. m.clearedwxs = true
  17628. }
  17629. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  17630. func (m *ServerMutation) WxsCleared() bool {
  17631. return m.clearedwxs
  17632. }
  17633. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  17634. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  17635. if m.removedwxs == nil {
  17636. m.removedwxs = make(map[uint64]struct{})
  17637. }
  17638. for i := range ids {
  17639. delete(m.wxs, ids[i])
  17640. m.removedwxs[ids[i]] = struct{}{}
  17641. }
  17642. }
  17643. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  17644. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  17645. for id := range m.removedwxs {
  17646. ids = append(ids, id)
  17647. }
  17648. return
  17649. }
  17650. // WxsIDs returns the "wxs" edge IDs in the mutation.
  17651. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  17652. for id := range m.wxs {
  17653. ids = append(ids, id)
  17654. }
  17655. return
  17656. }
  17657. // ResetWxs resets all changes to the "wxs" edge.
  17658. func (m *ServerMutation) ResetWxs() {
  17659. m.wxs = nil
  17660. m.clearedwxs = false
  17661. m.removedwxs = nil
  17662. }
  17663. // Where appends a list predicates to the ServerMutation builder.
  17664. func (m *ServerMutation) Where(ps ...predicate.Server) {
  17665. m.predicates = append(m.predicates, ps...)
  17666. }
  17667. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  17668. // users can use type-assertion to append predicates that do not depend on any generated package.
  17669. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  17670. p := make([]predicate.Server, len(ps))
  17671. for i := range ps {
  17672. p[i] = ps[i]
  17673. }
  17674. m.Where(p...)
  17675. }
  17676. // Op returns the operation name.
  17677. func (m *ServerMutation) Op() Op {
  17678. return m.op
  17679. }
  17680. // SetOp allows setting the mutation operation.
  17681. func (m *ServerMutation) SetOp(op Op) {
  17682. m.op = op
  17683. }
  17684. // Type returns the node type of this mutation (Server).
  17685. func (m *ServerMutation) Type() string {
  17686. return m.typ
  17687. }
  17688. // Fields returns all fields that were changed during this mutation. Note that in
  17689. // order to get all numeric fields that were incremented/decremented, call
  17690. // AddedFields().
  17691. func (m *ServerMutation) Fields() []string {
  17692. fields := make([]string, 0, 8)
  17693. if m.created_at != nil {
  17694. fields = append(fields, server.FieldCreatedAt)
  17695. }
  17696. if m.updated_at != nil {
  17697. fields = append(fields, server.FieldUpdatedAt)
  17698. }
  17699. if m.status != nil {
  17700. fields = append(fields, server.FieldStatus)
  17701. }
  17702. if m.deleted_at != nil {
  17703. fields = append(fields, server.FieldDeletedAt)
  17704. }
  17705. if m.name != nil {
  17706. fields = append(fields, server.FieldName)
  17707. }
  17708. if m.public_ip != nil {
  17709. fields = append(fields, server.FieldPublicIP)
  17710. }
  17711. if m.private_ip != nil {
  17712. fields = append(fields, server.FieldPrivateIP)
  17713. }
  17714. if m.admin_port != nil {
  17715. fields = append(fields, server.FieldAdminPort)
  17716. }
  17717. return fields
  17718. }
  17719. // Field returns the value of a field with the given name. The second boolean
  17720. // return value indicates that this field was not set, or was not defined in the
  17721. // schema.
  17722. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  17723. switch name {
  17724. case server.FieldCreatedAt:
  17725. return m.CreatedAt()
  17726. case server.FieldUpdatedAt:
  17727. return m.UpdatedAt()
  17728. case server.FieldStatus:
  17729. return m.Status()
  17730. case server.FieldDeletedAt:
  17731. return m.DeletedAt()
  17732. case server.FieldName:
  17733. return m.Name()
  17734. case server.FieldPublicIP:
  17735. return m.PublicIP()
  17736. case server.FieldPrivateIP:
  17737. return m.PrivateIP()
  17738. case server.FieldAdminPort:
  17739. return m.AdminPort()
  17740. }
  17741. return nil, false
  17742. }
  17743. // OldField returns the old value of the field from the database. An error is
  17744. // returned if the mutation operation is not UpdateOne, or the query to the
  17745. // database failed.
  17746. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17747. switch name {
  17748. case server.FieldCreatedAt:
  17749. return m.OldCreatedAt(ctx)
  17750. case server.FieldUpdatedAt:
  17751. return m.OldUpdatedAt(ctx)
  17752. case server.FieldStatus:
  17753. return m.OldStatus(ctx)
  17754. case server.FieldDeletedAt:
  17755. return m.OldDeletedAt(ctx)
  17756. case server.FieldName:
  17757. return m.OldName(ctx)
  17758. case server.FieldPublicIP:
  17759. return m.OldPublicIP(ctx)
  17760. case server.FieldPrivateIP:
  17761. return m.OldPrivateIP(ctx)
  17762. case server.FieldAdminPort:
  17763. return m.OldAdminPort(ctx)
  17764. }
  17765. return nil, fmt.Errorf("unknown Server field %s", name)
  17766. }
  17767. // SetField sets the value of a field with the given name. It returns an error if
  17768. // the field is not defined in the schema, or if the type mismatched the field
  17769. // type.
  17770. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  17771. switch name {
  17772. case server.FieldCreatedAt:
  17773. v, ok := value.(time.Time)
  17774. if !ok {
  17775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17776. }
  17777. m.SetCreatedAt(v)
  17778. return nil
  17779. case server.FieldUpdatedAt:
  17780. v, ok := value.(time.Time)
  17781. if !ok {
  17782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17783. }
  17784. m.SetUpdatedAt(v)
  17785. return nil
  17786. case server.FieldStatus:
  17787. v, ok := value.(uint8)
  17788. if !ok {
  17789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17790. }
  17791. m.SetStatus(v)
  17792. return nil
  17793. case server.FieldDeletedAt:
  17794. v, ok := value.(time.Time)
  17795. if !ok {
  17796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17797. }
  17798. m.SetDeletedAt(v)
  17799. return nil
  17800. case server.FieldName:
  17801. v, ok := value.(string)
  17802. if !ok {
  17803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17804. }
  17805. m.SetName(v)
  17806. return nil
  17807. case server.FieldPublicIP:
  17808. v, ok := value.(string)
  17809. if !ok {
  17810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17811. }
  17812. m.SetPublicIP(v)
  17813. return nil
  17814. case server.FieldPrivateIP:
  17815. v, ok := value.(string)
  17816. if !ok {
  17817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17818. }
  17819. m.SetPrivateIP(v)
  17820. return nil
  17821. case server.FieldAdminPort:
  17822. v, ok := value.(string)
  17823. if !ok {
  17824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17825. }
  17826. m.SetAdminPort(v)
  17827. return nil
  17828. }
  17829. return fmt.Errorf("unknown Server field %s", name)
  17830. }
  17831. // AddedFields returns all numeric fields that were incremented/decremented during
  17832. // this mutation.
  17833. func (m *ServerMutation) AddedFields() []string {
  17834. var fields []string
  17835. if m.addstatus != nil {
  17836. fields = append(fields, server.FieldStatus)
  17837. }
  17838. return fields
  17839. }
  17840. // AddedField returns the numeric value that was incremented/decremented on a field
  17841. // with the given name. The second boolean return value indicates that this field
  17842. // was not set, or was not defined in the schema.
  17843. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  17844. switch name {
  17845. case server.FieldStatus:
  17846. return m.AddedStatus()
  17847. }
  17848. return nil, false
  17849. }
  17850. // AddField adds the value to the field with the given name. It returns an error if
  17851. // the field is not defined in the schema, or if the type mismatched the field
  17852. // type.
  17853. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  17854. switch name {
  17855. case server.FieldStatus:
  17856. v, ok := value.(int8)
  17857. if !ok {
  17858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17859. }
  17860. m.AddStatus(v)
  17861. return nil
  17862. }
  17863. return fmt.Errorf("unknown Server numeric field %s", name)
  17864. }
  17865. // ClearedFields returns all nullable fields that were cleared during this
  17866. // mutation.
  17867. func (m *ServerMutation) ClearedFields() []string {
  17868. var fields []string
  17869. if m.FieldCleared(server.FieldStatus) {
  17870. fields = append(fields, server.FieldStatus)
  17871. }
  17872. if m.FieldCleared(server.FieldDeletedAt) {
  17873. fields = append(fields, server.FieldDeletedAt)
  17874. }
  17875. return fields
  17876. }
  17877. // FieldCleared returns a boolean indicating if a field with the given name was
  17878. // cleared in this mutation.
  17879. func (m *ServerMutation) FieldCleared(name string) bool {
  17880. _, ok := m.clearedFields[name]
  17881. return ok
  17882. }
  17883. // ClearField clears the value of the field with the given name. It returns an
  17884. // error if the field is not defined in the schema.
  17885. func (m *ServerMutation) ClearField(name string) error {
  17886. switch name {
  17887. case server.FieldStatus:
  17888. m.ClearStatus()
  17889. return nil
  17890. case server.FieldDeletedAt:
  17891. m.ClearDeletedAt()
  17892. return nil
  17893. }
  17894. return fmt.Errorf("unknown Server nullable field %s", name)
  17895. }
  17896. // ResetField resets all changes in the mutation for the field with the given name.
  17897. // It returns an error if the field is not defined in the schema.
  17898. func (m *ServerMutation) ResetField(name string) error {
  17899. switch name {
  17900. case server.FieldCreatedAt:
  17901. m.ResetCreatedAt()
  17902. return nil
  17903. case server.FieldUpdatedAt:
  17904. m.ResetUpdatedAt()
  17905. return nil
  17906. case server.FieldStatus:
  17907. m.ResetStatus()
  17908. return nil
  17909. case server.FieldDeletedAt:
  17910. m.ResetDeletedAt()
  17911. return nil
  17912. case server.FieldName:
  17913. m.ResetName()
  17914. return nil
  17915. case server.FieldPublicIP:
  17916. m.ResetPublicIP()
  17917. return nil
  17918. case server.FieldPrivateIP:
  17919. m.ResetPrivateIP()
  17920. return nil
  17921. case server.FieldAdminPort:
  17922. m.ResetAdminPort()
  17923. return nil
  17924. }
  17925. return fmt.Errorf("unknown Server field %s", name)
  17926. }
  17927. // AddedEdges returns all edge names that were set/added in this mutation.
  17928. func (m *ServerMutation) AddedEdges() []string {
  17929. edges := make([]string, 0, 1)
  17930. if m.wxs != nil {
  17931. edges = append(edges, server.EdgeWxs)
  17932. }
  17933. return edges
  17934. }
  17935. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17936. // name in this mutation.
  17937. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  17938. switch name {
  17939. case server.EdgeWxs:
  17940. ids := make([]ent.Value, 0, len(m.wxs))
  17941. for id := range m.wxs {
  17942. ids = append(ids, id)
  17943. }
  17944. return ids
  17945. }
  17946. return nil
  17947. }
  17948. // RemovedEdges returns all edge names that were removed in this mutation.
  17949. func (m *ServerMutation) RemovedEdges() []string {
  17950. edges := make([]string, 0, 1)
  17951. if m.removedwxs != nil {
  17952. edges = append(edges, server.EdgeWxs)
  17953. }
  17954. return edges
  17955. }
  17956. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17957. // the given name in this mutation.
  17958. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  17959. switch name {
  17960. case server.EdgeWxs:
  17961. ids := make([]ent.Value, 0, len(m.removedwxs))
  17962. for id := range m.removedwxs {
  17963. ids = append(ids, id)
  17964. }
  17965. return ids
  17966. }
  17967. return nil
  17968. }
  17969. // ClearedEdges returns all edge names that were cleared in this mutation.
  17970. func (m *ServerMutation) ClearedEdges() []string {
  17971. edges := make([]string, 0, 1)
  17972. if m.clearedwxs {
  17973. edges = append(edges, server.EdgeWxs)
  17974. }
  17975. return edges
  17976. }
  17977. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17978. // was cleared in this mutation.
  17979. func (m *ServerMutation) EdgeCleared(name string) bool {
  17980. switch name {
  17981. case server.EdgeWxs:
  17982. return m.clearedwxs
  17983. }
  17984. return false
  17985. }
  17986. // ClearEdge clears the value of the edge with the given name. It returns an error
  17987. // if that edge is not defined in the schema.
  17988. func (m *ServerMutation) ClearEdge(name string) error {
  17989. switch name {
  17990. }
  17991. return fmt.Errorf("unknown Server unique edge %s", name)
  17992. }
  17993. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17994. // It returns an error if the edge is not defined in the schema.
  17995. func (m *ServerMutation) ResetEdge(name string) error {
  17996. switch name {
  17997. case server.EdgeWxs:
  17998. m.ResetWxs()
  17999. return nil
  18000. }
  18001. return fmt.Errorf("unknown Server edge %s", name)
  18002. }
  18003. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  18004. type SopNodeMutation struct {
  18005. config
  18006. op Op
  18007. typ string
  18008. id *uint64
  18009. created_at *time.Time
  18010. updated_at *time.Time
  18011. status *uint8
  18012. addstatus *int8
  18013. deleted_at *time.Time
  18014. parent_id *uint64
  18015. addparent_id *int64
  18016. name *string
  18017. condition_type *int
  18018. addcondition_type *int
  18019. condition_list *[]string
  18020. appendcondition_list []string
  18021. no_reply_condition *uint64
  18022. addno_reply_condition *int64
  18023. no_reply_unit *string
  18024. action_message *[]custom_types.Action
  18025. appendaction_message []custom_types.Action
  18026. action_label_add *[]uint64
  18027. appendaction_label_add []uint64
  18028. action_label_del *[]uint64
  18029. appendaction_label_del []uint64
  18030. action_forward **custom_types.ActionForward
  18031. clearedFields map[string]struct{}
  18032. sop_stage *uint64
  18033. clearedsop_stage bool
  18034. node_messages map[uint64]struct{}
  18035. removednode_messages map[uint64]struct{}
  18036. clearednode_messages bool
  18037. done bool
  18038. oldValue func(context.Context) (*SopNode, error)
  18039. predicates []predicate.SopNode
  18040. }
  18041. var _ ent.Mutation = (*SopNodeMutation)(nil)
  18042. // sopnodeOption allows management of the mutation configuration using functional options.
  18043. type sopnodeOption func(*SopNodeMutation)
  18044. // newSopNodeMutation creates new mutation for the SopNode entity.
  18045. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  18046. m := &SopNodeMutation{
  18047. config: c,
  18048. op: op,
  18049. typ: TypeSopNode,
  18050. clearedFields: make(map[string]struct{}),
  18051. }
  18052. for _, opt := range opts {
  18053. opt(m)
  18054. }
  18055. return m
  18056. }
  18057. // withSopNodeID sets the ID field of the mutation.
  18058. func withSopNodeID(id uint64) sopnodeOption {
  18059. return func(m *SopNodeMutation) {
  18060. var (
  18061. err error
  18062. once sync.Once
  18063. value *SopNode
  18064. )
  18065. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  18066. once.Do(func() {
  18067. if m.done {
  18068. err = errors.New("querying old values post mutation is not allowed")
  18069. } else {
  18070. value, err = m.Client().SopNode.Get(ctx, id)
  18071. }
  18072. })
  18073. return value, err
  18074. }
  18075. m.id = &id
  18076. }
  18077. }
  18078. // withSopNode sets the old SopNode of the mutation.
  18079. func withSopNode(node *SopNode) sopnodeOption {
  18080. return func(m *SopNodeMutation) {
  18081. m.oldValue = func(context.Context) (*SopNode, error) {
  18082. return node, nil
  18083. }
  18084. m.id = &node.ID
  18085. }
  18086. }
  18087. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18088. // executed in a transaction (ent.Tx), a transactional client is returned.
  18089. func (m SopNodeMutation) Client() *Client {
  18090. client := &Client{config: m.config}
  18091. client.init()
  18092. return client
  18093. }
  18094. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18095. // it returns an error otherwise.
  18096. func (m SopNodeMutation) Tx() (*Tx, error) {
  18097. if _, ok := m.driver.(*txDriver); !ok {
  18098. return nil, errors.New("ent: mutation is not running in a transaction")
  18099. }
  18100. tx := &Tx{config: m.config}
  18101. tx.init()
  18102. return tx, nil
  18103. }
  18104. // SetID sets the value of the id field. Note that this
  18105. // operation is only accepted on creation of SopNode entities.
  18106. func (m *SopNodeMutation) SetID(id uint64) {
  18107. m.id = &id
  18108. }
  18109. // ID returns the ID value in the mutation. Note that the ID is only available
  18110. // if it was provided to the builder or after it was returned from the database.
  18111. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  18112. if m.id == nil {
  18113. return
  18114. }
  18115. return *m.id, true
  18116. }
  18117. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18118. // That means, if the mutation is applied within a transaction with an isolation level such
  18119. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18120. // or updated by the mutation.
  18121. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  18122. switch {
  18123. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18124. id, exists := m.ID()
  18125. if exists {
  18126. return []uint64{id}, nil
  18127. }
  18128. fallthrough
  18129. case m.op.Is(OpUpdate | OpDelete):
  18130. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  18131. default:
  18132. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18133. }
  18134. }
  18135. // SetCreatedAt sets the "created_at" field.
  18136. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  18137. m.created_at = &t
  18138. }
  18139. // CreatedAt returns the value of the "created_at" field in the mutation.
  18140. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  18141. v := m.created_at
  18142. if v == nil {
  18143. return
  18144. }
  18145. return *v, true
  18146. }
  18147. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  18148. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18150. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18151. if !m.op.Is(OpUpdateOne) {
  18152. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18153. }
  18154. if m.id == nil || m.oldValue == nil {
  18155. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18156. }
  18157. oldValue, err := m.oldValue(ctx)
  18158. if err != nil {
  18159. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18160. }
  18161. return oldValue.CreatedAt, nil
  18162. }
  18163. // ResetCreatedAt resets all changes to the "created_at" field.
  18164. func (m *SopNodeMutation) ResetCreatedAt() {
  18165. m.created_at = nil
  18166. }
  18167. // SetUpdatedAt sets the "updated_at" field.
  18168. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  18169. m.updated_at = &t
  18170. }
  18171. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18172. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  18173. v := m.updated_at
  18174. if v == nil {
  18175. return
  18176. }
  18177. return *v, true
  18178. }
  18179. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  18180. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18182. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18183. if !m.op.Is(OpUpdateOne) {
  18184. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18185. }
  18186. if m.id == nil || m.oldValue == nil {
  18187. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18188. }
  18189. oldValue, err := m.oldValue(ctx)
  18190. if err != nil {
  18191. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18192. }
  18193. return oldValue.UpdatedAt, nil
  18194. }
  18195. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18196. func (m *SopNodeMutation) ResetUpdatedAt() {
  18197. m.updated_at = nil
  18198. }
  18199. // SetStatus sets the "status" field.
  18200. func (m *SopNodeMutation) SetStatus(u uint8) {
  18201. m.status = &u
  18202. m.addstatus = nil
  18203. }
  18204. // Status returns the value of the "status" field in the mutation.
  18205. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  18206. v := m.status
  18207. if v == nil {
  18208. return
  18209. }
  18210. return *v, true
  18211. }
  18212. // OldStatus returns the old "status" field's value of the SopNode entity.
  18213. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18215. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18216. if !m.op.Is(OpUpdateOne) {
  18217. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18218. }
  18219. if m.id == nil || m.oldValue == nil {
  18220. return v, errors.New("OldStatus requires an ID field in the mutation")
  18221. }
  18222. oldValue, err := m.oldValue(ctx)
  18223. if err != nil {
  18224. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18225. }
  18226. return oldValue.Status, nil
  18227. }
  18228. // AddStatus adds u to the "status" field.
  18229. func (m *SopNodeMutation) AddStatus(u int8) {
  18230. if m.addstatus != nil {
  18231. *m.addstatus += u
  18232. } else {
  18233. m.addstatus = &u
  18234. }
  18235. }
  18236. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18237. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  18238. v := m.addstatus
  18239. if v == nil {
  18240. return
  18241. }
  18242. return *v, true
  18243. }
  18244. // ClearStatus clears the value of the "status" field.
  18245. func (m *SopNodeMutation) ClearStatus() {
  18246. m.status = nil
  18247. m.addstatus = nil
  18248. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  18249. }
  18250. // StatusCleared returns if the "status" field was cleared in this mutation.
  18251. func (m *SopNodeMutation) StatusCleared() bool {
  18252. _, ok := m.clearedFields[sopnode.FieldStatus]
  18253. return ok
  18254. }
  18255. // ResetStatus resets all changes to the "status" field.
  18256. func (m *SopNodeMutation) ResetStatus() {
  18257. m.status = nil
  18258. m.addstatus = nil
  18259. delete(m.clearedFields, sopnode.FieldStatus)
  18260. }
  18261. // SetDeletedAt sets the "deleted_at" field.
  18262. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  18263. m.deleted_at = &t
  18264. }
  18265. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18266. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  18267. v := m.deleted_at
  18268. if v == nil {
  18269. return
  18270. }
  18271. return *v, true
  18272. }
  18273. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  18274. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18276. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18277. if !m.op.Is(OpUpdateOne) {
  18278. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18279. }
  18280. if m.id == nil || m.oldValue == nil {
  18281. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18282. }
  18283. oldValue, err := m.oldValue(ctx)
  18284. if err != nil {
  18285. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18286. }
  18287. return oldValue.DeletedAt, nil
  18288. }
  18289. // ClearDeletedAt clears the value of the "deleted_at" field.
  18290. func (m *SopNodeMutation) ClearDeletedAt() {
  18291. m.deleted_at = nil
  18292. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  18293. }
  18294. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18295. func (m *SopNodeMutation) DeletedAtCleared() bool {
  18296. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  18297. return ok
  18298. }
  18299. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18300. func (m *SopNodeMutation) ResetDeletedAt() {
  18301. m.deleted_at = nil
  18302. delete(m.clearedFields, sopnode.FieldDeletedAt)
  18303. }
  18304. // SetStageID sets the "stage_id" field.
  18305. func (m *SopNodeMutation) SetStageID(u uint64) {
  18306. m.sop_stage = &u
  18307. }
  18308. // StageID returns the value of the "stage_id" field in the mutation.
  18309. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  18310. v := m.sop_stage
  18311. if v == nil {
  18312. return
  18313. }
  18314. return *v, true
  18315. }
  18316. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  18317. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18319. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  18320. if !m.op.Is(OpUpdateOne) {
  18321. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  18322. }
  18323. if m.id == nil || m.oldValue == nil {
  18324. return v, errors.New("OldStageID requires an ID field in the mutation")
  18325. }
  18326. oldValue, err := m.oldValue(ctx)
  18327. if err != nil {
  18328. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  18329. }
  18330. return oldValue.StageID, nil
  18331. }
  18332. // ResetStageID resets all changes to the "stage_id" field.
  18333. func (m *SopNodeMutation) ResetStageID() {
  18334. m.sop_stage = nil
  18335. }
  18336. // SetParentID sets the "parent_id" field.
  18337. func (m *SopNodeMutation) SetParentID(u uint64) {
  18338. m.parent_id = &u
  18339. m.addparent_id = nil
  18340. }
  18341. // ParentID returns the value of the "parent_id" field in the mutation.
  18342. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  18343. v := m.parent_id
  18344. if v == nil {
  18345. return
  18346. }
  18347. return *v, true
  18348. }
  18349. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  18350. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18352. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  18353. if !m.op.Is(OpUpdateOne) {
  18354. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  18355. }
  18356. if m.id == nil || m.oldValue == nil {
  18357. return v, errors.New("OldParentID requires an ID field in the mutation")
  18358. }
  18359. oldValue, err := m.oldValue(ctx)
  18360. if err != nil {
  18361. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  18362. }
  18363. return oldValue.ParentID, nil
  18364. }
  18365. // AddParentID adds u to the "parent_id" field.
  18366. func (m *SopNodeMutation) AddParentID(u int64) {
  18367. if m.addparent_id != nil {
  18368. *m.addparent_id += u
  18369. } else {
  18370. m.addparent_id = &u
  18371. }
  18372. }
  18373. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  18374. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  18375. v := m.addparent_id
  18376. if v == nil {
  18377. return
  18378. }
  18379. return *v, true
  18380. }
  18381. // ResetParentID resets all changes to the "parent_id" field.
  18382. func (m *SopNodeMutation) ResetParentID() {
  18383. m.parent_id = nil
  18384. m.addparent_id = nil
  18385. }
  18386. // SetName sets the "name" field.
  18387. func (m *SopNodeMutation) SetName(s string) {
  18388. m.name = &s
  18389. }
  18390. // Name returns the value of the "name" field in the mutation.
  18391. func (m *SopNodeMutation) Name() (r string, exists bool) {
  18392. v := m.name
  18393. if v == nil {
  18394. return
  18395. }
  18396. return *v, true
  18397. }
  18398. // OldName returns the old "name" field's value of the SopNode entity.
  18399. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18401. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  18402. if !m.op.Is(OpUpdateOne) {
  18403. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18404. }
  18405. if m.id == nil || m.oldValue == nil {
  18406. return v, errors.New("OldName requires an ID field in the mutation")
  18407. }
  18408. oldValue, err := m.oldValue(ctx)
  18409. if err != nil {
  18410. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18411. }
  18412. return oldValue.Name, nil
  18413. }
  18414. // ResetName resets all changes to the "name" field.
  18415. func (m *SopNodeMutation) ResetName() {
  18416. m.name = nil
  18417. }
  18418. // SetConditionType sets the "condition_type" field.
  18419. func (m *SopNodeMutation) SetConditionType(i int) {
  18420. m.condition_type = &i
  18421. m.addcondition_type = nil
  18422. }
  18423. // ConditionType returns the value of the "condition_type" field in the mutation.
  18424. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  18425. v := m.condition_type
  18426. if v == nil {
  18427. return
  18428. }
  18429. return *v, true
  18430. }
  18431. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  18432. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18434. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  18435. if !m.op.Is(OpUpdateOne) {
  18436. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  18437. }
  18438. if m.id == nil || m.oldValue == nil {
  18439. return v, errors.New("OldConditionType requires an ID field in the mutation")
  18440. }
  18441. oldValue, err := m.oldValue(ctx)
  18442. if err != nil {
  18443. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  18444. }
  18445. return oldValue.ConditionType, nil
  18446. }
  18447. // AddConditionType adds i to the "condition_type" field.
  18448. func (m *SopNodeMutation) AddConditionType(i int) {
  18449. if m.addcondition_type != nil {
  18450. *m.addcondition_type += i
  18451. } else {
  18452. m.addcondition_type = &i
  18453. }
  18454. }
  18455. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  18456. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  18457. v := m.addcondition_type
  18458. if v == nil {
  18459. return
  18460. }
  18461. return *v, true
  18462. }
  18463. // ResetConditionType resets all changes to the "condition_type" field.
  18464. func (m *SopNodeMutation) ResetConditionType() {
  18465. m.condition_type = nil
  18466. m.addcondition_type = nil
  18467. }
  18468. // SetConditionList sets the "condition_list" field.
  18469. func (m *SopNodeMutation) SetConditionList(s []string) {
  18470. m.condition_list = &s
  18471. m.appendcondition_list = nil
  18472. }
  18473. // ConditionList returns the value of the "condition_list" field in the mutation.
  18474. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  18475. v := m.condition_list
  18476. if v == nil {
  18477. return
  18478. }
  18479. return *v, true
  18480. }
  18481. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  18482. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18484. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  18485. if !m.op.Is(OpUpdateOne) {
  18486. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  18487. }
  18488. if m.id == nil || m.oldValue == nil {
  18489. return v, errors.New("OldConditionList requires an ID field in the mutation")
  18490. }
  18491. oldValue, err := m.oldValue(ctx)
  18492. if err != nil {
  18493. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  18494. }
  18495. return oldValue.ConditionList, nil
  18496. }
  18497. // AppendConditionList adds s to the "condition_list" field.
  18498. func (m *SopNodeMutation) AppendConditionList(s []string) {
  18499. m.appendcondition_list = append(m.appendcondition_list, s...)
  18500. }
  18501. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  18502. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  18503. if len(m.appendcondition_list) == 0 {
  18504. return nil, false
  18505. }
  18506. return m.appendcondition_list, true
  18507. }
  18508. // ClearConditionList clears the value of the "condition_list" field.
  18509. func (m *SopNodeMutation) ClearConditionList() {
  18510. m.condition_list = nil
  18511. m.appendcondition_list = nil
  18512. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  18513. }
  18514. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  18515. func (m *SopNodeMutation) ConditionListCleared() bool {
  18516. _, ok := m.clearedFields[sopnode.FieldConditionList]
  18517. return ok
  18518. }
  18519. // ResetConditionList resets all changes to the "condition_list" field.
  18520. func (m *SopNodeMutation) ResetConditionList() {
  18521. m.condition_list = nil
  18522. m.appendcondition_list = nil
  18523. delete(m.clearedFields, sopnode.FieldConditionList)
  18524. }
  18525. // SetNoReplyCondition sets the "no_reply_condition" field.
  18526. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  18527. m.no_reply_condition = &u
  18528. m.addno_reply_condition = nil
  18529. }
  18530. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  18531. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  18532. v := m.no_reply_condition
  18533. if v == nil {
  18534. return
  18535. }
  18536. return *v, true
  18537. }
  18538. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  18539. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18541. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  18542. if !m.op.Is(OpUpdateOne) {
  18543. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  18544. }
  18545. if m.id == nil || m.oldValue == nil {
  18546. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  18547. }
  18548. oldValue, err := m.oldValue(ctx)
  18549. if err != nil {
  18550. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  18551. }
  18552. return oldValue.NoReplyCondition, nil
  18553. }
  18554. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  18555. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  18556. if m.addno_reply_condition != nil {
  18557. *m.addno_reply_condition += u
  18558. } else {
  18559. m.addno_reply_condition = &u
  18560. }
  18561. }
  18562. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  18563. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  18564. v := m.addno_reply_condition
  18565. if v == nil {
  18566. return
  18567. }
  18568. return *v, true
  18569. }
  18570. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  18571. func (m *SopNodeMutation) ResetNoReplyCondition() {
  18572. m.no_reply_condition = nil
  18573. m.addno_reply_condition = nil
  18574. }
  18575. // SetNoReplyUnit sets the "no_reply_unit" field.
  18576. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  18577. m.no_reply_unit = &s
  18578. }
  18579. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  18580. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  18581. v := m.no_reply_unit
  18582. if v == nil {
  18583. return
  18584. }
  18585. return *v, true
  18586. }
  18587. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  18588. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18590. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  18591. if !m.op.Is(OpUpdateOne) {
  18592. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  18593. }
  18594. if m.id == nil || m.oldValue == nil {
  18595. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  18596. }
  18597. oldValue, err := m.oldValue(ctx)
  18598. if err != nil {
  18599. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  18600. }
  18601. return oldValue.NoReplyUnit, nil
  18602. }
  18603. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  18604. func (m *SopNodeMutation) ResetNoReplyUnit() {
  18605. m.no_reply_unit = nil
  18606. }
  18607. // SetActionMessage sets the "action_message" field.
  18608. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  18609. m.action_message = &ct
  18610. m.appendaction_message = nil
  18611. }
  18612. // ActionMessage returns the value of the "action_message" field in the mutation.
  18613. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  18614. v := m.action_message
  18615. if v == nil {
  18616. return
  18617. }
  18618. return *v, true
  18619. }
  18620. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  18621. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18623. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  18624. if !m.op.Is(OpUpdateOne) {
  18625. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  18626. }
  18627. if m.id == nil || m.oldValue == nil {
  18628. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  18629. }
  18630. oldValue, err := m.oldValue(ctx)
  18631. if err != nil {
  18632. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  18633. }
  18634. return oldValue.ActionMessage, nil
  18635. }
  18636. // AppendActionMessage adds ct to the "action_message" field.
  18637. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  18638. m.appendaction_message = append(m.appendaction_message, ct...)
  18639. }
  18640. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  18641. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  18642. if len(m.appendaction_message) == 0 {
  18643. return nil, false
  18644. }
  18645. return m.appendaction_message, true
  18646. }
  18647. // ClearActionMessage clears the value of the "action_message" field.
  18648. func (m *SopNodeMutation) ClearActionMessage() {
  18649. m.action_message = nil
  18650. m.appendaction_message = nil
  18651. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  18652. }
  18653. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  18654. func (m *SopNodeMutation) ActionMessageCleared() bool {
  18655. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  18656. return ok
  18657. }
  18658. // ResetActionMessage resets all changes to the "action_message" field.
  18659. func (m *SopNodeMutation) ResetActionMessage() {
  18660. m.action_message = nil
  18661. m.appendaction_message = nil
  18662. delete(m.clearedFields, sopnode.FieldActionMessage)
  18663. }
  18664. // SetActionLabelAdd sets the "action_label_add" field.
  18665. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  18666. m.action_label_add = &u
  18667. m.appendaction_label_add = nil
  18668. }
  18669. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18670. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18671. v := m.action_label_add
  18672. if v == nil {
  18673. return
  18674. }
  18675. return *v, true
  18676. }
  18677. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  18678. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18680. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18681. if !m.op.Is(OpUpdateOne) {
  18682. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18683. }
  18684. if m.id == nil || m.oldValue == nil {
  18685. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18686. }
  18687. oldValue, err := m.oldValue(ctx)
  18688. if err != nil {
  18689. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18690. }
  18691. return oldValue.ActionLabelAdd, nil
  18692. }
  18693. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18694. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  18695. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18696. }
  18697. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18698. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18699. if len(m.appendaction_label_add) == 0 {
  18700. return nil, false
  18701. }
  18702. return m.appendaction_label_add, true
  18703. }
  18704. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18705. func (m *SopNodeMutation) ClearActionLabelAdd() {
  18706. m.action_label_add = nil
  18707. m.appendaction_label_add = nil
  18708. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  18709. }
  18710. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18711. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  18712. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  18713. return ok
  18714. }
  18715. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18716. func (m *SopNodeMutation) ResetActionLabelAdd() {
  18717. m.action_label_add = nil
  18718. m.appendaction_label_add = nil
  18719. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  18720. }
  18721. // SetActionLabelDel sets the "action_label_del" field.
  18722. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  18723. m.action_label_del = &u
  18724. m.appendaction_label_del = nil
  18725. }
  18726. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18727. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  18728. v := m.action_label_del
  18729. if v == nil {
  18730. return
  18731. }
  18732. return *v, true
  18733. }
  18734. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  18735. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18737. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18738. if !m.op.Is(OpUpdateOne) {
  18739. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18740. }
  18741. if m.id == nil || m.oldValue == nil {
  18742. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18743. }
  18744. oldValue, err := m.oldValue(ctx)
  18745. if err != nil {
  18746. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18747. }
  18748. return oldValue.ActionLabelDel, nil
  18749. }
  18750. // AppendActionLabelDel adds u to the "action_label_del" field.
  18751. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  18752. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18753. }
  18754. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18755. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18756. if len(m.appendaction_label_del) == 0 {
  18757. return nil, false
  18758. }
  18759. return m.appendaction_label_del, true
  18760. }
  18761. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18762. func (m *SopNodeMutation) ClearActionLabelDel() {
  18763. m.action_label_del = nil
  18764. m.appendaction_label_del = nil
  18765. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  18766. }
  18767. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18768. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  18769. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  18770. return ok
  18771. }
  18772. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18773. func (m *SopNodeMutation) ResetActionLabelDel() {
  18774. m.action_label_del = nil
  18775. m.appendaction_label_del = nil
  18776. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  18777. }
  18778. // SetActionForward sets the "action_forward" field.
  18779. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  18780. m.action_forward = &ctf
  18781. }
  18782. // ActionForward returns the value of the "action_forward" field in the mutation.
  18783. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  18784. v := m.action_forward
  18785. if v == nil {
  18786. return
  18787. }
  18788. return *v, true
  18789. }
  18790. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  18791. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  18792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18793. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  18794. if !m.op.Is(OpUpdateOne) {
  18795. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  18796. }
  18797. if m.id == nil || m.oldValue == nil {
  18798. return v, errors.New("OldActionForward requires an ID field in the mutation")
  18799. }
  18800. oldValue, err := m.oldValue(ctx)
  18801. if err != nil {
  18802. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  18803. }
  18804. return oldValue.ActionForward, nil
  18805. }
  18806. // ClearActionForward clears the value of the "action_forward" field.
  18807. func (m *SopNodeMutation) ClearActionForward() {
  18808. m.action_forward = nil
  18809. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  18810. }
  18811. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  18812. func (m *SopNodeMutation) ActionForwardCleared() bool {
  18813. _, ok := m.clearedFields[sopnode.FieldActionForward]
  18814. return ok
  18815. }
  18816. // ResetActionForward resets all changes to the "action_forward" field.
  18817. func (m *SopNodeMutation) ResetActionForward() {
  18818. m.action_forward = nil
  18819. delete(m.clearedFields, sopnode.FieldActionForward)
  18820. }
  18821. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18822. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  18823. m.sop_stage = &id
  18824. }
  18825. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18826. func (m *SopNodeMutation) ClearSopStage() {
  18827. m.clearedsop_stage = true
  18828. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  18829. }
  18830. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18831. func (m *SopNodeMutation) SopStageCleared() bool {
  18832. return m.clearedsop_stage
  18833. }
  18834. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18835. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  18836. if m.sop_stage != nil {
  18837. return *m.sop_stage, true
  18838. }
  18839. return
  18840. }
  18841. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18842. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18843. // SopStageID instead. It exists only for internal usage by the builders.
  18844. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  18845. if id := m.sop_stage; id != nil {
  18846. ids = append(ids, *id)
  18847. }
  18848. return
  18849. }
  18850. // ResetSopStage resets all changes to the "sop_stage" edge.
  18851. func (m *SopNodeMutation) ResetSopStage() {
  18852. m.sop_stage = nil
  18853. m.clearedsop_stage = false
  18854. }
  18855. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  18856. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  18857. if m.node_messages == nil {
  18858. m.node_messages = make(map[uint64]struct{})
  18859. }
  18860. for i := range ids {
  18861. m.node_messages[ids[i]] = struct{}{}
  18862. }
  18863. }
  18864. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  18865. func (m *SopNodeMutation) ClearNodeMessages() {
  18866. m.clearednode_messages = true
  18867. }
  18868. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  18869. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  18870. return m.clearednode_messages
  18871. }
  18872. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  18873. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  18874. if m.removednode_messages == nil {
  18875. m.removednode_messages = make(map[uint64]struct{})
  18876. }
  18877. for i := range ids {
  18878. delete(m.node_messages, ids[i])
  18879. m.removednode_messages[ids[i]] = struct{}{}
  18880. }
  18881. }
  18882. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  18883. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  18884. for id := range m.removednode_messages {
  18885. ids = append(ids, id)
  18886. }
  18887. return
  18888. }
  18889. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  18890. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  18891. for id := range m.node_messages {
  18892. ids = append(ids, id)
  18893. }
  18894. return
  18895. }
  18896. // ResetNodeMessages resets all changes to the "node_messages" edge.
  18897. func (m *SopNodeMutation) ResetNodeMessages() {
  18898. m.node_messages = nil
  18899. m.clearednode_messages = false
  18900. m.removednode_messages = nil
  18901. }
  18902. // Where appends a list predicates to the SopNodeMutation builder.
  18903. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  18904. m.predicates = append(m.predicates, ps...)
  18905. }
  18906. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  18907. // users can use type-assertion to append predicates that do not depend on any generated package.
  18908. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  18909. p := make([]predicate.SopNode, len(ps))
  18910. for i := range ps {
  18911. p[i] = ps[i]
  18912. }
  18913. m.Where(p...)
  18914. }
  18915. // Op returns the operation name.
  18916. func (m *SopNodeMutation) Op() Op {
  18917. return m.op
  18918. }
  18919. // SetOp allows setting the mutation operation.
  18920. func (m *SopNodeMutation) SetOp(op Op) {
  18921. m.op = op
  18922. }
  18923. // Type returns the node type of this mutation (SopNode).
  18924. func (m *SopNodeMutation) Type() string {
  18925. return m.typ
  18926. }
  18927. // Fields returns all fields that were changed during this mutation. Note that in
  18928. // order to get all numeric fields that were incremented/decremented, call
  18929. // AddedFields().
  18930. func (m *SopNodeMutation) Fields() []string {
  18931. fields := make([]string, 0, 15)
  18932. if m.created_at != nil {
  18933. fields = append(fields, sopnode.FieldCreatedAt)
  18934. }
  18935. if m.updated_at != nil {
  18936. fields = append(fields, sopnode.FieldUpdatedAt)
  18937. }
  18938. if m.status != nil {
  18939. fields = append(fields, sopnode.FieldStatus)
  18940. }
  18941. if m.deleted_at != nil {
  18942. fields = append(fields, sopnode.FieldDeletedAt)
  18943. }
  18944. if m.sop_stage != nil {
  18945. fields = append(fields, sopnode.FieldStageID)
  18946. }
  18947. if m.parent_id != nil {
  18948. fields = append(fields, sopnode.FieldParentID)
  18949. }
  18950. if m.name != nil {
  18951. fields = append(fields, sopnode.FieldName)
  18952. }
  18953. if m.condition_type != nil {
  18954. fields = append(fields, sopnode.FieldConditionType)
  18955. }
  18956. if m.condition_list != nil {
  18957. fields = append(fields, sopnode.FieldConditionList)
  18958. }
  18959. if m.no_reply_condition != nil {
  18960. fields = append(fields, sopnode.FieldNoReplyCondition)
  18961. }
  18962. if m.no_reply_unit != nil {
  18963. fields = append(fields, sopnode.FieldNoReplyUnit)
  18964. }
  18965. if m.action_message != nil {
  18966. fields = append(fields, sopnode.FieldActionMessage)
  18967. }
  18968. if m.action_label_add != nil {
  18969. fields = append(fields, sopnode.FieldActionLabelAdd)
  18970. }
  18971. if m.action_label_del != nil {
  18972. fields = append(fields, sopnode.FieldActionLabelDel)
  18973. }
  18974. if m.action_forward != nil {
  18975. fields = append(fields, sopnode.FieldActionForward)
  18976. }
  18977. return fields
  18978. }
  18979. // Field returns the value of a field with the given name. The second boolean
  18980. // return value indicates that this field was not set, or was not defined in the
  18981. // schema.
  18982. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  18983. switch name {
  18984. case sopnode.FieldCreatedAt:
  18985. return m.CreatedAt()
  18986. case sopnode.FieldUpdatedAt:
  18987. return m.UpdatedAt()
  18988. case sopnode.FieldStatus:
  18989. return m.Status()
  18990. case sopnode.FieldDeletedAt:
  18991. return m.DeletedAt()
  18992. case sopnode.FieldStageID:
  18993. return m.StageID()
  18994. case sopnode.FieldParentID:
  18995. return m.ParentID()
  18996. case sopnode.FieldName:
  18997. return m.Name()
  18998. case sopnode.FieldConditionType:
  18999. return m.ConditionType()
  19000. case sopnode.FieldConditionList:
  19001. return m.ConditionList()
  19002. case sopnode.FieldNoReplyCondition:
  19003. return m.NoReplyCondition()
  19004. case sopnode.FieldNoReplyUnit:
  19005. return m.NoReplyUnit()
  19006. case sopnode.FieldActionMessage:
  19007. return m.ActionMessage()
  19008. case sopnode.FieldActionLabelAdd:
  19009. return m.ActionLabelAdd()
  19010. case sopnode.FieldActionLabelDel:
  19011. return m.ActionLabelDel()
  19012. case sopnode.FieldActionForward:
  19013. return m.ActionForward()
  19014. }
  19015. return nil, false
  19016. }
  19017. // OldField returns the old value of the field from the database. An error is
  19018. // returned if the mutation operation is not UpdateOne, or the query to the
  19019. // database failed.
  19020. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19021. switch name {
  19022. case sopnode.FieldCreatedAt:
  19023. return m.OldCreatedAt(ctx)
  19024. case sopnode.FieldUpdatedAt:
  19025. return m.OldUpdatedAt(ctx)
  19026. case sopnode.FieldStatus:
  19027. return m.OldStatus(ctx)
  19028. case sopnode.FieldDeletedAt:
  19029. return m.OldDeletedAt(ctx)
  19030. case sopnode.FieldStageID:
  19031. return m.OldStageID(ctx)
  19032. case sopnode.FieldParentID:
  19033. return m.OldParentID(ctx)
  19034. case sopnode.FieldName:
  19035. return m.OldName(ctx)
  19036. case sopnode.FieldConditionType:
  19037. return m.OldConditionType(ctx)
  19038. case sopnode.FieldConditionList:
  19039. return m.OldConditionList(ctx)
  19040. case sopnode.FieldNoReplyCondition:
  19041. return m.OldNoReplyCondition(ctx)
  19042. case sopnode.FieldNoReplyUnit:
  19043. return m.OldNoReplyUnit(ctx)
  19044. case sopnode.FieldActionMessage:
  19045. return m.OldActionMessage(ctx)
  19046. case sopnode.FieldActionLabelAdd:
  19047. return m.OldActionLabelAdd(ctx)
  19048. case sopnode.FieldActionLabelDel:
  19049. return m.OldActionLabelDel(ctx)
  19050. case sopnode.FieldActionForward:
  19051. return m.OldActionForward(ctx)
  19052. }
  19053. return nil, fmt.Errorf("unknown SopNode field %s", name)
  19054. }
  19055. // SetField sets the value of a field with the given name. It returns an error if
  19056. // the field is not defined in the schema, or if the type mismatched the field
  19057. // type.
  19058. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  19059. switch name {
  19060. case sopnode.FieldCreatedAt:
  19061. v, ok := value.(time.Time)
  19062. if !ok {
  19063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19064. }
  19065. m.SetCreatedAt(v)
  19066. return nil
  19067. case sopnode.FieldUpdatedAt:
  19068. v, ok := value.(time.Time)
  19069. if !ok {
  19070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19071. }
  19072. m.SetUpdatedAt(v)
  19073. return nil
  19074. case sopnode.FieldStatus:
  19075. v, ok := value.(uint8)
  19076. if !ok {
  19077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19078. }
  19079. m.SetStatus(v)
  19080. return nil
  19081. case sopnode.FieldDeletedAt:
  19082. v, ok := value.(time.Time)
  19083. if !ok {
  19084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19085. }
  19086. m.SetDeletedAt(v)
  19087. return nil
  19088. case sopnode.FieldStageID:
  19089. v, ok := value.(uint64)
  19090. if !ok {
  19091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19092. }
  19093. m.SetStageID(v)
  19094. return nil
  19095. case sopnode.FieldParentID:
  19096. v, ok := value.(uint64)
  19097. if !ok {
  19098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19099. }
  19100. m.SetParentID(v)
  19101. return nil
  19102. case sopnode.FieldName:
  19103. v, ok := value.(string)
  19104. if !ok {
  19105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19106. }
  19107. m.SetName(v)
  19108. return nil
  19109. case sopnode.FieldConditionType:
  19110. v, ok := value.(int)
  19111. if !ok {
  19112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19113. }
  19114. m.SetConditionType(v)
  19115. return nil
  19116. case sopnode.FieldConditionList:
  19117. v, ok := value.([]string)
  19118. if !ok {
  19119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19120. }
  19121. m.SetConditionList(v)
  19122. return nil
  19123. case sopnode.FieldNoReplyCondition:
  19124. v, ok := value.(uint64)
  19125. if !ok {
  19126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19127. }
  19128. m.SetNoReplyCondition(v)
  19129. return nil
  19130. case sopnode.FieldNoReplyUnit:
  19131. v, ok := value.(string)
  19132. if !ok {
  19133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19134. }
  19135. m.SetNoReplyUnit(v)
  19136. return nil
  19137. case sopnode.FieldActionMessage:
  19138. v, ok := value.([]custom_types.Action)
  19139. if !ok {
  19140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19141. }
  19142. m.SetActionMessage(v)
  19143. return nil
  19144. case sopnode.FieldActionLabelAdd:
  19145. v, ok := value.([]uint64)
  19146. if !ok {
  19147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19148. }
  19149. m.SetActionLabelAdd(v)
  19150. return nil
  19151. case sopnode.FieldActionLabelDel:
  19152. v, ok := value.([]uint64)
  19153. if !ok {
  19154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19155. }
  19156. m.SetActionLabelDel(v)
  19157. return nil
  19158. case sopnode.FieldActionForward:
  19159. v, ok := value.(*custom_types.ActionForward)
  19160. if !ok {
  19161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19162. }
  19163. m.SetActionForward(v)
  19164. return nil
  19165. }
  19166. return fmt.Errorf("unknown SopNode field %s", name)
  19167. }
  19168. // AddedFields returns all numeric fields that were incremented/decremented during
  19169. // this mutation.
  19170. func (m *SopNodeMutation) AddedFields() []string {
  19171. var fields []string
  19172. if m.addstatus != nil {
  19173. fields = append(fields, sopnode.FieldStatus)
  19174. }
  19175. if m.addparent_id != nil {
  19176. fields = append(fields, sopnode.FieldParentID)
  19177. }
  19178. if m.addcondition_type != nil {
  19179. fields = append(fields, sopnode.FieldConditionType)
  19180. }
  19181. if m.addno_reply_condition != nil {
  19182. fields = append(fields, sopnode.FieldNoReplyCondition)
  19183. }
  19184. return fields
  19185. }
  19186. // AddedField returns the numeric value that was incremented/decremented on a field
  19187. // with the given name. The second boolean return value indicates that this field
  19188. // was not set, or was not defined in the schema.
  19189. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  19190. switch name {
  19191. case sopnode.FieldStatus:
  19192. return m.AddedStatus()
  19193. case sopnode.FieldParentID:
  19194. return m.AddedParentID()
  19195. case sopnode.FieldConditionType:
  19196. return m.AddedConditionType()
  19197. case sopnode.FieldNoReplyCondition:
  19198. return m.AddedNoReplyCondition()
  19199. }
  19200. return nil, false
  19201. }
  19202. // AddField adds the value to the field with the given name. It returns an error if
  19203. // the field is not defined in the schema, or if the type mismatched the field
  19204. // type.
  19205. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  19206. switch name {
  19207. case sopnode.FieldStatus:
  19208. v, ok := value.(int8)
  19209. if !ok {
  19210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19211. }
  19212. m.AddStatus(v)
  19213. return nil
  19214. case sopnode.FieldParentID:
  19215. v, ok := value.(int64)
  19216. if !ok {
  19217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19218. }
  19219. m.AddParentID(v)
  19220. return nil
  19221. case sopnode.FieldConditionType:
  19222. v, ok := value.(int)
  19223. if !ok {
  19224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19225. }
  19226. m.AddConditionType(v)
  19227. return nil
  19228. case sopnode.FieldNoReplyCondition:
  19229. v, ok := value.(int64)
  19230. if !ok {
  19231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19232. }
  19233. m.AddNoReplyCondition(v)
  19234. return nil
  19235. }
  19236. return fmt.Errorf("unknown SopNode numeric field %s", name)
  19237. }
  19238. // ClearedFields returns all nullable fields that were cleared during this
  19239. // mutation.
  19240. func (m *SopNodeMutation) ClearedFields() []string {
  19241. var fields []string
  19242. if m.FieldCleared(sopnode.FieldStatus) {
  19243. fields = append(fields, sopnode.FieldStatus)
  19244. }
  19245. if m.FieldCleared(sopnode.FieldDeletedAt) {
  19246. fields = append(fields, sopnode.FieldDeletedAt)
  19247. }
  19248. if m.FieldCleared(sopnode.FieldConditionList) {
  19249. fields = append(fields, sopnode.FieldConditionList)
  19250. }
  19251. if m.FieldCleared(sopnode.FieldActionMessage) {
  19252. fields = append(fields, sopnode.FieldActionMessage)
  19253. }
  19254. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  19255. fields = append(fields, sopnode.FieldActionLabelAdd)
  19256. }
  19257. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  19258. fields = append(fields, sopnode.FieldActionLabelDel)
  19259. }
  19260. if m.FieldCleared(sopnode.FieldActionForward) {
  19261. fields = append(fields, sopnode.FieldActionForward)
  19262. }
  19263. return fields
  19264. }
  19265. // FieldCleared returns a boolean indicating if a field with the given name was
  19266. // cleared in this mutation.
  19267. func (m *SopNodeMutation) FieldCleared(name string) bool {
  19268. _, ok := m.clearedFields[name]
  19269. return ok
  19270. }
  19271. // ClearField clears the value of the field with the given name. It returns an
  19272. // error if the field is not defined in the schema.
  19273. func (m *SopNodeMutation) ClearField(name string) error {
  19274. switch name {
  19275. case sopnode.FieldStatus:
  19276. m.ClearStatus()
  19277. return nil
  19278. case sopnode.FieldDeletedAt:
  19279. m.ClearDeletedAt()
  19280. return nil
  19281. case sopnode.FieldConditionList:
  19282. m.ClearConditionList()
  19283. return nil
  19284. case sopnode.FieldActionMessage:
  19285. m.ClearActionMessage()
  19286. return nil
  19287. case sopnode.FieldActionLabelAdd:
  19288. m.ClearActionLabelAdd()
  19289. return nil
  19290. case sopnode.FieldActionLabelDel:
  19291. m.ClearActionLabelDel()
  19292. return nil
  19293. case sopnode.FieldActionForward:
  19294. m.ClearActionForward()
  19295. return nil
  19296. }
  19297. return fmt.Errorf("unknown SopNode nullable field %s", name)
  19298. }
  19299. // ResetField resets all changes in the mutation for the field with the given name.
  19300. // It returns an error if the field is not defined in the schema.
  19301. func (m *SopNodeMutation) ResetField(name string) error {
  19302. switch name {
  19303. case sopnode.FieldCreatedAt:
  19304. m.ResetCreatedAt()
  19305. return nil
  19306. case sopnode.FieldUpdatedAt:
  19307. m.ResetUpdatedAt()
  19308. return nil
  19309. case sopnode.FieldStatus:
  19310. m.ResetStatus()
  19311. return nil
  19312. case sopnode.FieldDeletedAt:
  19313. m.ResetDeletedAt()
  19314. return nil
  19315. case sopnode.FieldStageID:
  19316. m.ResetStageID()
  19317. return nil
  19318. case sopnode.FieldParentID:
  19319. m.ResetParentID()
  19320. return nil
  19321. case sopnode.FieldName:
  19322. m.ResetName()
  19323. return nil
  19324. case sopnode.FieldConditionType:
  19325. m.ResetConditionType()
  19326. return nil
  19327. case sopnode.FieldConditionList:
  19328. m.ResetConditionList()
  19329. return nil
  19330. case sopnode.FieldNoReplyCondition:
  19331. m.ResetNoReplyCondition()
  19332. return nil
  19333. case sopnode.FieldNoReplyUnit:
  19334. m.ResetNoReplyUnit()
  19335. return nil
  19336. case sopnode.FieldActionMessage:
  19337. m.ResetActionMessage()
  19338. return nil
  19339. case sopnode.FieldActionLabelAdd:
  19340. m.ResetActionLabelAdd()
  19341. return nil
  19342. case sopnode.FieldActionLabelDel:
  19343. m.ResetActionLabelDel()
  19344. return nil
  19345. case sopnode.FieldActionForward:
  19346. m.ResetActionForward()
  19347. return nil
  19348. }
  19349. return fmt.Errorf("unknown SopNode field %s", name)
  19350. }
  19351. // AddedEdges returns all edge names that were set/added in this mutation.
  19352. func (m *SopNodeMutation) AddedEdges() []string {
  19353. edges := make([]string, 0, 2)
  19354. if m.sop_stage != nil {
  19355. edges = append(edges, sopnode.EdgeSopStage)
  19356. }
  19357. if m.node_messages != nil {
  19358. edges = append(edges, sopnode.EdgeNodeMessages)
  19359. }
  19360. return edges
  19361. }
  19362. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19363. // name in this mutation.
  19364. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  19365. switch name {
  19366. case sopnode.EdgeSopStage:
  19367. if id := m.sop_stage; id != nil {
  19368. return []ent.Value{*id}
  19369. }
  19370. case sopnode.EdgeNodeMessages:
  19371. ids := make([]ent.Value, 0, len(m.node_messages))
  19372. for id := range m.node_messages {
  19373. ids = append(ids, id)
  19374. }
  19375. return ids
  19376. }
  19377. return nil
  19378. }
  19379. // RemovedEdges returns all edge names that were removed in this mutation.
  19380. func (m *SopNodeMutation) RemovedEdges() []string {
  19381. edges := make([]string, 0, 2)
  19382. if m.removednode_messages != nil {
  19383. edges = append(edges, sopnode.EdgeNodeMessages)
  19384. }
  19385. return edges
  19386. }
  19387. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19388. // the given name in this mutation.
  19389. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  19390. switch name {
  19391. case sopnode.EdgeNodeMessages:
  19392. ids := make([]ent.Value, 0, len(m.removednode_messages))
  19393. for id := range m.removednode_messages {
  19394. ids = append(ids, id)
  19395. }
  19396. return ids
  19397. }
  19398. return nil
  19399. }
  19400. // ClearedEdges returns all edge names that were cleared in this mutation.
  19401. func (m *SopNodeMutation) ClearedEdges() []string {
  19402. edges := make([]string, 0, 2)
  19403. if m.clearedsop_stage {
  19404. edges = append(edges, sopnode.EdgeSopStage)
  19405. }
  19406. if m.clearednode_messages {
  19407. edges = append(edges, sopnode.EdgeNodeMessages)
  19408. }
  19409. return edges
  19410. }
  19411. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19412. // was cleared in this mutation.
  19413. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  19414. switch name {
  19415. case sopnode.EdgeSopStage:
  19416. return m.clearedsop_stage
  19417. case sopnode.EdgeNodeMessages:
  19418. return m.clearednode_messages
  19419. }
  19420. return false
  19421. }
  19422. // ClearEdge clears the value of the edge with the given name. It returns an error
  19423. // if that edge is not defined in the schema.
  19424. func (m *SopNodeMutation) ClearEdge(name string) error {
  19425. switch name {
  19426. case sopnode.EdgeSopStage:
  19427. m.ClearSopStage()
  19428. return nil
  19429. }
  19430. return fmt.Errorf("unknown SopNode unique edge %s", name)
  19431. }
  19432. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19433. // It returns an error if the edge is not defined in the schema.
  19434. func (m *SopNodeMutation) ResetEdge(name string) error {
  19435. switch name {
  19436. case sopnode.EdgeSopStage:
  19437. m.ResetSopStage()
  19438. return nil
  19439. case sopnode.EdgeNodeMessages:
  19440. m.ResetNodeMessages()
  19441. return nil
  19442. }
  19443. return fmt.Errorf("unknown SopNode edge %s", name)
  19444. }
  19445. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  19446. type SopStageMutation struct {
  19447. config
  19448. op Op
  19449. typ string
  19450. id *uint64
  19451. created_at *time.Time
  19452. updated_at *time.Time
  19453. status *uint8
  19454. addstatus *int8
  19455. deleted_at *time.Time
  19456. name *string
  19457. condition_type *int
  19458. addcondition_type *int
  19459. condition_operator *int
  19460. addcondition_operator *int
  19461. condition_list *[]custom_types.Condition
  19462. appendcondition_list []custom_types.Condition
  19463. action_message *[]custom_types.Action
  19464. appendaction_message []custom_types.Action
  19465. action_label_add *[]uint64
  19466. appendaction_label_add []uint64
  19467. action_label_del *[]uint64
  19468. appendaction_label_del []uint64
  19469. action_forward **custom_types.ActionForward
  19470. index_sort *int
  19471. addindex_sort *int
  19472. clearedFields map[string]struct{}
  19473. sop_task *uint64
  19474. clearedsop_task bool
  19475. stage_nodes map[uint64]struct{}
  19476. removedstage_nodes map[uint64]struct{}
  19477. clearedstage_nodes bool
  19478. stage_messages map[uint64]struct{}
  19479. removedstage_messages map[uint64]struct{}
  19480. clearedstage_messages bool
  19481. done bool
  19482. oldValue func(context.Context) (*SopStage, error)
  19483. predicates []predicate.SopStage
  19484. }
  19485. var _ ent.Mutation = (*SopStageMutation)(nil)
  19486. // sopstageOption allows management of the mutation configuration using functional options.
  19487. type sopstageOption func(*SopStageMutation)
  19488. // newSopStageMutation creates new mutation for the SopStage entity.
  19489. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  19490. m := &SopStageMutation{
  19491. config: c,
  19492. op: op,
  19493. typ: TypeSopStage,
  19494. clearedFields: make(map[string]struct{}),
  19495. }
  19496. for _, opt := range opts {
  19497. opt(m)
  19498. }
  19499. return m
  19500. }
  19501. // withSopStageID sets the ID field of the mutation.
  19502. func withSopStageID(id uint64) sopstageOption {
  19503. return func(m *SopStageMutation) {
  19504. var (
  19505. err error
  19506. once sync.Once
  19507. value *SopStage
  19508. )
  19509. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  19510. once.Do(func() {
  19511. if m.done {
  19512. err = errors.New("querying old values post mutation is not allowed")
  19513. } else {
  19514. value, err = m.Client().SopStage.Get(ctx, id)
  19515. }
  19516. })
  19517. return value, err
  19518. }
  19519. m.id = &id
  19520. }
  19521. }
  19522. // withSopStage sets the old SopStage of the mutation.
  19523. func withSopStage(node *SopStage) sopstageOption {
  19524. return func(m *SopStageMutation) {
  19525. m.oldValue = func(context.Context) (*SopStage, error) {
  19526. return node, nil
  19527. }
  19528. m.id = &node.ID
  19529. }
  19530. }
  19531. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19532. // executed in a transaction (ent.Tx), a transactional client is returned.
  19533. func (m SopStageMutation) Client() *Client {
  19534. client := &Client{config: m.config}
  19535. client.init()
  19536. return client
  19537. }
  19538. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19539. // it returns an error otherwise.
  19540. func (m SopStageMutation) Tx() (*Tx, error) {
  19541. if _, ok := m.driver.(*txDriver); !ok {
  19542. return nil, errors.New("ent: mutation is not running in a transaction")
  19543. }
  19544. tx := &Tx{config: m.config}
  19545. tx.init()
  19546. return tx, nil
  19547. }
  19548. // SetID sets the value of the id field. Note that this
  19549. // operation is only accepted on creation of SopStage entities.
  19550. func (m *SopStageMutation) SetID(id uint64) {
  19551. m.id = &id
  19552. }
  19553. // ID returns the ID value in the mutation. Note that the ID is only available
  19554. // if it was provided to the builder or after it was returned from the database.
  19555. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  19556. if m.id == nil {
  19557. return
  19558. }
  19559. return *m.id, true
  19560. }
  19561. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19562. // That means, if the mutation is applied within a transaction with an isolation level such
  19563. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19564. // or updated by the mutation.
  19565. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  19566. switch {
  19567. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19568. id, exists := m.ID()
  19569. if exists {
  19570. return []uint64{id}, nil
  19571. }
  19572. fallthrough
  19573. case m.op.Is(OpUpdate | OpDelete):
  19574. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  19575. default:
  19576. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19577. }
  19578. }
  19579. // SetCreatedAt sets the "created_at" field.
  19580. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  19581. m.created_at = &t
  19582. }
  19583. // CreatedAt returns the value of the "created_at" field in the mutation.
  19584. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  19585. v := m.created_at
  19586. if v == nil {
  19587. return
  19588. }
  19589. return *v, true
  19590. }
  19591. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  19592. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19594. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19595. if !m.op.Is(OpUpdateOne) {
  19596. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19597. }
  19598. if m.id == nil || m.oldValue == nil {
  19599. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19600. }
  19601. oldValue, err := m.oldValue(ctx)
  19602. if err != nil {
  19603. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19604. }
  19605. return oldValue.CreatedAt, nil
  19606. }
  19607. // ResetCreatedAt resets all changes to the "created_at" field.
  19608. func (m *SopStageMutation) ResetCreatedAt() {
  19609. m.created_at = nil
  19610. }
  19611. // SetUpdatedAt sets the "updated_at" field.
  19612. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  19613. m.updated_at = &t
  19614. }
  19615. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19616. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  19617. v := m.updated_at
  19618. if v == nil {
  19619. return
  19620. }
  19621. return *v, true
  19622. }
  19623. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  19624. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19626. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19627. if !m.op.Is(OpUpdateOne) {
  19628. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19629. }
  19630. if m.id == nil || m.oldValue == nil {
  19631. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19632. }
  19633. oldValue, err := m.oldValue(ctx)
  19634. if err != nil {
  19635. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19636. }
  19637. return oldValue.UpdatedAt, nil
  19638. }
  19639. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19640. func (m *SopStageMutation) ResetUpdatedAt() {
  19641. m.updated_at = nil
  19642. }
  19643. // SetStatus sets the "status" field.
  19644. func (m *SopStageMutation) SetStatus(u uint8) {
  19645. m.status = &u
  19646. m.addstatus = nil
  19647. }
  19648. // Status returns the value of the "status" field in the mutation.
  19649. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  19650. v := m.status
  19651. if v == nil {
  19652. return
  19653. }
  19654. return *v, true
  19655. }
  19656. // OldStatus returns the old "status" field's value of the SopStage entity.
  19657. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19659. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19660. if !m.op.Is(OpUpdateOne) {
  19661. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19662. }
  19663. if m.id == nil || m.oldValue == nil {
  19664. return v, errors.New("OldStatus requires an ID field in the mutation")
  19665. }
  19666. oldValue, err := m.oldValue(ctx)
  19667. if err != nil {
  19668. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19669. }
  19670. return oldValue.Status, nil
  19671. }
  19672. // AddStatus adds u to the "status" field.
  19673. func (m *SopStageMutation) AddStatus(u int8) {
  19674. if m.addstatus != nil {
  19675. *m.addstatus += u
  19676. } else {
  19677. m.addstatus = &u
  19678. }
  19679. }
  19680. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19681. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  19682. v := m.addstatus
  19683. if v == nil {
  19684. return
  19685. }
  19686. return *v, true
  19687. }
  19688. // ClearStatus clears the value of the "status" field.
  19689. func (m *SopStageMutation) ClearStatus() {
  19690. m.status = nil
  19691. m.addstatus = nil
  19692. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  19693. }
  19694. // StatusCleared returns if the "status" field was cleared in this mutation.
  19695. func (m *SopStageMutation) StatusCleared() bool {
  19696. _, ok := m.clearedFields[sopstage.FieldStatus]
  19697. return ok
  19698. }
  19699. // ResetStatus resets all changes to the "status" field.
  19700. func (m *SopStageMutation) ResetStatus() {
  19701. m.status = nil
  19702. m.addstatus = nil
  19703. delete(m.clearedFields, sopstage.FieldStatus)
  19704. }
  19705. // SetDeletedAt sets the "deleted_at" field.
  19706. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  19707. m.deleted_at = &t
  19708. }
  19709. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19710. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  19711. v := m.deleted_at
  19712. if v == nil {
  19713. return
  19714. }
  19715. return *v, true
  19716. }
  19717. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  19718. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19720. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19721. if !m.op.Is(OpUpdateOne) {
  19722. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19723. }
  19724. if m.id == nil || m.oldValue == nil {
  19725. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19726. }
  19727. oldValue, err := m.oldValue(ctx)
  19728. if err != nil {
  19729. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19730. }
  19731. return oldValue.DeletedAt, nil
  19732. }
  19733. // ClearDeletedAt clears the value of the "deleted_at" field.
  19734. func (m *SopStageMutation) ClearDeletedAt() {
  19735. m.deleted_at = nil
  19736. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  19737. }
  19738. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19739. func (m *SopStageMutation) DeletedAtCleared() bool {
  19740. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  19741. return ok
  19742. }
  19743. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19744. func (m *SopStageMutation) ResetDeletedAt() {
  19745. m.deleted_at = nil
  19746. delete(m.clearedFields, sopstage.FieldDeletedAt)
  19747. }
  19748. // SetTaskID sets the "task_id" field.
  19749. func (m *SopStageMutation) SetTaskID(u uint64) {
  19750. m.sop_task = &u
  19751. }
  19752. // TaskID returns the value of the "task_id" field in the mutation.
  19753. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  19754. v := m.sop_task
  19755. if v == nil {
  19756. return
  19757. }
  19758. return *v, true
  19759. }
  19760. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  19761. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19763. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  19764. if !m.op.Is(OpUpdateOne) {
  19765. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  19766. }
  19767. if m.id == nil || m.oldValue == nil {
  19768. return v, errors.New("OldTaskID requires an ID field in the mutation")
  19769. }
  19770. oldValue, err := m.oldValue(ctx)
  19771. if err != nil {
  19772. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  19773. }
  19774. return oldValue.TaskID, nil
  19775. }
  19776. // ResetTaskID resets all changes to the "task_id" field.
  19777. func (m *SopStageMutation) ResetTaskID() {
  19778. m.sop_task = nil
  19779. }
  19780. // SetName sets the "name" field.
  19781. func (m *SopStageMutation) SetName(s string) {
  19782. m.name = &s
  19783. }
  19784. // Name returns the value of the "name" field in the mutation.
  19785. func (m *SopStageMutation) Name() (r string, exists bool) {
  19786. v := m.name
  19787. if v == nil {
  19788. return
  19789. }
  19790. return *v, true
  19791. }
  19792. // OldName returns the old "name" field's value of the SopStage entity.
  19793. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19795. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  19796. if !m.op.Is(OpUpdateOne) {
  19797. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19798. }
  19799. if m.id == nil || m.oldValue == nil {
  19800. return v, errors.New("OldName requires an ID field in the mutation")
  19801. }
  19802. oldValue, err := m.oldValue(ctx)
  19803. if err != nil {
  19804. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19805. }
  19806. return oldValue.Name, nil
  19807. }
  19808. // ResetName resets all changes to the "name" field.
  19809. func (m *SopStageMutation) ResetName() {
  19810. m.name = nil
  19811. }
  19812. // SetConditionType sets the "condition_type" field.
  19813. func (m *SopStageMutation) SetConditionType(i int) {
  19814. m.condition_type = &i
  19815. m.addcondition_type = nil
  19816. }
  19817. // ConditionType returns the value of the "condition_type" field in the mutation.
  19818. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  19819. v := m.condition_type
  19820. if v == nil {
  19821. return
  19822. }
  19823. return *v, true
  19824. }
  19825. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  19826. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19828. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  19829. if !m.op.Is(OpUpdateOne) {
  19830. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  19831. }
  19832. if m.id == nil || m.oldValue == nil {
  19833. return v, errors.New("OldConditionType requires an ID field in the mutation")
  19834. }
  19835. oldValue, err := m.oldValue(ctx)
  19836. if err != nil {
  19837. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  19838. }
  19839. return oldValue.ConditionType, nil
  19840. }
  19841. // AddConditionType adds i to the "condition_type" field.
  19842. func (m *SopStageMutation) AddConditionType(i int) {
  19843. if m.addcondition_type != nil {
  19844. *m.addcondition_type += i
  19845. } else {
  19846. m.addcondition_type = &i
  19847. }
  19848. }
  19849. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  19850. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  19851. v := m.addcondition_type
  19852. if v == nil {
  19853. return
  19854. }
  19855. return *v, true
  19856. }
  19857. // ResetConditionType resets all changes to the "condition_type" field.
  19858. func (m *SopStageMutation) ResetConditionType() {
  19859. m.condition_type = nil
  19860. m.addcondition_type = nil
  19861. }
  19862. // SetConditionOperator sets the "condition_operator" field.
  19863. func (m *SopStageMutation) SetConditionOperator(i int) {
  19864. m.condition_operator = &i
  19865. m.addcondition_operator = nil
  19866. }
  19867. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  19868. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  19869. v := m.condition_operator
  19870. if v == nil {
  19871. return
  19872. }
  19873. return *v, true
  19874. }
  19875. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  19876. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19878. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  19879. if !m.op.Is(OpUpdateOne) {
  19880. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  19881. }
  19882. if m.id == nil || m.oldValue == nil {
  19883. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  19884. }
  19885. oldValue, err := m.oldValue(ctx)
  19886. if err != nil {
  19887. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  19888. }
  19889. return oldValue.ConditionOperator, nil
  19890. }
  19891. // AddConditionOperator adds i to the "condition_operator" field.
  19892. func (m *SopStageMutation) AddConditionOperator(i int) {
  19893. if m.addcondition_operator != nil {
  19894. *m.addcondition_operator += i
  19895. } else {
  19896. m.addcondition_operator = &i
  19897. }
  19898. }
  19899. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  19900. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  19901. v := m.addcondition_operator
  19902. if v == nil {
  19903. return
  19904. }
  19905. return *v, true
  19906. }
  19907. // ResetConditionOperator resets all changes to the "condition_operator" field.
  19908. func (m *SopStageMutation) ResetConditionOperator() {
  19909. m.condition_operator = nil
  19910. m.addcondition_operator = nil
  19911. }
  19912. // SetConditionList sets the "condition_list" field.
  19913. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  19914. m.condition_list = &ct
  19915. m.appendcondition_list = nil
  19916. }
  19917. // ConditionList returns the value of the "condition_list" field in the mutation.
  19918. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  19919. v := m.condition_list
  19920. if v == nil {
  19921. return
  19922. }
  19923. return *v, true
  19924. }
  19925. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  19926. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19928. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  19929. if !m.op.Is(OpUpdateOne) {
  19930. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  19931. }
  19932. if m.id == nil || m.oldValue == nil {
  19933. return v, errors.New("OldConditionList requires an ID field in the mutation")
  19934. }
  19935. oldValue, err := m.oldValue(ctx)
  19936. if err != nil {
  19937. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  19938. }
  19939. return oldValue.ConditionList, nil
  19940. }
  19941. // AppendConditionList adds ct to the "condition_list" field.
  19942. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  19943. m.appendcondition_list = append(m.appendcondition_list, ct...)
  19944. }
  19945. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  19946. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  19947. if len(m.appendcondition_list) == 0 {
  19948. return nil, false
  19949. }
  19950. return m.appendcondition_list, true
  19951. }
  19952. // ResetConditionList resets all changes to the "condition_list" field.
  19953. func (m *SopStageMutation) ResetConditionList() {
  19954. m.condition_list = nil
  19955. m.appendcondition_list = nil
  19956. }
  19957. // SetActionMessage sets the "action_message" field.
  19958. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  19959. m.action_message = &ct
  19960. m.appendaction_message = nil
  19961. }
  19962. // ActionMessage returns the value of the "action_message" field in the mutation.
  19963. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  19964. v := m.action_message
  19965. if v == nil {
  19966. return
  19967. }
  19968. return *v, true
  19969. }
  19970. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  19971. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19973. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  19974. if !m.op.Is(OpUpdateOne) {
  19975. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  19976. }
  19977. if m.id == nil || m.oldValue == nil {
  19978. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  19979. }
  19980. oldValue, err := m.oldValue(ctx)
  19981. if err != nil {
  19982. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  19983. }
  19984. return oldValue.ActionMessage, nil
  19985. }
  19986. // AppendActionMessage adds ct to the "action_message" field.
  19987. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  19988. m.appendaction_message = append(m.appendaction_message, ct...)
  19989. }
  19990. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  19991. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  19992. if len(m.appendaction_message) == 0 {
  19993. return nil, false
  19994. }
  19995. return m.appendaction_message, true
  19996. }
  19997. // ClearActionMessage clears the value of the "action_message" field.
  19998. func (m *SopStageMutation) ClearActionMessage() {
  19999. m.action_message = nil
  20000. m.appendaction_message = nil
  20001. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  20002. }
  20003. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  20004. func (m *SopStageMutation) ActionMessageCleared() bool {
  20005. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  20006. return ok
  20007. }
  20008. // ResetActionMessage resets all changes to the "action_message" field.
  20009. func (m *SopStageMutation) ResetActionMessage() {
  20010. m.action_message = nil
  20011. m.appendaction_message = nil
  20012. delete(m.clearedFields, sopstage.FieldActionMessage)
  20013. }
  20014. // SetActionLabelAdd sets the "action_label_add" field.
  20015. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  20016. m.action_label_add = &u
  20017. m.appendaction_label_add = nil
  20018. }
  20019. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  20020. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  20021. v := m.action_label_add
  20022. if v == nil {
  20023. return
  20024. }
  20025. return *v, true
  20026. }
  20027. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  20028. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20030. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  20031. if !m.op.Is(OpUpdateOne) {
  20032. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  20033. }
  20034. if m.id == nil || m.oldValue == nil {
  20035. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  20036. }
  20037. oldValue, err := m.oldValue(ctx)
  20038. if err != nil {
  20039. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  20040. }
  20041. return oldValue.ActionLabelAdd, nil
  20042. }
  20043. // AppendActionLabelAdd adds u to the "action_label_add" field.
  20044. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  20045. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  20046. }
  20047. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  20048. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  20049. if len(m.appendaction_label_add) == 0 {
  20050. return nil, false
  20051. }
  20052. return m.appendaction_label_add, true
  20053. }
  20054. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  20055. func (m *SopStageMutation) ClearActionLabelAdd() {
  20056. m.action_label_add = nil
  20057. m.appendaction_label_add = nil
  20058. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  20059. }
  20060. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  20061. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  20062. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  20063. return ok
  20064. }
  20065. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  20066. func (m *SopStageMutation) ResetActionLabelAdd() {
  20067. m.action_label_add = nil
  20068. m.appendaction_label_add = nil
  20069. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  20070. }
  20071. // SetActionLabelDel sets the "action_label_del" field.
  20072. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  20073. m.action_label_del = &u
  20074. m.appendaction_label_del = nil
  20075. }
  20076. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  20077. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  20078. v := m.action_label_del
  20079. if v == nil {
  20080. return
  20081. }
  20082. return *v, true
  20083. }
  20084. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  20085. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20087. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  20088. if !m.op.Is(OpUpdateOne) {
  20089. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  20090. }
  20091. if m.id == nil || m.oldValue == nil {
  20092. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  20093. }
  20094. oldValue, err := m.oldValue(ctx)
  20095. if err != nil {
  20096. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  20097. }
  20098. return oldValue.ActionLabelDel, nil
  20099. }
  20100. // AppendActionLabelDel adds u to the "action_label_del" field.
  20101. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  20102. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  20103. }
  20104. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  20105. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  20106. if len(m.appendaction_label_del) == 0 {
  20107. return nil, false
  20108. }
  20109. return m.appendaction_label_del, true
  20110. }
  20111. // ClearActionLabelDel clears the value of the "action_label_del" field.
  20112. func (m *SopStageMutation) ClearActionLabelDel() {
  20113. m.action_label_del = nil
  20114. m.appendaction_label_del = nil
  20115. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  20116. }
  20117. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  20118. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  20119. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  20120. return ok
  20121. }
  20122. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  20123. func (m *SopStageMutation) ResetActionLabelDel() {
  20124. m.action_label_del = nil
  20125. m.appendaction_label_del = nil
  20126. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  20127. }
  20128. // SetActionForward sets the "action_forward" field.
  20129. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  20130. m.action_forward = &ctf
  20131. }
  20132. // ActionForward returns the value of the "action_forward" field in the mutation.
  20133. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  20134. v := m.action_forward
  20135. if v == nil {
  20136. return
  20137. }
  20138. return *v, true
  20139. }
  20140. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  20141. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20143. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  20144. if !m.op.Is(OpUpdateOne) {
  20145. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  20146. }
  20147. if m.id == nil || m.oldValue == nil {
  20148. return v, errors.New("OldActionForward requires an ID field in the mutation")
  20149. }
  20150. oldValue, err := m.oldValue(ctx)
  20151. if err != nil {
  20152. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  20153. }
  20154. return oldValue.ActionForward, nil
  20155. }
  20156. // ClearActionForward clears the value of the "action_forward" field.
  20157. func (m *SopStageMutation) ClearActionForward() {
  20158. m.action_forward = nil
  20159. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  20160. }
  20161. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  20162. func (m *SopStageMutation) ActionForwardCleared() bool {
  20163. _, ok := m.clearedFields[sopstage.FieldActionForward]
  20164. return ok
  20165. }
  20166. // ResetActionForward resets all changes to the "action_forward" field.
  20167. func (m *SopStageMutation) ResetActionForward() {
  20168. m.action_forward = nil
  20169. delete(m.clearedFields, sopstage.FieldActionForward)
  20170. }
  20171. // SetIndexSort sets the "index_sort" field.
  20172. func (m *SopStageMutation) SetIndexSort(i int) {
  20173. m.index_sort = &i
  20174. m.addindex_sort = nil
  20175. }
  20176. // IndexSort returns the value of the "index_sort" field in the mutation.
  20177. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  20178. v := m.index_sort
  20179. if v == nil {
  20180. return
  20181. }
  20182. return *v, true
  20183. }
  20184. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  20185. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  20186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20187. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  20188. if !m.op.Is(OpUpdateOne) {
  20189. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  20190. }
  20191. if m.id == nil || m.oldValue == nil {
  20192. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  20193. }
  20194. oldValue, err := m.oldValue(ctx)
  20195. if err != nil {
  20196. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  20197. }
  20198. return oldValue.IndexSort, nil
  20199. }
  20200. // AddIndexSort adds i to the "index_sort" field.
  20201. func (m *SopStageMutation) AddIndexSort(i int) {
  20202. if m.addindex_sort != nil {
  20203. *m.addindex_sort += i
  20204. } else {
  20205. m.addindex_sort = &i
  20206. }
  20207. }
  20208. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  20209. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  20210. v := m.addindex_sort
  20211. if v == nil {
  20212. return
  20213. }
  20214. return *v, true
  20215. }
  20216. // ClearIndexSort clears the value of the "index_sort" field.
  20217. func (m *SopStageMutation) ClearIndexSort() {
  20218. m.index_sort = nil
  20219. m.addindex_sort = nil
  20220. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  20221. }
  20222. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  20223. func (m *SopStageMutation) IndexSortCleared() bool {
  20224. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  20225. return ok
  20226. }
  20227. // ResetIndexSort resets all changes to the "index_sort" field.
  20228. func (m *SopStageMutation) ResetIndexSort() {
  20229. m.index_sort = nil
  20230. m.addindex_sort = nil
  20231. delete(m.clearedFields, sopstage.FieldIndexSort)
  20232. }
  20233. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  20234. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  20235. m.sop_task = &id
  20236. }
  20237. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  20238. func (m *SopStageMutation) ClearSopTask() {
  20239. m.clearedsop_task = true
  20240. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  20241. }
  20242. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  20243. func (m *SopStageMutation) SopTaskCleared() bool {
  20244. return m.clearedsop_task
  20245. }
  20246. // SopTaskID returns the "sop_task" edge ID in the mutation.
  20247. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  20248. if m.sop_task != nil {
  20249. return *m.sop_task, true
  20250. }
  20251. return
  20252. }
  20253. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  20254. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20255. // SopTaskID instead. It exists only for internal usage by the builders.
  20256. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  20257. if id := m.sop_task; id != nil {
  20258. ids = append(ids, *id)
  20259. }
  20260. return
  20261. }
  20262. // ResetSopTask resets all changes to the "sop_task" edge.
  20263. func (m *SopStageMutation) ResetSopTask() {
  20264. m.sop_task = nil
  20265. m.clearedsop_task = false
  20266. }
  20267. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  20268. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  20269. if m.stage_nodes == nil {
  20270. m.stage_nodes = make(map[uint64]struct{})
  20271. }
  20272. for i := range ids {
  20273. m.stage_nodes[ids[i]] = struct{}{}
  20274. }
  20275. }
  20276. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  20277. func (m *SopStageMutation) ClearStageNodes() {
  20278. m.clearedstage_nodes = true
  20279. }
  20280. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  20281. func (m *SopStageMutation) StageNodesCleared() bool {
  20282. return m.clearedstage_nodes
  20283. }
  20284. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  20285. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  20286. if m.removedstage_nodes == nil {
  20287. m.removedstage_nodes = make(map[uint64]struct{})
  20288. }
  20289. for i := range ids {
  20290. delete(m.stage_nodes, ids[i])
  20291. m.removedstage_nodes[ids[i]] = struct{}{}
  20292. }
  20293. }
  20294. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  20295. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  20296. for id := range m.removedstage_nodes {
  20297. ids = append(ids, id)
  20298. }
  20299. return
  20300. }
  20301. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  20302. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  20303. for id := range m.stage_nodes {
  20304. ids = append(ids, id)
  20305. }
  20306. return
  20307. }
  20308. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  20309. func (m *SopStageMutation) ResetStageNodes() {
  20310. m.stage_nodes = nil
  20311. m.clearedstage_nodes = false
  20312. m.removedstage_nodes = nil
  20313. }
  20314. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  20315. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  20316. if m.stage_messages == nil {
  20317. m.stage_messages = make(map[uint64]struct{})
  20318. }
  20319. for i := range ids {
  20320. m.stage_messages[ids[i]] = struct{}{}
  20321. }
  20322. }
  20323. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  20324. func (m *SopStageMutation) ClearStageMessages() {
  20325. m.clearedstage_messages = true
  20326. }
  20327. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  20328. func (m *SopStageMutation) StageMessagesCleared() bool {
  20329. return m.clearedstage_messages
  20330. }
  20331. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  20332. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  20333. if m.removedstage_messages == nil {
  20334. m.removedstage_messages = make(map[uint64]struct{})
  20335. }
  20336. for i := range ids {
  20337. delete(m.stage_messages, ids[i])
  20338. m.removedstage_messages[ids[i]] = struct{}{}
  20339. }
  20340. }
  20341. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  20342. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  20343. for id := range m.removedstage_messages {
  20344. ids = append(ids, id)
  20345. }
  20346. return
  20347. }
  20348. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  20349. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  20350. for id := range m.stage_messages {
  20351. ids = append(ids, id)
  20352. }
  20353. return
  20354. }
  20355. // ResetStageMessages resets all changes to the "stage_messages" edge.
  20356. func (m *SopStageMutation) ResetStageMessages() {
  20357. m.stage_messages = nil
  20358. m.clearedstage_messages = false
  20359. m.removedstage_messages = nil
  20360. }
  20361. // Where appends a list predicates to the SopStageMutation builder.
  20362. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  20363. m.predicates = append(m.predicates, ps...)
  20364. }
  20365. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  20366. // users can use type-assertion to append predicates that do not depend on any generated package.
  20367. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  20368. p := make([]predicate.SopStage, len(ps))
  20369. for i := range ps {
  20370. p[i] = ps[i]
  20371. }
  20372. m.Where(p...)
  20373. }
  20374. // Op returns the operation name.
  20375. func (m *SopStageMutation) Op() Op {
  20376. return m.op
  20377. }
  20378. // SetOp allows setting the mutation operation.
  20379. func (m *SopStageMutation) SetOp(op Op) {
  20380. m.op = op
  20381. }
  20382. // Type returns the node type of this mutation (SopStage).
  20383. func (m *SopStageMutation) Type() string {
  20384. return m.typ
  20385. }
  20386. // Fields returns all fields that were changed during this mutation. Note that in
  20387. // order to get all numeric fields that were incremented/decremented, call
  20388. // AddedFields().
  20389. func (m *SopStageMutation) Fields() []string {
  20390. fields := make([]string, 0, 14)
  20391. if m.created_at != nil {
  20392. fields = append(fields, sopstage.FieldCreatedAt)
  20393. }
  20394. if m.updated_at != nil {
  20395. fields = append(fields, sopstage.FieldUpdatedAt)
  20396. }
  20397. if m.status != nil {
  20398. fields = append(fields, sopstage.FieldStatus)
  20399. }
  20400. if m.deleted_at != nil {
  20401. fields = append(fields, sopstage.FieldDeletedAt)
  20402. }
  20403. if m.sop_task != nil {
  20404. fields = append(fields, sopstage.FieldTaskID)
  20405. }
  20406. if m.name != nil {
  20407. fields = append(fields, sopstage.FieldName)
  20408. }
  20409. if m.condition_type != nil {
  20410. fields = append(fields, sopstage.FieldConditionType)
  20411. }
  20412. if m.condition_operator != nil {
  20413. fields = append(fields, sopstage.FieldConditionOperator)
  20414. }
  20415. if m.condition_list != nil {
  20416. fields = append(fields, sopstage.FieldConditionList)
  20417. }
  20418. if m.action_message != nil {
  20419. fields = append(fields, sopstage.FieldActionMessage)
  20420. }
  20421. if m.action_label_add != nil {
  20422. fields = append(fields, sopstage.FieldActionLabelAdd)
  20423. }
  20424. if m.action_label_del != nil {
  20425. fields = append(fields, sopstage.FieldActionLabelDel)
  20426. }
  20427. if m.action_forward != nil {
  20428. fields = append(fields, sopstage.FieldActionForward)
  20429. }
  20430. if m.index_sort != nil {
  20431. fields = append(fields, sopstage.FieldIndexSort)
  20432. }
  20433. return fields
  20434. }
  20435. // Field returns the value of a field with the given name. The second boolean
  20436. // return value indicates that this field was not set, or was not defined in the
  20437. // schema.
  20438. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  20439. switch name {
  20440. case sopstage.FieldCreatedAt:
  20441. return m.CreatedAt()
  20442. case sopstage.FieldUpdatedAt:
  20443. return m.UpdatedAt()
  20444. case sopstage.FieldStatus:
  20445. return m.Status()
  20446. case sopstage.FieldDeletedAt:
  20447. return m.DeletedAt()
  20448. case sopstage.FieldTaskID:
  20449. return m.TaskID()
  20450. case sopstage.FieldName:
  20451. return m.Name()
  20452. case sopstage.FieldConditionType:
  20453. return m.ConditionType()
  20454. case sopstage.FieldConditionOperator:
  20455. return m.ConditionOperator()
  20456. case sopstage.FieldConditionList:
  20457. return m.ConditionList()
  20458. case sopstage.FieldActionMessage:
  20459. return m.ActionMessage()
  20460. case sopstage.FieldActionLabelAdd:
  20461. return m.ActionLabelAdd()
  20462. case sopstage.FieldActionLabelDel:
  20463. return m.ActionLabelDel()
  20464. case sopstage.FieldActionForward:
  20465. return m.ActionForward()
  20466. case sopstage.FieldIndexSort:
  20467. return m.IndexSort()
  20468. }
  20469. return nil, false
  20470. }
  20471. // OldField returns the old value of the field from the database. An error is
  20472. // returned if the mutation operation is not UpdateOne, or the query to the
  20473. // database failed.
  20474. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20475. switch name {
  20476. case sopstage.FieldCreatedAt:
  20477. return m.OldCreatedAt(ctx)
  20478. case sopstage.FieldUpdatedAt:
  20479. return m.OldUpdatedAt(ctx)
  20480. case sopstage.FieldStatus:
  20481. return m.OldStatus(ctx)
  20482. case sopstage.FieldDeletedAt:
  20483. return m.OldDeletedAt(ctx)
  20484. case sopstage.FieldTaskID:
  20485. return m.OldTaskID(ctx)
  20486. case sopstage.FieldName:
  20487. return m.OldName(ctx)
  20488. case sopstage.FieldConditionType:
  20489. return m.OldConditionType(ctx)
  20490. case sopstage.FieldConditionOperator:
  20491. return m.OldConditionOperator(ctx)
  20492. case sopstage.FieldConditionList:
  20493. return m.OldConditionList(ctx)
  20494. case sopstage.FieldActionMessage:
  20495. return m.OldActionMessage(ctx)
  20496. case sopstage.FieldActionLabelAdd:
  20497. return m.OldActionLabelAdd(ctx)
  20498. case sopstage.FieldActionLabelDel:
  20499. return m.OldActionLabelDel(ctx)
  20500. case sopstage.FieldActionForward:
  20501. return m.OldActionForward(ctx)
  20502. case sopstage.FieldIndexSort:
  20503. return m.OldIndexSort(ctx)
  20504. }
  20505. return nil, fmt.Errorf("unknown SopStage field %s", name)
  20506. }
  20507. // SetField sets the value of a field with the given name. It returns an error if
  20508. // the field is not defined in the schema, or if the type mismatched the field
  20509. // type.
  20510. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  20511. switch name {
  20512. case sopstage.FieldCreatedAt:
  20513. v, ok := value.(time.Time)
  20514. if !ok {
  20515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20516. }
  20517. m.SetCreatedAt(v)
  20518. return nil
  20519. case sopstage.FieldUpdatedAt:
  20520. v, ok := value.(time.Time)
  20521. if !ok {
  20522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20523. }
  20524. m.SetUpdatedAt(v)
  20525. return nil
  20526. case sopstage.FieldStatus:
  20527. v, ok := value.(uint8)
  20528. if !ok {
  20529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20530. }
  20531. m.SetStatus(v)
  20532. return nil
  20533. case sopstage.FieldDeletedAt:
  20534. v, ok := value.(time.Time)
  20535. if !ok {
  20536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20537. }
  20538. m.SetDeletedAt(v)
  20539. return nil
  20540. case sopstage.FieldTaskID:
  20541. v, ok := value.(uint64)
  20542. if !ok {
  20543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20544. }
  20545. m.SetTaskID(v)
  20546. return nil
  20547. case sopstage.FieldName:
  20548. v, ok := value.(string)
  20549. if !ok {
  20550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20551. }
  20552. m.SetName(v)
  20553. return nil
  20554. case sopstage.FieldConditionType:
  20555. v, ok := value.(int)
  20556. if !ok {
  20557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20558. }
  20559. m.SetConditionType(v)
  20560. return nil
  20561. case sopstage.FieldConditionOperator:
  20562. v, ok := value.(int)
  20563. if !ok {
  20564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20565. }
  20566. m.SetConditionOperator(v)
  20567. return nil
  20568. case sopstage.FieldConditionList:
  20569. v, ok := value.([]custom_types.Condition)
  20570. if !ok {
  20571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20572. }
  20573. m.SetConditionList(v)
  20574. return nil
  20575. case sopstage.FieldActionMessage:
  20576. v, ok := value.([]custom_types.Action)
  20577. if !ok {
  20578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20579. }
  20580. m.SetActionMessage(v)
  20581. return nil
  20582. case sopstage.FieldActionLabelAdd:
  20583. v, ok := value.([]uint64)
  20584. if !ok {
  20585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20586. }
  20587. m.SetActionLabelAdd(v)
  20588. return nil
  20589. case sopstage.FieldActionLabelDel:
  20590. v, ok := value.([]uint64)
  20591. if !ok {
  20592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20593. }
  20594. m.SetActionLabelDel(v)
  20595. return nil
  20596. case sopstage.FieldActionForward:
  20597. v, ok := value.(*custom_types.ActionForward)
  20598. if !ok {
  20599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20600. }
  20601. m.SetActionForward(v)
  20602. return nil
  20603. case sopstage.FieldIndexSort:
  20604. v, ok := value.(int)
  20605. if !ok {
  20606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20607. }
  20608. m.SetIndexSort(v)
  20609. return nil
  20610. }
  20611. return fmt.Errorf("unknown SopStage field %s", name)
  20612. }
  20613. // AddedFields returns all numeric fields that were incremented/decremented during
  20614. // this mutation.
  20615. func (m *SopStageMutation) AddedFields() []string {
  20616. var fields []string
  20617. if m.addstatus != nil {
  20618. fields = append(fields, sopstage.FieldStatus)
  20619. }
  20620. if m.addcondition_type != nil {
  20621. fields = append(fields, sopstage.FieldConditionType)
  20622. }
  20623. if m.addcondition_operator != nil {
  20624. fields = append(fields, sopstage.FieldConditionOperator)
  20625. }
  20626. if m.addindex_sort != nil {
  20627. fields = append(fields, sopstage.FieldIndexSort)
  20628. }
  20629. return fields
  20630. }
  20631. // AddedField returns the numeric value that was incremented/decremented on a field
  20632. // with the given name. The second boolean return value indicates that this field
  20633. // was not set, or was not defined in the schema.
  20634. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  20635. switch name {
  20636. case sopstage.FieldStatus:
  20637. return m.AddedStatus()
  20638. case sopstage.FieldConditionType:
  20639. return m.AddedConditionType()
  20640. case sopstage.FieldConditionOperator:
  20641. return m.AddedConditionOperator()
  20642. case sopstage.FieldIndexSort:
  20643. return m.AddedIndexSort()
  20644. }
  20645. return nil, false
  20646. }
  20647. // AddField adds the value to the field with the given name. It returns an error if
  20648. // the field is not defined in the schema, or if the type mismatched the field
  20649. // type.
  20650. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  20651. switch name {
  20652. case sopstage.FieldStatus:
  20653. v, ok := value.(int8)
  20654. if !ok {
  20655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20656. }
  20657. m.AddStatus(v)
  20658. return nil
  20659. case sopstage.FieldConditionType:
  20660. v, ok := value.(int)
  20661. if !ok {
  20662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20663. }
  20664. m.AddConditionType(v)
  20665. return nil
  20666. case sopstage.FieldConditionOperator:
  20667. v, ok := value.(int)
  20668. if !ok {
  20669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20670. }
  20671. m.AddConditionOperator(v)
  20672. return nil
  20673. case sopstage.FieldIndexSort:
  20674. v, ok := value.(int)
  20675. if !ok {
  20676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20677. }
  20678. m.AddIndexSort(v)
  20679. return nil
  20680. }
  20681. return fmt.Errorf("unknown SopStage numeric field %s", name)
  20682. }
  20683. // ClearedFields returns all nullable fields that were cleared during this
  20684. // mutation.
  20685. func (m *SopStageMutation) ClearedFields() []string {
  20686. var fields []string
  20687. if m.FieldCleared(sopstage.FieldStatus) {
  20688. fields = append(fields, sopstage.FieldStatus)
  20689. }
  20690. if m.FieldCleared(sopstage.FieldDeletedAt) {
  20691. fields = append(fields, sopstage.FieldDeletedAt)
  20692. }
  20693. if m.FieldCleared(sopstage.FieldActionMessage) {
  20694. fields = append(fields, sopstage.FieldActionMessage)
  20695. }
  20696. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  20697. fields = append(fields, sopstage.FieldActionLabelAdd)
  20698. }
  20699. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  20700. fields = append(fields, sopstage.FieldActionLabelDel)
  20701. }
  20702. if m.FieldCleared(sopstage.FieldActionForward) {
  20703. fields = append(fields, sopstage.FieldActionForward)
  20704. }
  20705. if m.FieldCleared(sopstage.FieldIndexSort) {
  20706. fields = append(fields, sopstage.FieldIndexSort)
  20707. }
  20708. return fields
  20709. }
  20710. // FieldCleared returns a boolean indicating if a field with the given name was
  20711. // cleared in this mutation.
  20712. func (m *SopStageMutation) FieldCleared(name string) bool {
  20713. _, ok := m.clearedFields[name]
  20714. return ok
  20715. }
  20716. // ClearField clears the value of the field with the given name. It returns an
  20717. // error if the field is not defined in the schema.
  20718. func (m *SopStageMutation) ClearField(name string) error {
  20719. switch name {
  20720. case sopstage.FieldStatus:
  20721. m.ClearStatus()
  20722. return nil
  20723. case sopstage.FieldDeletedAt:
  20724. m.ClearDeletedAt()
  20725. return nil
  20726. case sopstage.FieldActionMessage:
  20727. m.ClearActionMessage()
  20728. return nil
  20729. case sopstage.FieldActionLabelAdd:
  20730. m.ClearActionLabelAdd()
  20731. return nil
  20732. case sopstage.FieldActionLabelDel:
  20733. m.ClearActionLabelDel()
  20734. return nil
  20735. case sopstage.FieldActionForward:
  20736. m.ClearActionForward()
  20737. return nil
  20738. case sopstage.FieldIndexSort:
  20739. m.ClearIndexSort()
  20740. return nil
  20741. }
  20742. return fmt.Errorf("unknown SopStage nullable field %s", name)
  20743. }
  20744. // ResetField resets all changes in the mutation for the field with the given name.
  20745. // It returns an error if the field is not defined in the schema.
  20746. func (m *SopStageMutation) ResetField(name string) error {
  20747. switch name {
  20748. case sopstage.FieldCreatedAt:
  20749. m.ResetCreatedAt()
  20750. return nil
  20751. case sopstage.FieldUpdatedAt:
  20752. m.ResetUpdatedAt()
  20753. return nil
  20754. case sopstage.FieldStatus:
  20755. m.ResetStatus()
  20756. return nil
  20757. case sopstage.FieldDeletedAt:
  20758. m.ResetDeletedAt()
  20759. return nil
  20760. case sopstage.FieldTaskID:
  20761. m.ResetTaskID()
  20762. return nil
  20763. case sopstage.FieldName:
  20764. m.ResetName()
  20765. return nil
  20766. case sopstage.FieldConditionType:
  20767. m.ResetConditionType()
  20768. return nil
  20769. case sopstage.FieldConditionOperator:
  20770. m.ResetConditionOperator()
  20771. return nil
  20772. case sopstage.FieldConditionList:
  20773. m.ResetConditionList()
  20774. return nil
  20775. case sopstage.FieldActionMessage:
  20776. m.ResetActionMessage()
  20777. return nil
  20778. case sopstage.FieldActionLabelAdd:
  20779. m.ResetActionLabelAdd()
  20780. return nil
  20781. case sopstage.FieldActionLabelDel:
  20782. m.ResetActionLabelDel()
  20783. return nil
  20784. case sopstage.FieldActionForward:
  20785. m.ResetActionForward()
  20786. return nil
  20787. case sopstage.FieldIndexSort:
  20788. m.ResetIndexSort()
  20789. return nil
  20790. }
  20791. return fmt.Errorf("unknown SopStage field %s", name)
  20792. }
  20793. // AddedEdges returns all edge names that were set/added in this mutation.
  20794. func (m *SopStageMutation) AddedEdges() []string {
  20795. edges := make([]string, 0, 3)
  20796. if m.sop_task != nil {
  20797. edges = append(edges, sopstage.EdgeSopTask)
  20798. }
  20799. if m.stage_nodes != nil {
  20800. edges = append(edges, sopstage.EdgeStageNodes)
  20801. }
  20802. if m.stage_messages != nil {
  20803. edges = append(edges, sopstage.EdgeStageMessages)
  20804. }
  20805. return edges
  20806. }
  20807. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20808. // name in this mutation.
  20809. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  20810. switch name {
  20811. case sopstage.EdgeSopTask:
  20812. if id := m.sop_task; id != nil {
  20813. return []ent.Value{*id}
  20814. }
  20815. case sopstage.EdgeStageNodes:
  20816. ids := make([]ent.Value, 0, len(m.stage_nodes))
  20817. for id := range m.stage_nodes {
  20818. ids = append(ids, id)
  20819. }
  20820. return ids
  20821. case sopstage.EdgeStageMessages:
  20822. ids := make([]ent.Value, 0, len(m.stage_messages))
  20823. for id := range m.stage_messages {
  20824. ids = append(ids, id)
  20825. }
  20826. return ids
  20827. }
  20828. return nil
  20829. }
  20830. // RemovedEdges returns all edge names that were removed in this mutation.
  20831. func (m *SopStageMutation) RemovedEdges() []string {
  20832. edges := make([]string, 0, 3)
  20833. if m.removedstage_nodes != nil {
  20834. edges = append(edges, sopstage.EdgeStageNodes)
  20835. }
  20836. if m.removedstage_messages != nil {
  20837. edges = append(edges, sopstage.EdgeStageMessages)
  20838. }
  20839. return edges
  20840. }
  20841. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20842. // the given name in this mutation.
  20843. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  20844. switch name {
  20845. case sopstage.EdgeStageNodes:
  20846. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  20847. for id := range m.removedstage_nodes {
  20848. ids = append(ids, id)
  20849. }
  20850. return ids
  20851. case sopstage.EdgeStageMessages:
  20852. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  20853. for id := range m.removedstage_messages {
  20854. ids = append(ids, id)
  20855. }
  20856. return ids
  20857. }
  20858. return nil
  20859. }
  20860. // ClearedEdges returns all edge names that were cleared in this mutation.
  20861. func (m *SopStageMutation) ClearedEdges() []string {
  20862. edges := make([]string, 0, 3)
  20863. if m.clearedsop_task {
  20864. edges = append(edges, sopstage.EdgeSopTask)
  20865. }
  20866. if m.clearedstage_nodes {
  20867. edges = append(edges, sopstage.EdgeStageNodes)
  20868. }
  20869. if m.clearedstage_messages {
  20870. edges = append(edges, sopstage.EdgeStageMessages)
  20871. }
  20872. return edges
  20873. }
  20874. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20875. // was cleared in this mutation.
  20876. func (m *SopStageMutation) EdgeCleared(name string) bool {
  20877. switch name {
  20878. case sopstage.EdgeSopTask:
  20879. return m.clearedsop_task
  20880. case sopstage.EdgeStageNodes:
  20881. return m.clearedstage_nodes
  20882. case sopstage.EdgeStageMessages:
  20883. return m.clearedstage_messages
  20884. }
  20885. return false
  20886. }
  20887. // ClearEdge clears the value of the edge with the given name. It returns an error
  20888. // if that edge is not defined in the schema.
  20889. func (m *SopStageMutation) ClearEdge(name string) error {
  20890. switch name {
  20891. case sopstage.EdgeSopTask:
  20892. m.ClearSopTask()
  20893. return nil
  20894. }
  20895. return fmt.Errorf("unknown SopStage unique edge %s", name)
  20896. }
  20897. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20898. // It returns an error if the edge is not defined in the schema.
  20899. func (m *SopStageMutation) ResetEdge(name string) error {
  20900. switch name {
  20901. case sopstage.EdgeSopTask:
  20902. m.ResetSopTask()
  20903. return nil
  20904. case sopstage.EdgeStageNodes:
  20905. m.ResetStageNodes()
  20906. return nil
  20907. case sopstage.EdgeStageMessages:
  20908. m.ResetStageMessages()
  20909. return nil
  20910. }
  20911. return fmt.Errorf("unknown SopStage edge %s", name)
  20912. }
  20913. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  20914. type SopTaskMutation struct {
  20915. config
  20916. op Op
  20917. typ string
  20918. id *uint64
  20919. created_at *time.Time
  20920. updated_at *time.Time
  20921. status *uint8
  20922. addstatus *int8
  20923. deleted_at *time.Time
  20924. name *string
  20925. bot_wxid_list *[]string
  20926. appendbot_wxid_list []string
  20927. _type *int
  20928. add_type *int
  20929. plan_start_time *time.Time
  20930. plan_end_time *time.Time
  20931. creator_id *string
  20932. organization_id *uint64
  20933. addorganization_id *int64
  20934. token *[]string
  20935. appendtoken []string
  20936. clearedFields map[string]struct{}
  20937. task_stages map[uint64]struct{}
  20938. removedtask_stages map[uint64]struct{}
  20939. clearedtask_stages bool
  20940. done bool
  20941. oldValue func(context.Context) (*SopTask, error)
  20942. predicates []predicate.SopTask
  20943. }
  20944. var _ ent.Mutation = (*SopTaskMutation)(nil)
  20945. // soptaskOption allows management of the mutation configuration using functional options.
  20946. type soptaskOption func(*SopTaskMutation)
  20947. // newSopTaskMutation creates new mutation for the SopTask entity.
  20948. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  20949. m := &SopTaskMutation{
  20950. config: c,
  20951. op: op,
  20952. typ: TypeSopTask,
  20953. clearedFields: make(map[string]struct{}),
  20954. }
  20955. for _, opt := range opts {
  20956. opt(m)
  20957. }
  20958. return m
  20959. }
  20960. // withSopTaskID sets the ID field of the mutation.
  20961. func withSopTaskID(id uint64) soptaskOption {
  20962. return func(m *SopTaskMutation) {
  20963. var (
  20964. err error
  20965. once sync.Once
  20966. value *SopTask
  20967. )
  20968. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  20969. once.Do(func() {
  20970. if m.done {
  20971. err = errors.New("querying old values post mutation is not allowed")
  20972. } else {
  20973. value, err = m.Client().SopTask.Get(ctx, id)
  20974. }
  20975. })
  20976. return value, err
  20977. }
  20978. m.id = &id
  20979. }
  20980. }
  20981. // withSopTask sets the old SopTask of the mutation.
  20982. func withSopTask(node *SopTask) soptaskOption {
  20983. return func(m *SopTaskMutation) {
  20984. m.oldValue = func(context.Context) (*SopTask, error) {
  20985. return node, nil
  20986. }
  20987. m.id = &node.ID
  20988. }
  20989. }
  20990. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20991. // executed in a transaction (ent.Tx), a transactional client is returned.
  20992. func (m SopTaskMutation) Client() *Client {
  20993. client := &Client{config: m.config}
  20994. client.init()
  20995. return client
  20996. }
  20997. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20998. // it returns an error otherwise.
  20999. func (m SopTaskMutation) Tx() (*Tx, error) {
  21000. if _, ok := m.driver.(*txDriver); !ok {
  21001. return nil, errors.New("ent: mutation is not running in a transaction")
  21002. }
  21003. tx := &Tx{config: m.config}
  21004. tx.init()
  21005. return tx, nil
  21006. }
  21007. // SetID sets the value of the id field. Note that this
  21008. // operation is only accepted on creation of SopTask entities.
  21009. func (m *SopTaskMutation) SetID(id uint64) {
  21010. m.id = &id
  21011. }
  21012. // ID returns the ID value in the mutation. Note that the ID is only available
  21013. // if it was provided to the builder or after it was returned from the database.
  21014. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  21015. if m.id == nil {
  21016. return
  21017. }
  21018. return *m.id, true
  21019. }
  21020. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21021. // That means, if the mutation is applied within a transaction with an isolation level such
  21022. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21023. // or updated by the mutation.
  21024. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  21025. switch {
  21026. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21027. id, exists := m.ID()
  21028. if exists {
  21029. return []uint64{id}, nil
  21030. }
  21031. fallthrough
  21032. case m.op.Is(OpUpdate | OpDelete):
  21033. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  21034. default:
  21035. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21036. }
  21037. }
  21038. // SetCreatedAt sets the "created_at" field.
  21039. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  21040. m.created_at = &t
  21041. }
  21042. // CreatedAt returns the value of the "created_at" field in the mutation.
  21043. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  21044. v := m.created_at
  21045. if v == nil {
  21046. return
  21047. }
  21048. return *v, true
  21049. }
  21050. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  21051. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21053. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21054. if !m.op.Is(OpUpdateOne) {
  21055. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21056. }
  21057. if m.id == nil || m.oldValue == nil {
  21058. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21059. }
  21060. oldValue, err := m.oldValue(ctx)
  21061. if err != nil {
  21062. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21063. }
  21064. return oldValue.CreatedAt, nil
  21065. }
  21066. // ResetCreatedAt resets all changes to the "created_at" field.
  21067. func (m *SopTaskMutation) ResetCreatedAt() {
  21068. m.created_at = nil
  21069. }
  21070. // SetUpdatedAt sets the "updated_at" field.
  21071. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  21072. m.updated_at = &t
  21073. }
  21074. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21075. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  21076. v := m.updated_at
  21077. if v == nil {
  21078. return
  21079. }
  21080. return *v, true
  21081. }
  21082. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  21083. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21085. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21086. if !m.op.Is(OpUpdateOne) {
  21087. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21088. }
  21089. if m.id == nil || m.oldValue == nil {
  21090. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21091. }
  21092. oldValue, err := m.oldValue(ctx)
  21093. if err != nil {
  21094. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21095. }
  21096. return oldValue.UpdatedAt, nil
  21097. }
  21098. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21099. func (m *SopTaskMutation) ResetUpdatedAt() {
  21100. m.updated_at = nil
  21101. }
  21102. // SetStatus sets the "status" field.
  21103. func (m *SopTaskMutation) SetStatus(u uint8) {
  21104. m.status = &u
  21105. m.addstatus = nil
  21106. }
  21107. // Status returns the value of the "status" field in the mutation.
  21108. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  21109. v := m.status
  21110. if v == nil {
  21111. return
  21112. }
  21113. return *v, true
  21114. }
  21115. // OldStatus returns the old "status" field's value of the SopTask entity.
  21116. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21118. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21119. if !m.op.Is(OpUpdateOne) {
  21120. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21121. }
  21122. if m.id == nil || m.oldValue == nil {
  21123. return v, errors.New("OldStatus requires an ID field in the mutation")
  21124. }
  21125. oldValue, err := m.oldValue(ctx)
  21126. if err != nil {
  21127. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21128. }
  21129. return oldValue.Status, nil
  21130. }
  21131. // AddStatus adds u to the "status" field.
  21132. func (m *SopTaskMutation) AddStatus(u int8) {
  21133. if m.addstatus != nil {
  21134. *m.addstatus += u
  21135. } else {
  21136. m.addstatus = &u
  21137. }
  21138. }
  21139. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21140. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  21141. v := m.addstatus
  21142. if v == nil {
  21143. return
  21144. }
  21145. return *v, true
  21146. }
  21147. // ClearStatus clears the value of the "status" field.
  21148. func (m *SopTaskMutation) ClearStatus() {
  21149. m.status = nil
  21150. m.addstatus = nil
  21151. m.clearedFields[soptask.FieldStatus] = struct{}{}
  21152. }
  21153. // StatusCleared returns if the "status" field was cleared in this mutation.
  21154. func (m *SopTaskMutation) StatusCleared() bool {
  21155. _, ok := m.clearedFields[soptask.FieldStatus]
  21156. return ok
  21157. }
  21158. // ResetStatus resets all changes to the "status" field.
  21159. func (m *SopTaskMutation) ResetStatus() {
  21160. m.status = nil
  21161. m.addstatus = nil
  21162. delete(m.clearedFields, soptask.FieldStatus)
  21163. }
  21164. // SetDeletedAt sets the "deleted_at" field.
  21165. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  21166. m.deleted_at = &t
  21167. }
  21168. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21169. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  21170. v := m.deleted_at
  21171. if v == nil {
  21172. return
  21173. }
  21174. return *v, true
  21175. }
  21176. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  21177. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21179. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21180. if !m.op.Is(OpUpdateOne) {
  21181. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21182. }
  21183. if m.id == nil || m.oldValue == nil {
  21184. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21185. }
  21186. oldValue, err := m.oldValue(ctx)
  21187. if err != nil {
  21188. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21189. }
  21190. return oldValue.DeletedAt, nil
  21191. }
  21192. // ClearDeletedAt clears the value of the "deleted_at" field.
  21193. func (m *SopTaskMutation) ClearDeletedAt() {
  21194. m.deleted_at = nil
  21195. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  21196. }
  21197. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21198. func (m *SopTaskMutation) DeletedAtCleared() bool {
  21199. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  21200. return ok
  21201. }
  21202. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21203. func (m *SopTaskMutation) ResetDeletedAt() {
  21204. m.deleted_at = nil
  21205. delete(m.clearedFields, soptask.FieldDeletedAt)
  21206. }
  21207. // SetName sets the "name" field.
  21208. func (m *SopTaskMutation) SetName(s string) {
  21209. m.name = &s
  21210. }
  21211. // Name returns the value of the "name" field in the mutation.
  21212. func (m *SopTaskMutation) Name() (r string, exists bool) {
  21213. v := m.name
  21214. if v == nil {
  21215. return
  21216. }
  21217. return *v, true
  21218. }
  21219. // OldName returns the old "name" field's value of the SopTask entity.
  21220. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21222. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  21223. if !m.op.Is(OpUpdateOne) {
  21224. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21225. }
  21226. if m.id == nil || m.oldValue == nil {
  21227. return v, errors.New("OldName requires an ID field in the mutation")
  21228. }
  21229. oldValue, err := m.oldValue(ctx)
  21230. if err != nil {
  21231. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21232. }
  21233. return oldValue.Name, nil
  21234. }
  21235. // ResetName resets all changes to the "name" field.
  21236. func (m *SopTaskMutation) ResetName() {
  21237. m.name = nil
  21238. }
  21239. // SetBotWxidList sets the "bot_wxid_list" field.
  21240. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  21241. m.bot_wxid_list = &s
  21242. m.appendbot_wxid_list = nil
  21243. }
  21244. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  21245. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  21246. v := m.bot_wxid_list
  21247. if v == nil {
  21248. return
  21249. }
  21250. return *v, true
  21251. }
  21252. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  21253. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21255. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  21256. if !m.op.Is(OpUpdateOne) {
  21257. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  21258. }
  21259. if m.id == nil || m.oldValue == nil {
  21260. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  21261. }
  21262. oldValue, err := m.oldValue(ctx)
  21263. if err != nil {
  21264. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  21265. }
  21266. return oldValue.BotWxidList, nil
  21267. }
  21268. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  21269. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  21270. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  21271. }
  21272. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  21273. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  21274. if len(m.appendbot_wxid_list) == 0 {
  21275. return nil, false
  21276. }
  21277. return m.appendbot_wxid_list, true
  21278. }
  21279. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  21280. func (m *SopTaskMutation) ClearBotWxidList() {
  21281. m.bot_wxid_list = nil
  21282. m.appendbot_wxid_list = nil
  21283. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  21284. }
  21285. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  21286. func (m *SopTaskMutation) BotWxidListCleared() bool {
  21287. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  21288. return ok
  21289. }
  21290. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  21291. func (m *SopTaskMutation) ResetBotWxidList() {
  21292. m.bot_wxid_list = nil
  21293. m.appendbot_wxid_list = nil
  21294. delete(m.clearedFields, soptask.FieldBotWxidList)
  21295. }
  21296. // SetType sets the "type" field.
  21297. func (m *SopTaskMutation) SetType(i int) {
  21298. m._type = &i
  21299. m.add_type = nil
  21300. }
  21301. // GetType returns the value of the "type" field in the mutation.
  21302. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  21303. v := m._type
  21304. if v == nil {
  21305. return
  21306. }
  21307. return *v, true
  21308. }
  21309. // OldType returns the old "type" field's value of the SopTask entity.
  21310. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21312. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  21313. if !m.op.Is(OpUpdateOne) {
  21314. return v, errors.New("OldType is only allowed on UpdateOne operations")
  21315. }
  21316. if m.id == nil || m.oldValue == nil {
  21317. return v, errors.New("OldType requires an ID field in the mutation")
  21318. }
  21319. oldValue, err := m.oldValue(ctx)
  21320. if err != nil {
  21321. return v, fmt.Errorf("querying old value for OldType: %w", err)
  21322. }
  21323. return oldValue.Type, nil
  21324. }
  21325. // AddType adds i to the "type" field.
  21326. func (m *SopTaskMutation) AddType(i int) {
  21327. if m.add_type != nil {
  21328. *m.add_type += i
  21329. } else {
  21330. m.add_type = &i
  21331. }
  21332. }
  21333. // AddedType returns the value that was added to the "type" field in this mutation.
  21334. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  21335. v := m.add_type
  21336. if v == nil {
  21337. return
  21338. }
  21339. return *v, true
  21340. }
  21341. // ResetType resets all changes to the "type" field.
  21342. func (m *SopTaskMutation) ResetType() {
  21343. m._type = nil
  21344. m.add_type = nil
  21345. }
  21346. // SetPlanStartTime sets the "plan_start_time" field.
  21347. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  21348. m.plan_start_time = &t
  21349. }
  21350. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  21351. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  21352. v := m.plan_start_time
  21353. if v == nil {
  21354. return
  21355. }
  21356. return *v, true
  21357. }
  21358. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  21359. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21361. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  21362. if !m.op.Is(OpUpdateOne) {
  21363. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  21364. }
  21365. if m.id == nil || m.oldValue == nil {
  21366. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  21367. }
  21368. oldValue, err := m.oldValue(ctx)
  21369. if err != nil {
  21370. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  21371. }
  21372. return oldValue.PlanStartTime, nil
  21373. }
  21374. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  21375. func (m *SopTaskMutation) ClearPlanStartTime() {
  21376. m.plan_start_time = nil
  21377. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  21378. }
  21379. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  21380. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  21381. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  21382. return ok
  21383. }
  21384. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  21385. func (m *SopTaskMutation) ResetPlanStartTime() {
  21386. m.plan_start_time = nil
  21387. delete(m.clearedFields, soptask.FieldPlanStartTime)
  21388. }
  21389. // SetPlanEndTime sets the "plan_end_time" field.
  21390. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  21391. m.plan_end_time = &t
  21392. }
  21393. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  21394. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  21395. v := m.plan_end_time
  21396. if v == nil {
  21397. return
  21398. }
  21399. return *v, true
  21400. }
  21401. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  21402. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21404. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  21405. if !m.op.Is(OpUpdateOne) {
  21406. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  21407. }
  21408. if m.id == nil || m.oldValue == nil {
  21409. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  21410. }
  21411. oldValue, err := m.oldValue(ctx)
  21412. if err != nil {
  21413. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  21414. }
  21415. return oldValue.PlanEndTime, nil
  21416. }
  21417. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  21418. func (m *SopTaskMutation) ClearPlanEndTime() {
  21419. m.plan_end_time = nil
  21420. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  21421. }
  21422. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  21423. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  21424. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  21425. return ok
  21426. }
  21427. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  21428. func (m *SopTaskMutation) ResetPlanEndTime() {
  21429. m.plan_end_time = nil
  21430. delete(m.clearedFields, soptask.FieldPlanEndTime)
  21431. }
  21432. // SetCreatorID sets the "creator_id" field.
  21433. func (m *SopTaskMutation) SetCreatorID(s string) {
  21434. m.creator_id = &s
  21435. }
  21436. // CreatorID returns the value of the "creator_id" field in the mutation.
  21437. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  21438. v := m.creator_id
  21439. if v == nil {
  21440. return
  21441. }
  21442. return *v, true
  21443. }
  21444. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  21445. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21447. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  21448. if !m.op.Is(OpUpdateOne) {
  21449. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  21450. }
  21451. if m.id == nil || m.oldValue == nil {
  21452. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  21453. }
  21454. oldValue, err := m.oldValue(ctx)
  21455. if err != nil {
  21456. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  21457. }
  21458. return oldValue.CreatorID, nil
  21459. }
  21460. // ClearCreatorID clears the value of the "creator_id" field.
  21461. func (m *SopTaskMutation) ClearCreatorID() {
  21462. m.creator_id = nil
  21463. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  21464. }
  21465. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  21466. func (m *SopTaskMutation) CreatorIDCleared() bool {
  21467. _, ok := m.clearedFields[soptask.FieldCreatorID]
  21468. return ok
  21469. }
  21470. // ResetCreatorID resets all changes to the "creator_id" field.
  21471. func (m *SopTaskMutation) ResetCreatorID() {
  21472. m.creator_id = nil
  21473. delete(m.clearedFields, soptask.FieldCreatorID)
  21474. }
  21475. // SetOrganizationID sets the "organization_id" field.
  21476. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  21477. m.organization_id = &u
  21478. m.addorganization_id = nil
  21479. }
  21480. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21481. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  21482. v := m.organization_id
  21483. if v == nil {
  21484. return
  21485. }
  21486. return *v, true
  21487. }
  21488. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  21489. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21491. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21492. if !m.op.Is(OpUpdateOne) {
  21493. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21494. }
  21495. if m.id == nil || m.oldValue == nil {
  21496. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21497. }
  21498. oldValue, err := m.oldValue(ctx)
  21499. if err != nil {
  21500. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21501. }
  21502. return oldValue.OrganizationID, nil
  21503. }
  21504. // AddOrganizationID adds u to the "organization_id" field.
  21505. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  21506. if m.addorganization_id != nil {
  21507. *m.addorganization_id += u
  21508. } else {
  21509. m.addorganization_id = &u
  21510. }
  21511. }
  21512. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21513. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  21514. v := m.addorganization_id
  21515. if v == nil {
  21516. return
  21517. }
  21518. return *v, true
  21519. }
  21520. // ClearOrganizationID clears the value of the "organization_id" field.
  21521. func (m *SopTaskMutation) ClearOrganizationID() {
  21522. m.organization_id = nil
  21523. m.addorganization_id = nil
  21524. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  21525. }
  21526. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21527. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  21528. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  21529. return ok
  21530. }
  21531. // ResetOrganizationID resets all changes to the "organization_id" field.
  21532. func (m *SopTaskMutation) ResetOrganizationID() {
  21533. m.organization_id = nil
  21534. m.addorganization_id = nil
  21535. delete(m.clearedFields, soptask.FieldOrganizationID)
  21536. }
  21537. // SetToken sets the "token" field.
  21538. func (m *SopTaskMutation) SetToken(s []string) {
  21539. m.token = &s
  21540. m.appendtoken = nil
  21541. }
  21542. // Token returns the value of the "token" field in the mutation.
  21543. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  21544. v := m.token
  21545. if v == nil {
  21546. return
  21547. }
  21548. return *v, true
  21549. }
  21550. // OldToken returns the old "token" field's value of the SopTask entity.
  21551. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  21552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21553. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  21554. if !m.op.Is(OpUpdateOne) {
  21555. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  21556. }
  21557. if m.id == nil || m.oldValue == nil {
  21558. return v, errors.New("OldToken requires an ID field in the mutation")
  21559. }
  21560. oldValue, err := m.oldValue(ctx)
  21561. if err != nil {
  21562. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  21563. }
  21564. return oldValue.Token, nil
  21565. }
  21566. // AppendToken adds s to the "token" field.
  21567. func (m *SopTaskMutation) AppendToken(s []string) {
  21568. m.appendtoken = append(m.appendtoken, s...)
  21569. }
  21570. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  21571. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  21572. if len(m.appendtoken) == 0 {
  21573. return nil, false
  21574. }
  21575. return m.appendtoken, true
  21576. }
  21577. // ClearToken clears the value of the "token" field.
  21578. func (m *SopTaskMutation) ClearToken() {
  21579. m.token = nil
  21580. m.appendtoken = nil
  21581. m.clearedFields[soptask.FieldToken] = struct{}{}
  21582. }
  21583. // TokenCleared returns if the "token" field was cleared in this mutation.
  21584. func (m *SopTaskMutation) TokenCleared() bool {
  21585. _, ok := m.clearedFields[soptask.FieldToken]
  21586. return ok
  21587. }
  21588. // ResetToken resets all changes to the "token" field.
  21589. func (m *SopTaskMutation) ResetToken() {
  21590. m.token = nil
  21591. m.appendtoken = nil
  21592. delete(m.clearedFields, soptask.FieldToken)
  21593. }
  21594. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  21595. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  21596. if m.task_stages == nil {
  21597. m.task_stages = make(map[uint64]struct{})
  21598. }
  21599. for i := range ids {
  21600. m.task_stages[ids[i]] = struct{}{}
  21601. }
  21602. }
  21603. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  21604. func (m *SopTaskMutation) ClearTaskStages() {
  21605. m.clearedtask_stages = true
  21606. }
  21607. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  21608. func (m *SopTaskMutation) TaskStagesCleared() bool {
  21609. return m.clearedtask_stages
  21610. }
  21611. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  21612. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  21613. if m.removedtask_stages == nil {
  21614. m.removedtask_stages = make(map[uint64]struct{})
  21615. }
  21616. for i := range ids {
  21617. delete(m.task_stages, ids[i])
  21618. m.removedtask_stages[ids[i]] = struct{}{}
  21619. }
  21620. }
  21621. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  21622. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  21623. for id := range m.removedtask_stages {
  21624. ids = append(ids, id)
  21625. }
  21626. return
  21627. }
  21628. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  21629. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  21630. for id := range m.task_stages {
  21631. ids = append(ids, id)
  21632. }
  21633. return
  21634. }
  21635. // ResetTaskStages resets all changes to the "task_stages" edge.
  21636. func (m *SopTaskMutation) ResetTaskStages() {
  21637. m.task_stages = nil
  21638. m.clearedtask_stages = false
  21639. m.removedtask_stages = nil
  21640. }
  21641. // Where appends a list predicates to the SopTaskMutation builder.
  21642. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  21643. m.predicates = append(m.predicates, ps...)
  21644. }
  21645. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  21646. // users can use type-assertion to append predicates that do not depend on any generated package.
  21647. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  21648. p := make([]predicate.SopTask, len(ps))
  21649. for i := range ps {
  21650. p[i] = ps[i]
  21651. }
  21652. m.Where(p...)
  21653. }
  21654. // Op returns the operation name.
  21655. func (m *SopTaskMutation) Op() Op {
  21656. return m.op
  21657. }
  21658. // SetOp allows setting the mutation operation.
  21659. func (m *SopTaskMutation) SetOp(op Op) {
  21660. m.op = op
  21661. }
  21662. // Type returns the node type of this mutation (SopTask).
  21663. func (m *SopTaskMutation) Type() string {
  21664. return m.typ
  21665. }
  21666. // Fields returns all fields that were changed during this mutation. Note that in
  21667. // order to get all numeric fields that were incremented/decremented, call
  21668. // AddedFields().
  21669. func (m *SopTaskMutation) Fields() []string {
  21670. fields := make([]string, 0, 12)
  21671. if m.created_at != nil {
  21672. fields = append(fields, soptask.FieldCreatedAt)
  21673. }
  21674. if m.updated_at != nil {
  21675. fields = append(fields, soptask.FieldUpdatedAt)
  21676. }
  21677. if m.status != nil {
  21678. fields = append(fields, soptask.FieldStatus)
  21679. }
  21680. if m.deleted_at != nil {
  21681. fields = append(fields, soptask.FieldDeletedAt)
  21682. }
  21683. if m.name != nil {
  21684. fields = append(fields, soptask.FieldName)
  21685. }
  21686. if m.bot_wxid_list != nil {
  21687. fields = append(fields, soptask.FieldBotWxidList)
  21688. }
  21689. if m._type != nil {
  21690. fields = append(fields, soptask.FieldType)
  21691. }
  21692. if m.plan_start_time != nil {
  21693. fields = append(fields, soptask.FieldPlanStartTime)
  21694. }
  21695. if m.plan_end_time != nil {
  21696. fields = append(fields, soptask.FieldPlanEndTime)
  21697. }
  21698. if m.creator_id != nil {
  21699. fields = append(fields, soptask.FieldCreatorID)
  21700. }
  21701. if m.organization_id != nil {
  21702. fields = append(fields, soptask.FieldOrganizationID)
  21703. }
  21704. if m.token != nil {
  21705. fields = append(fields, soptask.FieldToken)
  21706. }
  21707. return fields
  21708. }
  21709. // Field returns the value of a field with the given name. The second boolean
  21710. // return value indicates that this field was not set, or was not defined in the
  21711. // schema.
  21712. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  21713. switch name {
  21714. case soptask.FieldCreatedAt:
  21715. return m.CreatedAt()
  21716. case soptask.FieldUpdatedAt:
  21717. return m.UpdatedAt()
  21718. case soptask.FieldStatus:
  21719. return m.Status()
  21720. case soptask.FieldDeletedAt:
  21721. return m.DeletedAt()
  21722. case soptask.FieldName:
  21723. return m.Name()
  21724. case soptask.FieldBotWxidList:
  21725. return m.BotWxidList()
  21726. case soptask.FieldType:
  21727. return m.GetType()
  21728. case soptask.FieldPlanStartTime:
  21729. return m.PlanStartTime()
  21730. case soptask.FieldPlanEndTime:
  21731. return m.PlanEndTime()
  21732. case soptask.FieldCreatorID:
  21733. return m.CreatorID()
  21734. case soptask.FieldOrganizationID:
  21735. return m.OrganizationID()
  21736. case soptask.FieldToken:
  21737. return m.Token()
  21738. }
  21739. return nil, false
  21740. }
  21741. // OldField returns the old value of the field from the database. An error is
  21742. // returned if the mutation operation is not UpdateOne, or the query to the
  21743. // database failed.
  21744. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21745. switch name {
  21746. case soptask.FieldCreatedAt:
  21747. return m.OldCreatedAt(ctx)
  21748. case soptask.FieldUpdatedAt:
  21749. return m.OldUpdatedAt(ctx)
  21750. case soptask.FieldStatus:
  21751. return m.OldStatus(ctx)
  21752. case soptask.FieldDeletedAt:
  21753. return m.OldDeletedAt(ctx)
  21754. case soptask.FieldName:
  21755. return m.OldName(ctx)
  21756. case soptask.FieldBotWxidList:
  21757. return m.OldBotWxidList(ctx)
  21758. case soptask.FieldType:
  21759. return m.OldType(ctx)
  21760. case soptask.FieldPlanStartTime:
  21761. return m.OldPlanStartTime(ctx)
  21762. case soptask.FieldPlanEndTime:
  21763. return m.OldPlanEndTime(ctx)
  21764. case soptask.FieldCreatorID:
  21765. return m.OldCreatorID(ctx)
  21766. case soptask.FieldOrganizationID:
  21767. return m.OldOrganizationID(ctx)
  21768. case soptask.FieldToken:
  21769. return m.OldToken(ctx)
  21770. }
  21771. return nil, fmt.Errorf("unknown SopTask field %s", name)
  21772. }
  21773. // SetField sets the value of a field with the given name. It returns an error if
  21774. // the field is not defined in the schema, or if the type mismatched the field
  21775. // type.
  21776. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  21777. switch name {
  21778. case soptask.FieldCreatedAt:
  21779. v, ok := value.(time.Time)
  21780. if !ok {
  21781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21782. }
  21783. m.SetCreatedAt(v)
  21784. return nil
  21785. case soptask.FieldUpdatedAt:
  21786. v, ok := value.(time.Time)
  21787. if !ok {
  21788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21789. }
  21790. m.SetUpdatedAt(v)
  21791. return nil
  21792. case soptask.FieldStatus:
  21793. v, ok := value.(uint8)
  21794. if !ok {
  21795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21796. }
  21797. m.SetStatus(v)
  21798. return nil
  21799. case soptask.FieldDeletedAt:
  21800. v, ok := value.(time.Time)
  21801. if !ok {
  21802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21803. }
  21804. m.SetDeletedAt(v)
  21805. return nil
  21806. case soptask.FieldName:
  21807. v, ok := value.(string)
  21808. if !ok {
  21809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21810. }
  21811. m.SetName(v)
  21812. return nil
  21813. case soptask.FieldBotWxidList:
  21814. v, ok := value.([]string)
  21815. if !ok {
  21816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21817. }
  21818. m.SetBotWxidList(v)
  21819. return nil
  21820. case soptask.FieldType:
  21821. v, ok := value.(int)
  21822. if !ok {
  21823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21824. }
  21825. m.SetType(v)
  21826. return nil
  21827. case soptask.FieldPlanStartTime:
  21828. v, ok := value.(time.Time)
  21829. if !ok {
  21830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21831. }
  21832. m.SetPlanStartTime(v)
  21833. return nil
  21834. case soptask.FieldPlanEndTime:
  21835. v, ok := value.(time.Time)
  21836. if !ok {
  21837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21838. }
  21839. m.SetPlanEndTime(v)
  21840. return nil
  21841. case soptask.FieldCreatorID:
  21842. v, ok := value.(string)
  21843. if !ok {
  21844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21845. }
  21846. m.SetCreatorID(v)
  21847. return nil
  21848. case soptask.FieldOrganizationID:
  21849. v, ok := value.(uint64)
  21850. if !ok {
  21851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21852. }
  21853. m.SetOrganizationID(v)
  21854. return nil
  21855. case soptask.FieldToken:
  21856. v, ok := value.([]string)
  21857. if !ok {
  21858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21859. }
  21860. m.SetToken(v)
  21861. return nil
  21862. }
  21863. return fmt.Errorf("unknown SopTask field %s", name)
  21864. }
  21865. // AddedFields returns all numeric fields that were incremented/decremented during
  21866. // this mutation.
  21867. func (m *SopTaskMutation) AddedFields() []string {
  21868. var fields []string
  21869. if m.addstatus != nil {
  21870. fields = append(fields, soptask.FieldStatus)
  21871. }
  21872. if m.add_type != nil {
  21873. fields = append(fields, soptask.FieldType)
  21874. }
  21875. if m.addorganization_id != nil {
  21876. fields = append(fields, soptask.FieldOrganizationID)
  21877. }
  21878. return fields
  21879. }
  21880. // AddedField returns the numeric value that was incremented/decremented on a field
  21881. // with the given name. The second boolean return value indicates that this field
  21882. // was not set, or was not defined in the schema.
  21883. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  21884. switch name {
  21885. case soptask.FieldStatus:
  21886. return m.AddedStatus()
  21887. case soptask.FieldType:
  21888. return m.AddedType()
  21889. case soptask.FieldOrganizationID:
  21890. return m.AddedOrganizationID()
  21891. }
  21892. return nil, false
  21893. }
  21894. // AddField adds the value to the field with the given name. It returns an error if
  21895. // the field is not defined in the schema, or if the type mismatched the field
  21896. // type.
  21897. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  21898. switch name {
  21899. case soptask.FieldStatus:
  21900. v, ok := value.(int8)
  21901. if !ok {
  21902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21903. }
  21904. m.AddStatus(v)
  21905. return nil
  21906. case soptask.FieldType:
  21907. v, ok := value.(int)
  21908. if !ok {
  21909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21910. }
  21911. m.AddType(v)
  21912. return nil
  21913. case soptask.FieldOrganizationID:
  21914. v, ok := value.(int64)
  21915. if !ok {
  21916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21917. }
  21918. m.AddOrganizationID(v)
  21919. return nil
  21920. }
  21921. return fmt.Errorf("unknown SopTask numeric field %s", name)
  21922. }
  21923. // ClearedFields returns all nullable fields that were cleared during this
  21924. // mutation.
  21925. func (m *SopTaskMutation) ClearedFields() []string {
  21926. var fields []string
  21927. if m.FieldCleared(soptask.FieldStatus) {
  21928. fields = append(fields, soptask.FieldStatus)
  21929. }
  21930. if m.FieldCleared(soptask.FieldDeletedAt) {
  21931. fields = append(fields, soptask.FieldDeletedAt)
  21932. }
  21933. if m.FieldCleared(soptask.FieldBotWxidList) {
  21934. fields = append(fields, soptask.FieldBotWxidList)
  21935. }
  21936. if m.FieldCleared(soptask.FieldPlanStartTime) {
  21937. fields = append(fields, soptask.FieldPlanStartTime)
  21938. }
  21939. if m.FieldCleared(soptask.FieldPlanEndTime) {
  21940. fields = append(fields, soptask.FieldPlanEndTime)
  21941. }
  21942. if m.FieldCleared(soptask.FieldCreatorID) {
  21943. fields = append(fields, soptask.FieldCreatorID)
  21944. }
  21945. if m.FieldCleared(soptask.FieldOrganizationID) {
  21946. fields = append(fields, soptask.FieldOrganizationID)
  21947. }
  21948. if m.FieldCleared(soptask.FieldToken) {
  21949. fields = append(fields, soptask.FieldToken)
  21950. }
  21951. return fields
  21952. }
  21953. // FieldCleared returns a boolean indicating if a field with the given name was
  21954. // cleared in this mutation.
  21955. func (m *SopTaskMutation) FieldCleared(name string) bool {
  21956. _, ok := m.clearedFields[name]
  21957. return ok
  21958. }
  21959. // ClearField clears the value of the field with the given name. It returns an
  21960. // error if the field is not defined in the schema.
  21961. func (m *SopTaskMutation) ClearField(name string) error {
  21962. switch name {
  21963. case soptask.FieldStatus:
  21964. m.ClearStatus()
  21965. return nil
  21966. case soptask.FieldDeletedAt:
  21967. m.ClearDeletedAt()
  21968. return nil
  21969. case soptask.FieldBotWxidList:
  21970. m.ClearBotWxidList()
  21971. return nil
  21972. case soptask.FieldPlanStartTime:
  21973. m.ClearPlanStartTime()
  21974. return nil
  21975. case soptask.FieldPlanEndTime:
  21976. m.ClearPlanEndTime()
  21977. return nil
  21978. case soptask.FieldCreatorID:
  21979. m.ClearCreatorID()
  21980. return nil
  21981. case soptask.FieldOrganizationID:
  21982. m.ClearOrganizationID()
  21983. return nil
  21984. case soptask.FieldToken:
  21985. m.ClearToken()
  21986. return nil
  21987. }
  21988. return fmt.Errorf("unknown SopTask nullable field %s", name)
  21989. }
  21990. // ResetField resets all changes in the mutation for the field with the given name.
  21991. // It returns an error if the field is not defined in the schema.
  21992. func (m *SopTaskMutation) ResetField(name string) error {
  21993. switch name {
  21994. case soptask.FieldCreatedAt:
  21995. m.ResetCreatedAt()
  21996. return nil
  21997. case soptask.FieldUpdatedAt:
  21998. m.ResetUpdatedAt()
  21999. return nil
  22000. case soptask.FieldStatus:
  22001. m.ResetStatus()
  22002. return nil
  22003. case soptask.FieldDeletedAt:
  22004. m.ResetDeletedAt()
  22005. return nil
  22006. case soptask.FieldName:
  22007. m.ResetName()
  22008. return nil
  22009. case soptask.FieldBotWxidList:
  22010. m.ResetBotWxidList()
  22011. return nil
  22012. case soptask.FieldType:
  22013. m.ResetType()
  22014. return nil
  22015. case soptask.FieldPlanStartTime:
  22016. m.ResetPlanStartTime()
  22017. return nil
  22018. case soptask.FieldPlanEndTime:
  22019. m.ResetPlanEndTime()
  22020. return nil
  22021. case soptask.FieldCreatorID:
  22022. m.ResetCreatorID()
  22023. return nil
  22024. case soptask.FieldOrganizationID:
  22025. m.ResetOrganizationID()
  22026. return nil
  22027. case soptask.FieldToken:
  22028. m.ResetToken()
  22029. return nil
  22030. }
  22031. return fmt.Errorf("unknown SopTask field %s", name)
  22032. }
  22033. // AddedEdges returns all edge names that were set/added in this mutation.
  22034. func (m *SopTaskMutation) AddedEdges() []string {
  22035. edges := make([]string, 0, 1)
  22036. if m.task_stages != nil {
  22037. edges = append(edges, soptask.EdgeTaskStages)
  22038. }
  22039. return edges
  22040. }
  22041. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22042. // name in this mutation.
  22043. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  22044. switch name {
  22045. case soptask.EdgeTaskStages:
  22046. ids := make([]ent.Value, 0, len(m.task_stages))
  22047. for id := range m.task_stages {
  22048. ids = append(ids, id)
  22049. }
  22050. return ids
  22051. }
  22052. return nil
  22053. }
  22054. // RemovedEdges returns all edge names that were removed in this mutation.
  22055. func (m *SopTaskMutation) RemovedEdges() []string {
  22056. edges := make([]string, 0, 1)
  22057. if m.removedtask_stages != nil {
  22058. edges = append(edges, soptask.EdgeTaskStages)
  22059. }
  22060. return edges
  22061. }
  22062. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22063. // the given name in this mutation.
  22064. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  22065. switch name {
  22066. case soptask.EdgeTaskStages:
  22067. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  22068. for id := range m.removedtask_stages {
  22069. ids = append(ids, id)
  22070. }
  22071. return ids
  22072. }
  22073. return nil
  22074. }
  22075. // ClearedEdges returns all edge names that were cleared in this mutation.
  22076. func (m *SopTaskMutation) ClearedEdges() []string {
  22077. edges := make([]string, 0, 1)
  22078. if m.clearedtask_stages {
  22079. edges = append(edges, soptask.EdgeTaskStages)
  22080. }
  22081. return edges
  22082. }
  22083. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22084. // was cleared in this mutation.
  22085. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  22086. switch name {
  22087. case soptask.EdgeTaskStages:
  22088. return m.clearedtask_stages
  22089. }
  22090. return false
  22091. }
  22092. // ClearEdge clears the value of the edge with the given name. It returns an error
  22093. // if that edge is not defined in the schema.
  22094. func (m *SopTaskMutation) ClearEdge(name string) error {
  22095. switch name {
  22096. }
  22097. return fmt.Errorf("unknown SopTask unique edge %s", name)
  22098. }
  22099. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22100. // It returns an error if the edge is not defined in the schema.
  22101. func (m *SopTaskMutation) ResetEdge(name string) error {
  22102. switch name {
  22103. case soptask.EdgeTaskStages:
  22104. m.ResetTaskStages()
  22105. return nil
  22106. }
  22107. return fmt.Errorf("unknown SopTask edge %s", name)
  22108. }
  22109. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  22110. type TokenMutation struct {
  22111. config
  22112. op Op
  22113. typ string
  22114. id *uint64
  22115. created_at *time.Time
  22116. updated_at *time.Time
  22117. deleted_at *time.Time
  22118. expire_at *time.Time
  22119. token *string
  22120. mac *string
  22121. organization_id *uint64
  22122. addorganization_id *int64
  22123. custom_agent_base *string
  22124. custom_agent_key *string
  22125. openai_base *string
  22126. openai_key *string
  22127. clearedFields map[string]struct{}
  22128. agent *uint64
  22129. clearedagent bool
  22130. done bool
  22131. oldValue func(context.Context) (*Token, error)
  22132. predicates []predicate.Token
  22133. }
  22134. var _ ent.Mutation = (*TokenMutation)(nil)
  22135. // tokenOption allows management of the mutation configuration using functional options.
  22136. type tokenOption func(*TokenMutation)
  22137. // newTokenMutation creates new mutation for the Token entity.
  22138. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  22139. m := &TokenMutation{
  22140. config: c,
  22141. op: op,
  22142. typ: TypeToken,
  22143. clearedFields: make(map[string]struct{}),
  22144. }
  22145. for _, opt := range opts {
  22146. opt(m)
  22147. }
  22148. return m
  22149. }
  22150. // withTokenID sets the ID field of the mutation.
  22151. func withTokenID(id uint64) tokenOption {
  22152. return func(m *TokenMutation) {
  22153. var (
  22154. err error
  22155. once sync.Once
  22156. value *Token
  22157. )
  22158. m.oldValue = func(ctx context.Context) (*Token, error) {
  22159. once.Do(func() {
  22160. if m.done {
  22161. err = errors.New("querying old values post mutation is not allowed")
  22162. } else {
  22163. value, err = m.Client().Token.Get(ctx, id)
  22164. }
  22165. })
  22166. return value, err
  22167. }
  22168. m.id = &id
  22169. }
  22170. }
  22171. // withToken sets the old Token of the mutation.
  22172. func withToken(node *Token) tokenOption {
  22173. return func(m *TokenMutation) {
  22174. m.oldValue = func(context.Context) (*Token, error) {
  22175. return node, nil
  22176. }
  22177. m.id = &node.ID
  22178. }
  22179. }
  22180. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22181. // executed in a transaction (ent.Tx), a transactional client is returned.
  22182. func (m TokenMutation) Client() *Client {
  22183. client := &Client{config: m.config}
  22184. client.init()
  22185. return client
  22186. }
  22187. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22188. // it returns an error otherwise.
  22189. func (m TokenMutation) Tx() (*Tx, error) {
  22190. if _, ok := m.driver.(*txDriver); !ok {
  22191. return nil, errors.New("ent: mutation is not running in a transaction")
  22192. }
  22193. tx := &Tx{config: m.config}
  22194. tx.init()
  22195. return tx, nil
  22196. }
  22197. // SetID sets the value of the id field. Note that this
  22198. // operation is only accepted on creation of Token entities.
  22199. func (m *TokenMutation) SetID(id uint64) {
  22200. m.id = &id
  22201. }
  22202. // ID returns the ID value in the mutation. Note that the ID is only available
  22203. // if it was provided to the builder or after it was returned from the database.
  22204. func (m *TokenMutation) ID() (id uint64, exists bool) {
  22205. if m.id == nil {
  22206. return
  22207. }
  22208. return *m.id, true
  22209. }
  22210. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22211. // That means, if the mutation is applied within a transaction with an isolation level such
  22212. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22213. // or updated by the mutation.
  22214. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  22215. switch {
  22216. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22217. id, exists := m.ID()
  22218. if exists {
  22219. return []uint64{id}, nil
  22220. }
  22221. fallthrough
  22222. case m.op.Is(OpUpdate | OpDelete):
  22223. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  22224. default:
  22225. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22226. }
  22227. }
  22228. // SetCreatedAt sets the "created_at" field.
  22229. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  22230. m.created_at = &t
  22231. }
  22232. // CreatedAt returns the value of the "created_at" field in the mutation.
  22233. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  22234. v := m.created_at
  22235. if v == nil {
  22236. return
  22237. }
  22238. return *v, true
  22239. }
  22240. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  22241. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22243. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22244. if !m.op.Is(OpUpdateOne) {
  22245. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22246. }
  22247. if m.id == nil || m.oldValue == nil {
  22248. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22249. }
  22250. oldValue, err := m.oldValue(ctx)
  22251. if err != nil {
  22252. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22253. }
  22254. return oldValue.CreatedAt, nil
  22255. }
  22256. // ResetCreatedAt resets all changes to the "created_at" field.
  22257. func (m *TokenMutation) ResetCreatedAt() {
  22258. m.created_at = nil
  22259. }
  22260. // SetUpdatedAt sets the "updated_at" field.
  22261. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  22262. m.updated_at = &t
  22263. }
  22264. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22265. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  22266. v := m.updated_at
  22267. if v == nil {
  22268. return
  22269. }
  22270. return *v, true
  22271. }
  22272. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  22273. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22275. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22276. if !m.op.Is(OpUpdateOne) {
  22277. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22278. }
  22279. if m.id == nil || m.oldValue == nil {
  22280. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22281. }
  22282. oldValue, err := m.oldValue(ctx)
  22283. if err != nil {
  22284. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22285. }
  22286. return oldValue.UpdatedAt, nil
  22287. }
  22288. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22289. func (m *TokenMutation) ResetUpdatedAt() {
  22290. m.updated_at = nil
  22291. }
  22292. // SetDeletedAt sets the "deleted_at" field.
  22293. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  22294. m.deleted_at = &t
  22295. }
  22296. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22297. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  22298. v := m.deleted_at
  22299. if v == nil {
  22300. return
  22301. }
  22302. return *v, true
  22303. }
  22304. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  22305. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22307. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22308. if !m.op.Is(OpUpdateOne) {
  22309. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22310. }
  22311. if m.id == nil || m.oldValue == nil {
  22312. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22313. }
  22314. oldValue, err := m.oldValue(ctx)
  22315. if err != nil {
  22316. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22317. }
  22318. return oldValue.DeletedAt, nil
  22319. }
  22320. // ClearDeletedAt clears the value of the "deleted_at" field.
  22321. func (m *TokenMutation) ClearDeletedAt() {
  22322. m.deleted_at = nil
  22323. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  22324. }
  22325. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22326. func (m *TokenMutation) DeletedAtCleared() bool {
  22327. _, ok := m.clearedFields[token.FieldDeletedAt]
  22328. return ok
  22329. }
  22330. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22331. func (m *TokenMutation) ResetDeletedAt() {
  22332. m.deleted_at = nil
  22333. delete(m.clearedFields, token.FieldDeletedAt)
  22334. }
  22335. // SetExpireAt sets the "expire_at" field.
  22336. func (m *TokenMutation) SetExpireAt(t time.Time) {
  22337. m.expire_at = &t
  22338. }
  22339. // ExpireAt returns the value of the "expire_at" field in the mutation.
  22340. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  22341. v := m.expire_at
  22342. if v == nil {
  22343. return
  22344. }
  22345. return *v, true
  22346. }
  22347. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  22348. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22350. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  22351. if !m.op.Is(OpUpdateOne) {
  22352. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  22353. }
  22354. if m.id == nil || m.oldValue == nil {
  22355. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  22356. }
  22357. oldValue, err := m.oldValue(ctx)
  22358. if err != nil {
  22359. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  22360. }
  22361. return oldValue.ExpireAt, nil
  22362. }
  22363. // ClearExpireAt clears the value of the "expire_at" field.
  22364. func (m *TokenMutation) ClearExpireAt() {
  22365. m.expire_at = nil
  22366. m.clearedFields[token.FieldExpireAt] = struct{}{}
  22367. }
  22368. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  22369. func (m *TokenMutation) ExpireAtCleared() bool {
  22370. _, ok := m.clearedFields[token.FieldExpireAt]
  22371. return ok
  22372. }
  22373. // ResetExpireAt resets all changes to the "expire_at" field.
  22374. func (m *TokenMutation) ResetExpireAt() {
  22375. m.expire_at = nil
  22376. delete(m.clearedFields, token.FieldExpireAt)
  22377. }
  22378. // SetToken sets the "token" field.
  22379. func (m *TokenMutation) SetToken(s string) {
  22380. m.token = &s
  22381. }
  22382. // Token returns the value of the "token" field in the mutation.
  22383. func (m *TokenMutation) Token() (r string, exists bool) {
  22384. v := m.token
  22385. if v == nil {
  22386. return
  22387. }
  22388. return *v, true
  22389. }
  22390. // OldToken returns the old "token" field's value of the Token entity.
  22391. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22393. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  22394. if !m.op.Is(OpUpdateOne) {
  22395. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  22396. }
  22397. if m.id == nil || m.oldValue == nil {
  22398. return v, errors.New("OldToken requires an ID field in the mutation")
  22399. }
  22400. oldValue, err := m.oldValue(ctx)
  22401. if err != nil {
  22402. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  22403. }
  22404. return oldValue.Token, nil
  22405. }
  22406. // ClearToken clears the value of the "token" field.
  22407. func (m *TokenMutation) ClearToken() {
  22408. m.token = nil
  22409. m.clearedFields[token.FieldToken] = struct{}{}
  22410. }
  22411. // TokenCleared returns if the "token" field was cleared in this mutation.
  22412. func (m *TokenMutation) TokenCleared() bool {
  22413. _, ok := m.clearedFields[token.FieldToken]
  22414. return ok
  22415. }
  22416. // ResetToken resets all changes to the "token" field.
  22417. func (m *TokenMutation) ResetToken() {
  22418. m.token = nil
  22419. delete(m.clearedFields, token.FieldToken)
  22420. }
  22421. // SetMAC sets the "mac" field.
  22422. func (m *TokenMutation) SetMAC(s string) {
  22423. m.mac = &s
  22424. }
  22425. // MAC returns the value of the "mac" field in the mutation.
  22426. func (m *TokenMutation) MAC() (r string, exists bool) {
  22427. v := m.mac
  22428. if v == nil {
  22429. return
  22430. }
  22431. return *v, true
  22432. }
  22433. // OldMAC returns the old "mac" field's value of the Token entity.
  22434. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22436. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  22437. if !m.op.Is(OpUpdateOne) {
  22438. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  22439. }
  22440. if m.id == nil || m.oldValue == nil {
  22441. return v, errors.New("OldMAC requires an ID field in the mutation")
  22442. }
  22443. oldValue, err := m.oldValue(ctx)
  22444. if err != nil {
  22445. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  22446. }
  22447. return oldValue.MAC, nil
  22448. }
  22449. // ClearMAC clears the value of the "mac" field.
  22450. func (m *TokenMutation) ClearMAC() {
  22451. m.mac = nil
  22452. m.clearedFields[token.FieldMAC] = struct{}{}
  22453. }
  22454. // MACCleared returns if the "mac" field was cleared in this mutation.
  22455. func (m *TokenMutation) MACCleared() bool {
  22456. _, ok := m.clearedFields[token.FieldMAC]
  22457. return ok
  22458. }
  22459. // ResetMAC resets all changes to the "mac" field.
  22460. func (m *TokenMutation) ResetMAC() {
  22461. m.mac = nil
  22462. delete(m.clearedFields, token.FieldMAC)
  22463. }
  22464. // SetOrganizationID sets the "organization_id" field.
  22465. func (m *TokenMutation) SetOrganizationID(u uint64) {
  22466. m.organization_id = &u
  22467. m.addorganization_id = nil
  22468. }
  22469. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22470. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  22471. v := m.organization_id
  22472. if v == nil {
  22473. return
  22474. }
  22475. return *v, true
  22476. }
  22477. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  22478. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22480. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22481. if !m.op.Is(OpUpdateOne) {
  22482. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22483. }
  22484. if m.id == nil || m.oldValue == nil {
  22485. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22486. }
  22487. oldValue, err := m.oldValue(ctx)
  22488. if err != nil {
  22489. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22490. }
  22491. return oldValue.OrganizationID, nil
  22492. }
  22493. // AddOrganizationID adds u to the "organization_id" field.
  22494. func (m *TokenMutation) AddOrganizationID(u int64) {
  22495. if m.addorganization_id != nil {
  22496. *m.addorganization_id += u
  22497. } else {
  22498. m.addorganization_id = &u
  22499. }
  22500. }
  22501. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22502. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  22503. v := m.addorganization_id
  22504. if v == nil {
  22505. return
  22506. }
  22507. return *v, true
  22508. }
  22509. // ResetOrganizationID resets all changes to the "organization_id" field.
  22510. func (m *TokenMutation) ResetOrganizationID() {
  22511. m.organization_id = nil
  22512. m.addorganization_id = nil
  22513. }
  22514. // SetAgentID sets the "agent_id" field.
  22515. func (m *TokenMutation) SetAgentID(u uint64) {
  22516. m.agent = &u
  22517. }
  22518. // AgentID returns the value of the "agent_id" field in the mutation.
  22519. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  22520. v := m.agent
  22521. if v == nil {
  22522. return
  22523. }
  22524. return *v, true
  22525. }
  22526. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  22527. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22529. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  22530. if !m.op.Is(OpUpdateOne) {
  22531. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  22532. }
  22533. if m.id == nil || m.oldValue == nil {
  22534. return v, errors.New("OldAgentID requires an ID field in the mutation")
  22535. }
  22536. oldValue, err := m.oldValue(ctx)
  22537. if err != nil {
  22538. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  22539. }
  22540. return oldValue.AgentID, nil
  22541. }
  22542. // ResetAgentID resets all changes to the "agent_id" field.
  22543. func (m *TokenMutation) ResetAgentID() {
  22544. m.agent = nil
  22545. }
  22546. // SetCustomAgentBase sets the "custom_agent_base" field.
  22547. func (m *TokenMutation) SetCustomAgentBase(s string) {
  22548. m.custom_agent_base = &s
  22549. }
  22550. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  22551. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  22552. v := m.custom_agent_base
  22553. if v == nil {
  22554. return
  22555. }
  22556. return *v, true
  22557. }
  22558. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  22559. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22561. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  22562. if !m.op.Is(OpUpdateOne) {
  22563. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  22564. }
  22565. if m.id == nil || m.oldValue == nil {
  22566. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  22567. }
  22568. oldValue, err := m.oldValue(ctx)
  22569. if err != nil {
  22570. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  22571. }
  22572. return oldValue.CustomAgentBase, nil
  22573. }
  22574. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  22575. func (m *TokenMutation) ClearCustomAgentBase() {
  22576. m.custom_agent_base = nil
  22577. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  22578. }
  22579. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  22580. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  22581. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  22582. return ok
  22583. }
  22584. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  22585. func (m *TokenMutation) ResetCustomAgentBase() {
  22586. m.custom_agent_base = nil
  22587. delete(m.clearedFields, token.FieldCustomAgentBase)
  22588. }
  22589. // SetCustomAgentKey sets the "custom_agent_key" field.
  22590. func (m *TokenMutation) SetCustomAgentKey(s string) {
  22591. m.custom_agent_key = &s
  22592. }
  22593. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  22594. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  22595. v := m.custom_agent_key
  22596. if v == nil {
  22597. return
  22598. }
  22599. return *v, true
  22600. }
  22601. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  22602. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22604. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  22605. if !m.op.Is(OpUpdateOne) {
  22606. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  22607. }
  22608. if m.id == nil || m.oldValue == nil {
  22609. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  22610. }
  22611. oldValue, err := m.oldValue(ctx)
  22612. if err != nil {
  22613. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  22614. }
  22615. return oldValue.CustomAgentKey, nil
  22616. }
  22617. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  22618. func (m *TokenMutation) ClearCustomAgentKey() {
  22619. m.custom_agent_key = nil
  22620. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  22621. }
  22622. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  22623. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  22624. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  22625. return ok
  22626. }
  22627. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  22628. func (m *TokenMutation) ResetCustomAgentKey() {
  22629. m.custom_agent_key = nil
  22630. delete(m.clearedFields, token.FieldCustomAgentKey)
  22631. }
  22632. // SetOpenaiBase sets the "openai_base" field.
  22633. func (m *TokenMutation) SetOpenaiBase(s string) {
  22634. m.openai_base = &s
  22635. }
  22636. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  22637. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  22638. v := m.openai_base
  22639. if v == nil {
  22640. return
  22641. }
  22642. return *v, true
  22643. }
  22644. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  22645. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22647. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  22648. if !m.op.Is(OpUpdateOne) {
  22649. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  22650. }
  22651. if m.id == nil || m.oldValue == nil {
  22652. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  22653. }
  22654. oldValue, err := m.oldValue(ctx)
  22655. if err != nil {
  22656. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  22657. }
  22658. return oldValue.OpenaiBase, nil
  22659. }
  22660. // ClearOpenaiBase clears the value of the "openai_base" field.
  22661. func (m *TokenMutation) ClearOpenaiBase() {
  22662. m.openai_base = nil
  22663. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  22664. }
  22665. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  22666. func (m *TokenMutation) OpenaiBaseCleared() bool {
  22667. _, ok := m.clearedFields[token.FieldOpenaiBase]
  22668. return ok
  22669. }
  22670. // ResetOpenaiBase resets all changes to the "openai_base" field.
  22671. func (m *TokenMutation) ResetOpenaiBase() {
  22672. m.openai_base = nil
  22673. delete(m.clearedFields, token.FieldOpenaiBase)
  22674. }
  22675. // SetOpenaiKey sets the "openai_key" field.
  22676. func (m *TokenMutation) SetOpenaiKey(s string) {
  22677. m.openai_key = &s
  22678. }
  22679. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  22680. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  22681. v := m.openai_key
  22682. if v == nil {
  22683. return
  22684. }
  22685. return *v, true
  22686. }
  22687. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  22688. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  22689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22690. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  22691. if !m.op.Is(OpUpdateOne) {
  22692. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  22693. }
  22694. if m.id == nil || m.oldValue == nil {
  22695. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  22696. }
  22697. oldValue, err := m.oldValue(ctx)
  22698. if err != nil {
  22699. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  22700. }
  22701. return oldValue.OpenaiKey, nil
  22702. }
  22703. // ClearOpenaiKey clears the value of the "openai_key" field.
  22704. func (m *TokenMutation) ClearOpenaiKey() {
  22705. m.openai_key = nil
  22706. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  22707. }
  22708. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  22709. func (m *TokenMutation) OpenaiKeyCleared() bool {
  22710. _, ok := m.clearedFields[token.FieldOpenaiKey]
  22711. return ok
  22712. }
  22713. // ResetOpenaiKey resets all changes to the "openai_key" field.
  22714. func (m *TokenMutation) ResetOpenaiKey() {
  22715. m.openai_key = nil
  22716. delete(m.clearedFields, token.FieldOpenaiKey)
  22717. }
  22718. // ClearAgent clears the "agent" edge to the Agent entity.
  22719. func (m *TokenMutation) ClearAgent() {
  22720. m.clearedagent = true
  22721. m.clearedFields[token.FieldAgentID] = struct{}{}
  22722. }
  22723. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  22724. func (m *TokenMutation) AgentCleared() bool {
  22725. return m.clearedagent
  22726. }
  22727. // AgentIDs returns the "agent" edge IDs in the mutation.
  22728. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22729. // AgentID instead. It exists only for internal usage by the builders.
  22730. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  22731. if id := m.agent; id != nil {
  22732. ids = append(ids, *id)
  22733. }
  22734. return
  22735. }
  22736. // ResetAgent resets all changes to the "agent" edge.
  22737. func (m *TokenMutation) ResetAgent() {
  22738. m.agent = nil
  22739. m.clearedagent = false
  22740. }
  22741. // Where appends a list predicates to the TokenMutation builder.
  22742. func (m *TokenMutation) Where(ps ...predicate.Token) {
  22743. m.predicates = append(m.predicates, ps...)
  22744. }
  22745. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  22746. // users can use type-assertion to append predicates that do not depend on any generated package.
  22747. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  22748. p := make([]predicate.Token, len(ps))
  22749. for i := range ps {
  22750. p[i] = ps[i]
  22751. }
  22752. m.Where(p...)
  22753. }
  22754. // Op returns the operation name.
  22755. func (m *TokenMutation) Op() Op {
  22756. return m.op
  22757. }
  22758. // SetOp allows setting the mutation operation.
  22759. func (m *TokenMutation) SetOp(op Op) {
  22760. m.op = op
  22761. }
  22762. // Type returns the node type of this mutation (Token).
  22763. func (m *TokenMutation) Type() string {
  22764. return m.typ
  22765. }
  22766. // Fields returns all fields that were changed during this mutation. Note that in
  22767. // order to get all numeric fields that were incremented/decremented, call
  22768. // AddedFields().
  22769. func (m *TokenMutation) Fields() []string {
  22770. fields := make([]string, 0, 12)
  22771. if m.created_at != nil {
  22772. fields = append(fields, token.FieldCreatedAt)
  22773. }
  22774. if m.updated_at != nil {
  22775. fields = append(fields, token.FieldUpdatedAt)
  22776. }
  22777. if m.deleted_at != nil {
  22778. fields = append(fields, token.FieldDeletedAt)
  22779. }
  22780. if m.expire_at != nil {
  22781. fields = append(fields, token.FieldExpireAt)
  22782. }
  22783. if m.token != nil {
  22784. fields = append(fields, token.FieldToken)
  22785. }
  22786. if m.mac != nil {
  22787. fields = append(fields, token.FieldMAC)
  22788. }
  22789. if m.organization_id != nil {
  22790. fields = append(fields, token.FieldOrganizationID)
  22791. }
  22792. if m.agent != nil {
  22793. fields = append(fields, token.FieldAgentID)
  22794. }
  22795. if m.custom_agent_base != nil {
  22796. fields = append(fields, token.FieldCustomAgentBase)
  22797. }
  22798. if m.custom_agent_key != nil {
  22799. fields = append(fields, token.FieldCustomAgentKey)
  22800. }
  22801. if m.openai_base != nil {
  22802. fields = append(fields, token.FieldOpenaiBase)
  22803. }
  22804. if m.openai_key != nil {
  22805. fields = append(fields, token.FieldOpenaiKey)
  22806. }
  22807. return fields
  22808. }
  22809. // Field returns the value of a field with the given name. The second boolean
  22810. // return value indicates that this field was not set, or was not defined in the
  22811. // schema.
  22812. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  22813. switch name {
  22814. case token.FieldCreatedAt:
  22815. return m.CreatedAt()
  22816. case token.FieldUpdatedAt:
  22817. return m.UpdatedAt()
  22818. case token.FieldDeletedAt:
  22819. return m.DeletedAt()
  22820. case token.FieldExpireAt:
  22821. return m.ExpireAt()
  22822. case token.FieldToken:
  22823. return m.Token()
  22824. case token.FieldMAC:
  22825. return m.MAC()
  22826. case token.FieldOrganizationID:
  22827. return m.OrganizationID()
  22828. case token.FieldAgentID:
  22829. return m.AgentID()
  22830. case token.FieldCustomAgentBase:
  22831. return m.CustomAgentBase()
  22832. case token.FieldCustomAgentKey:
  22833. return m.CustomAgentKey()
  22834. case token.FieldOpenaiBase:
  22835. return m.OpenaiBase()
  22836. case token.FieldOpenaiKey:
  22837. return m.OpenaiKey()
  22838. }
  22839. return nil, false
  22840. }
  22841. // OldField returns the old value of the field from the database. An error is
  22842. // returned if the mutation operation is not UpdateOne, or the query to the
  22843. // database failed.
  22844. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22845. switch name {
  22846. case token.FieldCreatedAt:
  22847. return m.OldCreatedAt(ctx)
  22848. case token.FieldUpdatedAt:
  22849. return m.OldUpdatedAt(ctx)
  22850. case token.FieldDeletedAt:
  22851. return m.OldDeletedAt(ctx)
  22852. case token.FieldExpireAt:
  22853. return m.OldExpireAt(ctx)
  22854. case token.FieldToken:
  22855. return m.OldToken(ctx)
  22856. case token.FieldMAC:
  22857. return m.OldMAC(ctx)
  22858. case token.FieldOrganizationID:
  22859. return m.OldOrganizationID(ctx)
  22860. case token.FieldAgentID:
  22861. return m.OldAgentID(ctx)
  22862. case token.FieldCustomAgentBase:
  22863. return m.OldCustomAgentBase(ctx)
  22864. case token.FieldCustomAgentKey:
  22865. return m.OldCustomAgentKey(ctx)
  22866. case token.FieldOpenaiBase:
  22867. return m.OldOpenaiBase(ctx)
  22868. case token.FieldOpenaiKey:
  22869. return m.OldOpenaiKey(ctx)
  22870. }
  22871. return nil, fmt.Errorf("unknown Token field %s", name)
  22872. }
  22873. // SetField sets the value of a field with the given name. It returns an error if
  22874. // the field is not defined in the schema, or if the type mismatched the field
  22875. // type.
  22876. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  22877. switch name {
  22878. case token.FieldCreatedAt:
  22879. v, ok := value.(time.Time)
  22880. if !ok {
  22881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22882. }
  22883. m.SetCreatedAt(v)
  22884. return nil
  22885. case token.FieldUpdatedAt:
  22886. v, ok := value.(time.Time)
  22887. if !ok {
  22888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22889. }
  22890. m.SetUpdatedAt(v)
  22891. return nil
  22892. case token.FieldDeletedAt:
  22893. v, ok := value.(time.Time)
  22894. if !ok {
  22895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22896. }
  22897. m.SetDeletedAt(v)
  22898. return nil
  22899. case token.FieldExpireAt:
  22900. v, ok := value.(time.Time)
  22901. if !ok {
  22902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22903. }
  22904. m.SetExpireAt(v)
  22905. return nil
  22906. case token.FieldToken:
  22907. v, ok := value.(string)
  22908. if !ok {
  22909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22910. }
  22911. m.SetToken(v)
  22912. return nil
  22913. case token.FieldMAC:
  22914. v, ok := value.(string)
  22915. if !ok {
  22916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22917. }
  22918. m.SetMAC(v)
  22919. return nil
  22920. case token.FieldOrganizationID:
  22921. v, ok := value.(uint64)
  22922. if !ok {
  22923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22924. }
  22925. m.SetOrganizationID(v)
  22926. return nil
  22927. case token.FieldAgentID:
  22928. v, ok := value.(uint64)
  22929. if !ok {
  22930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22931. }
  22932. m.SetAgentID(v)
  22933. return nil
  22934. case token.FieldCustomAgentBase:
  22935. v, ok := value.(string)
  22936. if !ok {
  22937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22938. }
  22939. m.SetCustomAgentBase(v)
  22940. return nil
  22941. case token.FieldCustomAgentKey:
  22942. v, ok := value.(string)
  22943. if !ok {
  22944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22945. }
  22946. m.SetCustomAgentKey(v)
  22947. return nil
  22948. case token.FieldOpenaiBase:
  22949. v, ok := value.(string)
  22950. if !ok {
  22951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22952. }
  22953. m.SetOpenaiBase(v)
  22954. return nil
  22955. case token.FieldOpenaiKey:
  22956. v, ok := value.(string)
  22957. if !ok {
  22958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22959. }
  22960. m.SetOpenaiKey(v)
  22961. return nil
  22962. }
  22963. return fmt.Errorf("unknown Token field %s", name)
  22964. }
  22965. // AddedFields returns all numeric fields that were incremented/decremented during
  22966. // this mutation.
  22967. func (m *TokenMutation) AddedFields() []string {
  22968. var fields []string
  22969. if m.addorganization_id != nil {
  22970. fields = append(fields, token.FieldOrganizationID)
  22971. }
  22972. return fields
  22973. }
  22974. // AddedField returns the numeric value that was incremented/decremented on a field
  22975. // with the given name. The second boolean return value indicates that this field
  22976. // was not set, or was not defined in the schema.
  22977. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  22978. switch name {
  22979. case token.FieldOrganizationID:
  22980. return m.AddedOrganizationID()
  22981. }
  22982. return nil, false
  22983. }
  22984. // AddField adds the value to the field with the given name. It returns an error if
  22985. // the field is not defined in the schema, or if the type mismatched the field
  22986. // type.
  22987. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  22988. switch name {
  22989. case token.FieldOrganizationID:
  22990. v, ok := value.(int64)
  22991. if !ok {
  22992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22993. }
  22994. m.AddOrganizationID(v)
  22995. return nil
  22996. }
  22997. return fmt.Errorf("unknown Token numeric field %s", name)
  22998. }
  22999. // ClearedFields returns all nullable fields that were cleared during this
  23000. // mutation.
  23001. func (m *TokenMutation) ClearedFields() []string {
  23002. var fields []string
  23003. if m.FieldCleared(token.FieldDeletedAt) {
  23004. fields = append(fields, token.FieldDeletedAt)
  23005. }
  23006. if m.FieldCleared(token.FieldExpireAt) {
  23007. fields = append(fields, token.FieldExpireAt)
  23008. }
  23009. if m.FieldCleared(token.FieldToken) {
  23010. fields = append(fields, token.FieldToken)
  23011. }
  23012. if m.FieldCleared(token.FieldMAC) {
  23013. fields = append(fields, token.FieldMAC)
  23014. }
  23015. if m.FieldCleared(token.FieldCustomAgentBase) {
  23016. fields = append(fields, token.FieldCustomAgentBase)
  23017. }
  23018. if m.FieldCleared(token.FieldCustomAgentKey) {
  23019. fields = append(fields, token.FieldCustomAgentKey)
  23020. }
  23021. if m.FieldCleared(token.FieldOpenaiBase) {
  23022. fields = append(fields, token.FieldOpenaiBase)
  23023. }
  23024. if m.FieldCleared(token.FieldOpenaiKey) {
  23025. fields = append(fields, token.FieldOpenaiKey)
  23026. }
  23027. return fields
  23028. }
  23029. // FieldCleared returns a boolean indicating if a field with the given name was
  23030. // cleared in this mutation.
  23031. func (m *TokenMutation) FieldCleared(name string) bool {
  23032. _, ok := m.clearedFields[name]
  23033. return ok
  23034. }
  23035. // ClearField clears the value of the field with the given name. It returns an
  23036. // error if the field is not defined in the schema.
  23037. func (m *TokenMutation) ClearField(name string) error {
  23038. switch name {
  23039. case token.FieldDeletedAt:
  23040. m.ClearDeletedAt()
  23041. return nil
  23042. case token.FieldExpireAt:
  23043. m.ClearExpireAt()
  23044. return nil
  23045. case token.FieldToken:
  23046. m.ClearToken()
  23047. return nil
  23048. case token.FieldMAC:
  23049. m.ClearMAC()
  23050. return nil
  23051. case token.FieldCustomAgentBase:
  23052. m.ClearCustomAgentBase()
  23053. return nil
  23054. case token.FieldCustomAgentKey:
  23055. m.ClearCustomAgentKey()
  23056. return nil
  23057. case token.FieldOpenaiBase:
  23058. m.ClearOpenaiBase()
  23059. return nil
  23060. case token.FieldOpenaiKey:
  23061. m.ClearOpenaiKey()
  23062. return nil
  23063. }
  23064. return fmt.Errorf("unknown Token nullable field %s", name)
  23065. }
  23066. // ResetField resets all changes in the mutation for the field with the given name.
  23067. // It returns an error if the field is not defined in the schema.
  23068. func (m *TokenMutation) ResetField(name string) error {
  23069. switch name {
  23070. case token.FieldCreatedAt:
  23071. m.ResetCreatedAt()
  23072. return nil
  23073. case token.FieldUpdatedAt:
  23074. m.ResetUpdatedAt()
  23075. return nil
  23076. case token.FieldDeletedAt:
  23077. m.ResetDeletedAt()
  23078. return nil
  23079. case token.FieldExpireAt:
  23080. m.ResetExpireAt()
  23081. return nil
  23082. case token.FieldToken:
  23083. m.ResetToken()
  23084. return nil
  23085. case token.FieldMAC:
  23086. m.ResetMAC()
  23087. return nil
  23088. case token.FieldOrganizationID:
  23089. m.ResetOrganizationID()
  23090. return nil
  23091. case token.FieldAgentID:
  23092. m.ResetAgentID()
  23093. return nil
  23094. case token.FieldCustomAgentBase:
  23095. m.ResetCustomAgentBase()
  23096. return nil
  23097. case token.FieldCustomAgentKey:
  23098. m.ResetCustomAgentKey()
  23099. return nil
  23100. case token.FieldOpenaiBase:
  23101. m.ResetOpenaiBase()
  23102. return nil
  23103. case token.FieldOpenaiKey:
  23104. m.ResetOpenaiKey()
  23105. return nil
  23106. }
  23107. return fmt.Errorf("unknown Token field %s", name)
  23108. }
  23109. // AddedEdges returns all edge names that were set/added in this mutation.
  23110. func (m *TokenMutation) AddedEdges() []string {
  23111. edges := make([]string, 0, 1)
  23112. if m.agent != nil {
  23113. edges = append(edges, token.EdgeAgent)
  23114. }
  23115. return edges
  23116. }
  23117. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23118. // name in this mutation.
  23119. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  23120. switch name {
  23121. case token.EdgeAgent:
  23122. if id := m.agent; id != nil {
  23123. return []ent.Value{*id}
  23124. }
  23125. }
  23126. return nil
  23127. }
  23128. // RemovedEdges returns all edge names that were removed in this mutation.
  23129. func (m *TokenMutation) RemovedEdges() []string {
  23130. edges := make([]string, 0, 1)
  23131. return edges
  23132. }
  23133. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23134. // the given name in this mutation.
  23135. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  23136. return nil
  23137. }
  23138. // ClearedEdges returns all edge names that were cleared in this mutation.
  23139. func (m *TokenMutation) ClearedEdges() []string {
  23140. edges := make([]string, 0, 1)
  23141. if m.clearedagent {
  23142. edges = append(edges, token.EdgeAgent)
  23143. }
  23144. return edges
  23145. }
  23146. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23147. // was cleared in this mutation.
  23148. func (m *TokenMutation) EdgeCleared(name string) bool {
  23149. switch name {
  23150. case token.EdgeAgent:
  23151. return m.clearedagent
  23152. }
  23153. return false
  23154. }
  23155. // ClearEdge clears the value of the edge with the given name. It returns an error
  23156. // if that edge is not defined in the schema.
  23157. func (m *TokenMutation) ClearEdge(name string) error {
  23158. switch name {
  23159. case token.EdgeAgent:
  23160. m.ClearAgent()
  23161. return nil
  23162. }
  23163. return fmt.Errorf("unknown Token unique edge %s", name)
  23164. }
  23165. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23166. // It returns an error if the edge is not defined in the schema.
  23167. func (m *TokenMutation) ResetEdge(name string) error {
  23168. switch name {
  23169. case token.EdgeAgent:
  23170. m.ResetAgent()
  23171. return nil
  23172. }
  23173. return fmt.Errorf("unknown Token edge %s", name)
  23174. }
  23175. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  23176. type TutorialMutation struct {
  23177. config
  23178. op Op
  23179. typ string
  23180. id *uint64
  23181. created_at *time.Time
  23182. updated_at *time.Time
  23183. deleted_at *time.Time
  23184. index *int
  23185. addindex *int
  23186. title *string
  23187. content *string
  23188. organization_id *uint64
  23189. addorganization_id *int64
  23190. clearedFields map[string]struct{}
  23191. employee *uint64
  23192. clearedemployee bool
  23193. done bool
  23194. oldValue func(context.Context) (*Tutorial, error)
  23195. predicates []predicate.Tutorial
  23196. }
  23197. var _ ent.Mutation = (*TutorialMutation)(nil)
  23198. // tutorialOption allows management of the mutation configuration using functional options.
  23199. type tutorialOption func(*TutorialMutation)
  23200. // newTutorialMutation creates new mutation for the Tutorial entity.
  23201. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  23202. m := &TutorialMutation{
  23203. config: c,
  23204. op: op,
  23205. typ: TypeTutorial,
  23206. clearedFields: make(map[string]struct{}),
  23207. }
  23208. for _, opt := range opts {
  23209. opt(m)
  23210. }
  23211. return m
  23212. }
  23213. // withTutorialID sets the ID field of the mutation.
  23214. func withTutorialID(id uint64) tutorialOption {
  23215. return func(m *TutorialMutation) {
  23216. var (
  23217. err error
  23218. once sync.Once
  23219. value *Tutorial
  23220. )
  23221. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  23222. once.Do(func() {
  23223. if m.done {
  23224. err = errors.New("querying old values post mutation is not allowed")
  23225. } else {
  23226. value, err = m.Client().Tutorial.Get(ctx, id)
  23227. }
  23228. })
  23229. return value, err
  23230. }
  23231. m.id = &id
  23232. }
  23233. }
  23234. // withTutorial sets the old Tutorial of the mutation.
  23235. func withTutorial(node *Tutorial) tutorialOption {
  23236. return func(m *TutorialMutation) {
  23237. m.oldValue = func(context.Context) (*Tutorial, error) {
  23238. return node, nil
  23239. }
  23240. m.id = &node.ID
  23241. }
  23242. }
  23243. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23244. // executed in a transaction (ent.Tx), a transactional client is returned.
  23245. func (m TutorialMutation) Client() *Client {
  23246. client := &Client{config: m.config}
  23247. client.init()
  23248. return client
  23249. }
  23250. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23251. // it returns an error otherwise.
  23252. func (m TutorialMutation) Tx() (*Tx, error) {
  23253. if _, ok := m.driver.(*txDriver); !ok {
  23254. return nil, errors.New("ent: mutation is not running in a transaction")
  23255. }
  23256. tx := &Tx{config: m.config}
  23257. tx.init()
  23258. return tx, nil
  23259. }
  23260. // SetID sets the value of the id field. Note that this
  23261. // operation is only accepted on creation of Tutorial entities.
  23262. func (m *TutorialMutation) SetID(id uint64) {
  23263. m.id = &id
  23264. }
  23265. // ID returns the ID value in the mutation. Note that the ID is only available
  23266. // if it was provided to the builder or after it was returned from the database.
  23267. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  23268. if m.id == nil {
  23269. return
  23270. }
  23271. return *m.id, true
  23272. }
  23273. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23274. // That means, if the mutation is applied within a transaction with an isolation level such
  23275. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23276. // or updated by the mutation.
  23277. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  23278. switch {
  23279. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23280. id, exists := m.ID()
  23281. if exists {
  23282. return []uint64{id}, nil
  23283. }
  23284. fallthrough
  23285. case m.op.Is(OpUpdate | OpDelete):
  23286. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  23287. default:
  23288. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23289. }
  23290. }
  23291. // SetCreatedAt sets the "created_at" field.
  23292. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  23293. m.created_at = &t
  23294. }
  23295. // CreatedAt returns the value of the "created_at" field in the mutation.
  23296. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  23297. v := m.created_at
  23298. if v == nil {
  23299. return
  23300. }
  23301. return *v, true
  23302. }
  23303. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  23304. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23306. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23307. if !m.op.Is(OpUpdateOne) {
  23308. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23309. }
  23310. if m.id == nil || m.oldValue == nil {
  23311. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23312. }
  23313. oldValue, err := m.oldValue(ctx)
  23314. if err != nil {
  23315. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23316. }
  23317. return oldValue.CreatedAt, nil
  23318. }
  23319. // ResetCreatedAt resets all changes to the "created_at" field.
  23320. func (m *TutorialMutation) ResetCreatedAt() {
  23321. m.created_at = nil
  23322. }
  23323. // SetUpdatedAt sets the "updated_at" field.
  23324. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  23325. m.updated_at = &t
  23326. }
  23327. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23328. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  23329. v := m.updated_at
  23330. if v == nil {
  23331. return
  23332. }
  23333. return *v, true
  23334. }
  23335. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  23336. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23338. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23339. if !m.op.Is(OpUpdateOne) {
  23340. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23341. }
  23342. if m.id == nil || m.oldValue == nil {
  23343. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23344. }
  23345. oldValue, err := m.oldValue(ctx)
  23346. if err != nil {
  23347. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23348. }
  23349. return oldValue.UpdatedAt, nil
  23350. }
  23351. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23352. func (m *TutorialMutation) ResetUpdatedAt() {
  23353. m.updated_at = nil
  23354. }
  23355. // SetDeletedAt sets the "deleted_at" field.
  23356. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  23357. m.deleted_at = &t
  23358. }
  23359. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23360. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  23361. v := m.deleted_at
  23362. if v == nil {
  23363. return
  23364. }
  23365. return *v, true
  23366. }
  23367. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  23368. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23370. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23371. if !m.op.Is(OpUpdateOne) {
  23372. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23373. }
  23374. if m.id == nil || m.oldValue == nil {
  23375. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23376. }
  23377. oldValue, err := m.oldValue(ctx)
  23378. if err != nil {
  23379. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23380. }
  23381. return oldValue.DeletedAt, nil
  23382. }
  23383. // ClearDeletedAt clears the value of the "deleted_at" field.
  23384. func (m *TutorialMutation) ClearDeletedAt() {
  23385. m.deleted_at = nil
  23386. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  23387. }
  23388. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23389. func (m *TutorialMutation) DeletedAtCleared() bool {
  23390. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  23391. return ok
  23392. }
  23393. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23394. func (m *TutorialMutation) ResetDeletedAt() {
  23395. m.deleted_at = nil
  23396. delete(m.clearedFields, tutorial.FieldDeletedAt)
  23397. }
  23398. // SetEmployeeID sets the "employee_id" field.
  23399. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  23400. m.employee = &u
  23401. }
  23402. // EmployeeID returns the value of the "employee_id" field in the mutation.
  23403. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  23404. v := m.employee
  23405. if v == nil {
  23406. return
  23407. }
  23408. return *v, true
  23409. }
  23410. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  23411. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23413. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  23414. if !m.op.Is(OpUpdateOne) {
  23415. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  23416. }
  23417. if m.id == nil || m.oldValue == nil {
  23418. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  23419. }
  23420. oldValue, err := m.oldValue(ctx)
  23421. if err != nil {
  23422. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  23423. }
  23424. return oldValue.EmployeeID, nil
  23425. }
  23426. // ResetEmployeeID resets all changes to the "employee_id" field.
  23427. func (m *TutorialMutation) ResetEmployeeID() {
  23428. m.employee = nil
  23429. }
  23430. // SetIndex sets the "index" field.
  23431. func (m *TutorialMutation) SetIndex(i int) {
  23432. m.index = &i
  23433. m.addindex = nil
  23434. }
  23435. // Index returns the value of the "index" field in the mutation.
  23436. func (m *TutorialMutation) Index() (r int, exists bool) {
  23437. v := m.index
  23438. if v == nil {
  23439. return
  23440. }
  23441. return *v, true
  23442. }
  23443. // OldIndex returns the old "index" field's value of the Tutorial entity.
  23444. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23446. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  23447. if !m.op.Is(OpUpdateOne) {
  23448. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  23449. }
  23450. if m.id == nil || m.oldValue == nil {
  23451. return v, errors.New("OldIndex requires an ID field in the mutation")
  23452. }
  23453. oldValue, err := m.oldValue(ctx)
  23454. if err != nil {
  23455. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  23456. }
  23457. return oldValue.Index, nil
  23458. }
  23459. // AddIndex adds i to the "index" field.
  23460. func (m *TutorialMutation) AddIndex(i int) {
  23461. if m.addindex != nil {
  23462. *m.addindex += i
  23463. } else {
  23464. m.addindex = &i
  23465. }
  23466. }
  23467. // AddedIndex returns the value that was added to the "index" field in this mutation.
  23468. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  23469. v := m.addindex
  23470. if v == nil {
  23471. return
  23472. }
  23473. return *v, true
  23474. }
  23475. // ResetIndex resets all changes to the "index" field.
  23476. func (m *TutorialMutation) ResetIndex() {
  23477. m.index = nil
  23478. m.addindex = nil
  23479. }
  23480. // SetTitle sets the "title" field.
  23481. func (m *TutorialMutation) SetTitle(s string) {
  23482. m.title = &s
  23483. }
  23484. // Title returns the value of the "title" field in the mutation.
  23485. func (m *TutorialMutation) Title() (r string, exists bool) {
  23486. v := m.title
  23487. if v == nil {
  23488. return
  23489. }
  23490. return *v, true
  23491. }
  23492. // OldTitle returns the old "title" field's value of the Tutorial entity.
  23493. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23495. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  23496. if !m.op.Is(OpUpdateOne) {
  23497. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  23498. }
  23499. if m.id == nil || m.oldValue == nil {
  23500. return v, errors.New("OldTitle requires an ID field in the mutation")
  23501. }
  23502. oldValue, err := m.oldValue(ctx)
  23503. if err != nil {
  23504. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  23505. }
  23506. return oldValue.Title, nil
  23507. }
  23508. // ResetTitle resets all changes to the "title" field.
  23509. func (m *TutorialMutation) ResetTitle() {
  23510. m.title = nil
  23511. }
  23512. // SetContent sets the "content" field.
  23513. func (m *TutorialMutation) SetContent(s string) {
  23514. m.content = &s
  23515. }
  23516. // Content returns the value of the "content" field in the mutation.
  23517. func (m *TutorialMutation) Content() (r string, exists bool) {
  23518. v := m.content
  23519. if v == nil {
  23520. return
  23521. }
  23522. return *v, true
  23523. }
  23524. // OldContent returns the old "content" field's value of the Tutorial entity.
  23525. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23527. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  23528. if !m.op.Is(OpUpdateOne) {
  23529. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  23530. }
  23531. if m.id == nil || m.oldValue == nil {
  23532. return v, errors.New("OldContent requires an ID field in the mutation")
  23533. }
  23534. oldValue, err := m.oldValue(ctx)
  23535. if err != nil {
  23536. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  23537. }
  23538. return oldValue.Content, nil
  23539. }
  23540. // ResetContent resets all changes to the "content" field.
  23541. func (m *TutorialMutation) ResetContent() {
  23542. m.content = nil
  23543. }
  23544. // SetOrganizationID sets the "organization_id" field.
  23545. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  23546. m.organization_id = &u
  23547. m.addorganization_id = nil
  23548. }
  23549. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23550. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  23551. v := m.organization_id
  23552. if v == nil {
  23553. return
  23554. }
  23555. return *v, true
  23556. }
  23557. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  23558. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  23559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23560. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23561. if !m.op.Is(OpUpdateOne) {
  23562. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23563. }
  23564. if m.id == nil || m.oldValue == nil {
  23565. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23566. }
  23567. oldValue, err := m.oldValue(ctx)
  23568. if err != nil {
  23569. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23570. }
  23571. return oldValue.OrganizationID, nil
  23572. }
  23573. // AddOrganizationID adds u to the "organization_id" field.
  23574. func (m *TutorialMutation) AddOrganizationID(u int64) {
  23575. if m.addorganization_id != nil {
  23576. *m.addorganization_id += u
  23577. } else {
  23578. m.addorganization_id = &u
  23579. }
  23580. }
  23581. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23582. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  23583. v := m.addorganization_id
  23584. if v == nil {
  23585. return
  23586. }
  23587. return *v, true
  23588. }
  23589. // ResetOrganizationID resets all changes to the "organization_id" field.
  23590. func (m *TutorialMutation) ResetOrganizationID() {
  23591. m.organization_id = nil
  23592. m.addorganization_id = nil
  23593. }
  23594. // ClearEmployee clears the "employee" edge to the Employee entity.
  23595. func (m *TutorialMutation) ClearEmployee() {
  23596. m.clearedemployee = true
  23597. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  23598. }
  23599. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  23600. func (m *TutorialMutation) EmployeeCleared() bool {
  23601. return m.clearedemployee
  23602. }
  23603. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  23604. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23605. // EmployeeID instead. It exists only for internal usage by the builders.
  23606. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  23607. if id := m.employee; id != nil {
  23608. ids = append(ids, *id)
  23609. }
  23610. return
  23611. }
  23612. // ResetEmployee resets all changes to the "employee" edge.
  23613. func (m *TutorialMutation) ResetEmployee() {
  23614. m.employee = nil
  23615. m.clearedemployee = false
  23616. }
  23617. // Where appends a list predicates to the TutorialMutation builder.
  23618. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  23619. m.predicates = append(m.predicates, ps...)
  23620. }
  23621. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  23622. // users can use type-assertion to append predicates that do not depend on any generated package.
  23623. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  23624. p := make([]predicate.Tutorial, len(ps))
  23625. for i := range ps {
  23626. p[i] = ps[i]
  23627. }
  23628. m.Where(p...)
  23629. }
  23630. // Op returns the operation name.
  23631. func (m *TutorialMutation) Op() Op {
  23632. return m.op
  23633. }
  23634. // SetOp allows setting the mutation operation.
  23635. func (m *TutorialMutation) SetOp(op Op) {
  23636. m.op = op
  23637. }
  23638. // Type returns the node type of this mutation (Tutorial).
  23639. func (m *TutorialMutation) Type() string {
  23640. return m.typ
  23641. }
  23642. // Fields returns all fields that were changed during this mutation. Note that in
  23643. // order to get all numeric fields that were incremented/decremented, call
  23644. // AddedFields().
  23645. func (m *TutorialMutation) Fields() []string {
  23646. fields := make([]string, 0, 8)
  23647. if m.created_at != nil {
  23648. fields = append(fields, tutorial.FieldCreatedAt)
  23649. }
  23650. if m.updated_at != nil {
  23651. fields = append(fields, tutorial.FieldUpdatedAt)
  23652. }
  23653. if m.deleted_at != nil {
  23654. fields = append(fields, tutorial.FieldDeletedAt)
  23655. }
  23656. if m.employee != nil {
  23657. fields = append(fields, tutorial.FieldEmployeeID)
  23658. }
  23659. if m.index != nil {
  23660. fields = append(fields, tutorial.FieldIndex)
  23661. }
  23662. if m.title != nil {
  23663. fields = append(fields, tutorial.FieldTitle)
  23664. }
  23665. if m.content != nil {
  23666. fields = append(fields, tutorial.FieldContent)
  23667. }
  23668. if m.organization_id != nil {
  23669. fields = append(fields, tutorial.FieldOrganizationID)
  23670. }
  23671. return fields
  23672. }
  23673. // Field returns the value of a field with the given name. The second boolean
  23674. // return value indicates that this field was not set, or was not defined in the
  23675. // schema.
  23676. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  23677. switch name {
  23678. case tutorial.FieldCreatedAt:
  23679. return m.CreatedAt()
  23680. case tutorial.FieldUpdatedAt:
  23681. return m.UpdatedAt()
  23682. case tutorial.FieldDeletedAt:
  23683. return m.DeletedAt()
  23684. case tutorial.FieldEmployeeID:
  23685. return m.EmployeeID()
  23686. case tutorial.FieldIndex:
  23687. return m.Index()
  23688. case tutorial.FieldTitle:
  23689. return m.Title()
  23690. case tutorial.FieldContent:
  23691. return m.Content()
  23692. case tutorial.FieldOrganizationID:
  23693. return m.OrganizationID()
  23694. }
  23695. return nil, false
  23696. }
  23697. // OldField returns the old value of the field from the database. An error is
  23698. // returned if the mutation operation is not UpdateOne, or the query to the
  23699. // database failed.
  23700. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23701. switch name {
  23702. case tutorial.FieldCreatedAt:
  23703. return m.OldCreatedAt(ctx)
  23704. case tutorial.FieldUpdatedAt:
  23705. return m.OldUpdatedAt(ctx)
  23706. case tutorial.FieldDeletedAt:
  23707. return m.OldDeletedAt(ctx)
  23708. case tutorial.FieldEmployeeID:
  23709. return m.OldEmployeeID(ctx)
  23710. case tutorial.FieldIndex:
  23711. return m.OldIndex(ctx)
  23712. case tutorial.FieldTitle:
  23713. return m.OldTitle(ctx)
  23714. case tutorial.FieldContent:
  23715. return m.OldContent(ctx)
  23716. case tutorial.FieldOrganizationID:
  23717. return m.OldOrganizationID(ctx)
  23718. }
  23719. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  23720. }
  23721. // SetField sets the value of a field with the given name. It returns an error if
  23722. // the field is not defined in the schema, or if the type mismatched the field
  23723. // type.
  23724. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  23725. switch name {
  23726. case tutorial.FieldCreatedAt:
  23727. v, ok := value.(time.Time)
  23728. if !ok {
  23729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23730. }
  23731. m.SetCreatedAt(v)
  23732. return nil
  23733. case tutorial.FieldUpdatedAt:
  23734. v, ok := value.(time.Time)
  23735. if !ok {
  23736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23737. }
  23738. m.SetUpdatedAt(v)
  23739. return nil
  23740. case tutorial.FieldDeletedAt:
  23741. v, ok := value.(time.Time)
  23742. if !ok {
  23743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23744. }
  23745. m.SetDeletedAt(v)
  23746. return nil
  23747. case tutorial.FieldEmployeeID:
  23748. v, ok := value.(uint64)
  23749. if !ok {
  23750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23751. }
  23752. m.SetEmployeeID(v)
  23753. return nil
  23754. case tutorial.FieldIndex:
  23755. v, ok := value.(int)
  23756. if !ok {
  23757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23758. }
  23759. m.SetIndex(v)
  23760. return nil
  23761. case tutorial.FieldTitle:
  23762. v, ok := value.(string)
  23763. if !ok {
  23764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23765. }
  23766. m.SetTitle(v)
  23767. return nil
  23768. case tutorial.FieldContent:
  23769. v, ok := value.(string)
  23770. if !ok {
  23771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23772. }
  23773. m.SetContent(v)
  23774. return nil
  23775. case tutorial.FieldOrganizationID:
  23776. v, ok := value.(uint64)
  23777. if !ok {
  23778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23779. }
  23780. m.SetOrganizationID(v)
  23781. return nil
  23782. }
  23783. return fmt.Errorf("unknown Tutorial field %s", name)
  23784. }
  23785. // AddedFields returns all numeric fields that were incremented/decremented during
  23786. // this mutation.
  23787. func (m *TutorialMutation) AddedFields() []string {
  23788. var fields []string
  23789. if m.addindex != nil {
  23790. fields = append(fields, tutorial.FieldIndex)
  23791. }
  23792. if m.addorganization_id != nil {
  23793. fields = append(fields, tutorial.FieldOrganizationID)
  23794. }
  23795. return fields
  23796. }
  23797. // AddedField returns the numeric value that was incremented/decremented on a field
  23798. // with the given name. The second boolean return value indicates that this field
  23799. // was not set, or was not defined in the schema.
  23800. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  23801. switch name {
  23802. case tutorial.FieldIndex:
  23803. return m.AddedIndex()
  23804. case tutorial.FieldOrganizationID:
  23805. return m.AddedOrganizationID()
  23806. }
  23807. return nil, false
  23808. }
  23809. // AddField adds the value to the field with the given name. It returns an error if
  23810. // the field is not defined in the schema, or if the type mismatched the field
  23811. // type.
  23812. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  23813. switch name {
  23814. case tutorial.FieldIndex:
  23815. v, ok := value.(int)
  23816. if !ok {
  23817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23818. }
  23819. m.AddIndex(v)
  23820. return nil
  23821. case tutorial.FieldOrganizationID:
  23822. v, ok := value.(int64)
  23823. if !ok {
  23824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23825. }
  23826. m.AddOrganizationID(v)
  23827. return nil
  23828. }
  23829. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  23830. }
  23831. // ClearedFields returns all nullable fields that were cleared during this
  23832. // mutation.
  23833. func (m *TutorialMutation) ClearedFields() []string {
  23834. var fields []string
  23835. if m.FieldCleared(tutorial.FieldDeletedAt) {
  23836. fields = append(fields, tutorial.FieldDeletedAt)
  23837. }
  23838. return fields
  23839. }
  23840. // FieldCleared returns a boolean indicating if a field with the given name was
  23841. // cleared in this mutation.
  23842. func (m *TutorialMutation) FieldCleared(name string) bool {
  23843. _, ok := m.clearedFields[name]
  23844. return ok
  23845. }
  23846. // ClearField clears the value of the field with the given name. It returns an
  23847. // error if the field is not defined in the schema.
  23848. func (m *TutorialMutation) ClearField(name string) error {
  23849. switch name {
  23850. case tutorial.FieldDeletedAt:
  23851. m.ClearDeletedAt()
  23852. return nil
  23853. }
  23854. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  23855. }
  23856. // ResetField resets all changes in the mutation for the field with the given name.
  23857. // It returns an error if the field is not defined in the schema.
  23858. func (m *TutorialMutation) ResetField(name string) error {
  23859. switch name {
  23860. case tutorial.FieldCreatedAt:
  23861. m.ResetCreatedAt()
  23862. return nil
  23863. case tutorial.FieldUpdatedAt:
  23864. m.ResetUpdatedAt()
  23865. return nil
  23866. case tutorial.FieldDeletedAt:
  23867. m.ResetDeletedAt()
  23868. return nil
  23869. case tutorial.FieldEmployeeID:
  23870. m.ResetEmployeeID()
  23871. return nil
  23872. case tutorial.FieldIndex:
  23873. m.ResetIndex()
  23874. return nil
  23875. case tutorial.FieldTitle:
  23876. m.ResetTitle()
  23877. return nil
  23878. case tutorial.FieldContent:
  23879. m.ResetContent()
  23880. return nil
  23881. case tutorial.FieldOrganizationID:
  23882. m.ResetOrganizationID()
  23883. return nil
  23884. }
  23885. return fmt.Errorf("unknown Tutorial field %s", name)
  23886. }
  23887. // AddedEdges returns all edge names that were set/added in this mutation.
  23888. func (m *TutorialMutation) AddedEdges() []string {
  23889. edges := make([]string, 0, 1)
  23890. if m.employee != nil {
  23891. edges = append(edges, tutorial.EdgeEmployee)
  23892. }
  23893. return edges
  23894. }
  23895. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23896. // name in this mutation.
  23897. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  23898. switch name {
  23899. case tutorial.EdgeEmployee:
  23900. if id := m.employee; id != nil {
  23901. return []ent.Value{*id}
  23902. }
  23903. }
  23904. return nil
  23905. }
  23906. // RemovedEdges returns all edge names that were removed in this mutation.
  23907. func (m *TutorialMutation) RemovedEdges() []string {
  23908. edges := make([]string, 0, 1)
  23909. return edges
  23910. }
  23911. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23912. // the given name in this mutation.
  23913. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  23914. return nil
  23915. }
  23916. // ClearedEdges returns all edge names that were cleared in this mutation.
  23917. func (m *TutorialMutation) ClearedEdges() []string {
  23918. edges := make([]string, 0, 1)
  23919. if m.clearedemployee {
  23920. edges = append(edges, tutorial.EdgeEmployee)
  23921. }
  23922. return edges
  23923. }
  23924. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23925. // was cleared in this mutation.
  23926. func (m *TutorialMutation) EdgeCleared(name string) bool {
  23927. switch name {
  23928. case tutorial.EdgeEmployee:
  23929. return m.clearedemployee
  23930. }
  23931. return false
  23932. }
  23933. // ClearEdge clears the value of the edge with the given name. It returns an error
  23934. // if that edge is not defined in the schema.
  23935. func (m *TutorialMutation) ClearEdge(name string) error {
  23936. switch name {
  23937. case tutorial.EdgeEmployee:
  23938. m.ClearEmployee()
  23939. return nil
  23940. }
  23941. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  23942. }
  23943. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23944. // It returns an error if the edge is not defined in the schema.
  23945. func (m *TutorialMutation) ResetEdge(name string) error {
  23946. switch name {
  23947. case tutorial.EdgeEmployee:
  23948. m.ResetEmployee()
  23949. return nil
  23950. }
  23951. return fmt.Errorf("unknown Tutorial edge %s", name)
  23952. }
  23953. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  23954. type UsageDetailMutation struct {
  23955. config
  23956. op Op
  23957. typ string
  23958. id *uint64
  23959. created_at *time.Time
  23960. updated_at *time.Time
  23961. status *uint8
  23962. addstatus *int8
  23963. _type *int
  23964. add_type *int
  23965. bot_id *string
  23966. receiver_id *string
  23967. app *int
  23968. addapp *int
  23969. session_id *uint64
  23970. addsession_id *int64
  23971. request *string
  23972. response *string
  23973. total_tokens *uint64
  23974. addtotal_tokens *int64
  23975. prompt_tokens *uint64
  23976. addprompt_tokens *int64
  23977. completion_tokens *uint64
  23978. addcompletion_tokens *int64
  23979. organization_id *uint64
  23980. addorganization_id *int64
  23981. clearedFields map[string]struct{}
  23982. done bool
  23983. oldValue func(context.Context) (*UsageDetail, error)
  23984. predicates []predicate.UsageDetail
  23985. }
  23986. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  23987. // usagedetailOption allows management of the mutation configuration using functional options.
  23988. type usagedetailOption func(*UsageDetailMutation)
  23989. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  23990. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  23991. m := &UsageDetailMutation{
  23992. config: c,
  23993. op: op,
  23994. typ: TypeUsageDetail,
  23995. clearedFields: make(map[string]struct{}),
  23996. }
  23997. for _, opt := range opts {
  23998. opt(m)
  23999. }
  24000. return m
  24001. }
  24002. // withUsageDetailID sets the ID field of the mutation.
  24003. func withUsageDetailID(id uint64) usagedetailOption {
  24004. return func(m *UsageDetailMutation) {
  24005. var (
  24006. err error
  24007. once sync.Once
  24008. value *UsageDetail
  24009. )
  24010. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  24011. once.Do(func() {
  24012. if m.done {
  24013. err = errors.New("querying old values post mutation is not allowed")
  24014. } else {
  24015. value, err = m.Client().UsageDetail.Get(ctx, id)
  24016. }
  24017. })
  24018. return value, err
  24019. }
  24020. m.id = &id
  24021. }
  24022. }
  24023. // withUsageDetail sets the old UsageDetail of the mutation.
  24024. func withUsageDetail(node *UsageDetail) usagedetailOption {
  24025. return func(m *UsageDetailMutation) {
  24026. m.oldValue = func(context.Context) (*UsageDetail, error) {
  24027. return node, nil
  24028. }
  24029. m.id = &node.ID
  24030. }
  24031. }
  24032. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24033. // executed in a transaction (ent.Tx), a transactional client is returned.
  24034. func (m UsageDetailMutation) Client() *Client {
  24035. client := &Client{config: m.config}
  24036. client.init()
  24037. return client
  24038. }
  24039. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24040. // it returns an error otherwise.
  24041. func (m UsageDetailMutation) Tx() (*Tx, error) {
  24042. if _, ok := m.driver.(*txDriver); !ok {
  24043. return nil, errors.New("ent: mutation is not running in a transaction")
  24044. }
  24045. tx := &Tx{config: m.config}
  24046. tx.init()
  24047. return tx, nil
  24048. }
  24049. // SetID sets the value of the id field. Note that this
  24050. // operation is only accepted on creation of UsageDetail entities.
  24051. func (m *UsageDetailMutation) SetID(id uint64) {
  24052. m.id = &id
  24053. }
  24054. // ID returns the ID value in the mutation. Note that the ID is only available
  24055. // if it was provided to the builder or after it was returned from the database.
  24056. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  24057. if m.id == nil {
  24058. return
  24059. }
  24060. return *m.id, true
  24061. }
  24062. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24063. // That means, if the mutation is applied within a transaction with an isolation level such
  24064. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24065. // or updated by the mutation.
  24066. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  24067. switch {
  24068. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24069. id, exists := m.ID()
  24070. if exists {
  24071. return []uint64{id}, nil
  24072. }
  24073. fallthrough
  24074. case m.op.Is(OpUpdate | OpDelete):
  24075. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  24076. default:
  24077. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24078. }
  24079. }
  24080. // SetCreatedAt sets the "created_at" field.
  24081. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  24082. m.created_at = &t
  24083. }
  24084. // CreatedAt returns the value of the "created_at" field in the mutation.
  24085. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  24086. v := m.created_at
  24087. if v == nil {
  24088. return
  24089. }
  24090. return *v, true
  24091. }
  24092. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  24093. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24095. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24096. if !m.op.Is(OpUpdateOne) {
  24097. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24098. }
  24099. if m.id == nil || m.oldValue == nil {
  24100. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24101. }
  24102. oldValue, err := m.oldValue(ctx)
  24103. if err != nil {
  24104. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24105. }
  24106. return oldValue.CreatedAt, nil
  24107. }
  24108. // ResetCreatedAt resets all changes to the "created_at" field.
  24109. func (m *UsageDetailMutation) ResetCreatedAt() {
  24110. m.created_at = nil
  24111. }
  24112. // SetUpdatedAt sets the "updated_at" field.
  24113. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  24114. m.updated_at = &t
  24115. }
  24116. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24117. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  24118. v := m.updated_at
  24119. if v == nil {
  24120. return
  24121. }
  24122. return *v, true
  24123. }
  24124. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  24125. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24127. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24128. if !m.op.Is(OpUpdateOne) {
  24129. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24130. }
  24131. if m.id == nil || m.oldValue == nil {
  24132. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24133. }
  24134. oldValue, err := m.oldValue(ctx)
  24135. if err != nil {
  24136. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24137. }
  24138. return oldValue.UpdatedAt, nil
  24139. }
  24140. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24141. func (m *UsageDetailMutation) ResetUpdatedAt() {
  24142. m.updated_at = nil
  24143. }
  24144. // SetStatus sets the "status" field.
  24145. func (m *UsageDetailMutation) SetStatus(u uint8) {
  24146. m.status = &u
  24147. m.addstatus = nil
  24148. }
  24149. // Status returns the value of the "status" field in the mutation.
  24150. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  24151. v := m.status
  24152. if v == nil {
  24153. return
  24154. }
  24155. return *v, true
  24156. }
  24157. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  24158. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24160. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24161. if !m.op.Is(OpUpdateOne) {
  24162. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24163. }
  24164. if m.id == nil || m.oldValue == nil {
  24165. return v, errors.New("OldStatus requires an ID field in the mutation")
  24166. }
  24167. oldValue, err := m.oldValue(ctx)
  24168. if err != nil {
  24169. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24170. }
  24171. return oldValue.Status, nil
  24172. }
  24173. // AddStatus adds u to the "status" field.
  24174. func (m *UsageDetailMutation) AddStatus(u int8) {
  24175. if m.addstatus != nil {
  24176. *m.addstatus += u
  24177. } else {
  24178. m.addstatus = &u
  24179. }
  24180. }
  24181. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24182. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  24183. v := m.addstatus
  24184. if v == nil {
  24185. return
  24186. }
  24187. return *v, true
  24188. }
  24189. // ClearStatus clears the value of the "status" field.
  24190. func (m *UsageDetailMutation) ClearStatus() {
  24191. m.status = nil
  24192. m.addstatus = nil
  24193. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  24194. }
  24195. // StatusCleared returns if the "status" field was cleared in this mutation.
  24196. func (m *UsageDetailMutation) StatusCleared() bool {
  24197. _, ok := m.clearedFields[usagedetail.FieldStatus]
  24198. return ok
  24199. }
  24200. // ResetStatus resets all changes to the "status" field.
  24201. func (m *UsageDetailMutation) ResetStatus() {
  24202. m.status = nil
  24203. m.addstatus = nil
  24204. delete(m.clearedFields, usagedetail.FieldStatus)
  24205. }
  24206. // SetType sets the "type" field.
  24207. func (m *UsageDetailMutation) SetType(i int) {
  24208. m._type = &i
  24209. m.add_type = nil
  24210. }
  24211. // GetType returns the value of the "type" field in the mutation.
  24212. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  24213. v := m._type
  24214. if v == nil {
  24215. return
  24216. }
  24217. return *v, true
  24218. }
  24219. // OldType returns the old "type" field's value of the UsageDetail entity.
  24220. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24222. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  24223. if !m.op.Is(OpUpdateOne) {
  24224. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24225. }
  24226. if m.id == nil || m.oldValue == nil {
  24227. return v, errors.New("OldType requires an ID field in the mutation")
  24228. }
  24229. oldValue, err := m.oldValue(ctx)
  24230. if err != nil {
  24231. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24232. }
  24233. return oldValue.Type, nil
  24234. }
  24235. // AddType adds i to the "type" field.
  24236. func (m *UsageDetailMutation) AddType(i int) {
  24237. if m.add_type != nil {
  24238. *m.add_type += i
  24239. } else {
  24240. m.add_type = &i
  24241. }
  24242. }
  24243. // AddedType returns the value that was added to the "type" field in this mutation.
  24244. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  24245. v := m.add_type
  24246. if v == nil {
  24247. return
  24248. }
  24249. return *v, true
  24250. }
  24251. // ClearType clears the value of the "type" field.
  24252. func (m *UsageDetailMutation) ClearType() {
  24253. m._type = nil
  24254. m.add_type = nil
  24255. m.clearedFields[usagedetail.FieldType] = struct{}{}
  24256. }
  24257. // TypeCleared returns if the "type" field was cleared in this mutation.
  24258. func (m *UsageDetailMutation) TypeCleared() bool {
  24259. _, ok := m.clearedFields[usagedetail.FieldType]
  24260. return ok
  24261. }
  24262. // ResetType resets all changes to the "type" field.
  24263. func (m *UsageDetailMutation) ResetType() {
  24264. m._type = nil
  24265. m.add_type = nil
  24266. delete(m.clearedFields, usagedetail.FieldType)
  24267. }
  24268. // SetBotID sets the "bot_id" field.
  24269. func (m *UsageDetailMutation) SetBotID(s string) {
  24270. m.bot_id = &s
  24271. }
  24272. // BotID returns the value of the "bot_id" field in the mutation.
  24273. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  24274. v := m.bot_id
  24275. if v == nil {
  24276. return
  24277. }
  24278. return *v, true
  24279. }
  24280. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  24281. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24283. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  24284. if !m.op.Is(OpUpdateOne) {
  24285. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24286. }
  24287. if m.id == nil || m.oldValue == nil {
  24288. return v, errors.New("OldBotID requires an ID field in the mutation")
  24289. }
  24290. oldValue, err := m.oldValue(ctx)
  24291. if err != nil {
  24292. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24293. }
  24294. return oldValue.BotID, nil
  24295. }
  24296. // ResetBotID resets all changes to the "bot_id" field.
  24297. func (m *UsageDetailMutation) ResetBotID() {
  24298. m.bot_id = nil
  24299. }
  24300. // SetReceiverID sets the "receiver_id" field.
  24301. func (m *UsageDetailMutation) SetReceiverID(s string) {
  24302. m.receiver_id = &s
  24303. }
  24304. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  24305. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  24306. v := m.receiver_id
  24307. if v == nil {
  24308. return
  24309. }
  24310. return *v, true
  24311. }
  24312. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  24313. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24315. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  24316. if !m.op.Is(OpUpdateOne) {
  24317. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  24318. }
  24319. if m.id == nil || m.oldValue == nil {
  24320. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  24321. }
  24322. oldValue, err := m.oldValue(ctx)
  24323. if err != nil {
  24324. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  24325. }
  24326. return oldValue.ReceiverID, nil
  24327. }
  24328. // ResetReceiverID resets all changes to the "receiver_id" field.
  24329. func (m *UsageDetailMutation) ResetReceiverID() {
  24330. m.receiver_id = nil
  24331. }
  24332. // SetApp sets the "app" field.
  24333. func (m *UsageDetailMutation) SetApp(i int) {
  24334. m.app = &i
  24335. m.addapp = nil
  24336. }
  24337. // App returns the value of the "app" field in the mutation.
  24338. func (m *UsageDetailMutation) App() (r int, exists bool) {
  24339. v := m.app
  24340. if v == nil {
  24341. return
  24342. }
  24343. return *v, true
  24344. }
  24345. // OldApp returns the old "app" field's value of the UsageDetail entity.
  24346. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24348. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  24349. if !m.op.Is(OpUpdateOne) {
  24350. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  24351. }
  24352. if m.id == nil || m.oldValue == nil {
  24353. return v, errors.New("OldApp requires an ID field in the mutation")
  24354. }
  24355. oldValue, err := m.oldValue(ctx)
  24356. if err != nil {
  24357. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  24358. }
  24359. return oldValue.App, nil
  24360. }
  24361. // AddApp adds i to the "app" field.
  24362. func (m *UsageDetailMutation) AddApp(i int) {
  24363. if m.addapp != nil {
  24364. *m.addapp += i
  24365. } else {
  24366. m.addapp = &i
  24367. }
  24368. }
  24369. // AddedApp returns the value that was added to the "app" field in this mutation.
  24370. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  24371. v := m.addapp
  24372. if v == nil {
  24373. return
  24374. }
  24375. return *v, true
  24376. }
  24377. // ClearApp clears the value of the "app" field.
  24378. func (m *UsageDetailMutation) ClearApp() {
  24379. m.app = nil
  24380. m.addapp = nil
  24381. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  24382. }
  24383. // AppCleared returns if the "app" field was cleared in this mutation.
  24384. func (m *UsageDetailMutation) AppCleared() bool {
  24385. _, ok := m.clearedFields[usagedetail.FieldApp]
  24386. return ok
  24387. }
  24388. // ResetApp resets all changes to the "app" field.
  24389. func (m *UsageDetailMutation) ResetApp() {
  24390. m.app = nil
  24391. m.addapp = nil
  24392. delete(m.clearedFields, usagedetail.FieldApp)
  24393. }
  24394. // SetSessionID sets the "session_id" field.
  24395. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  24396. m.session_id = &u
  24397. m.addsession_id = nil
  24398. }
  24399. // SessionID returns the value of the "session_id" field in the mutation.
  24400. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  24401. v := m.session_id
  24402. if v == nil {
  24403. return
  24404. }
  24405. return *v, true
  24406. }
  24407. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  24408. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24410. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  24411. if !m.op.Is(OpUpdateOne) {
  24412. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  24413. }
  24414. if m.id == nil || m.oldValue == nil {
  24415. return v, errors.New("OldSessionID requires an ID field in the mutation")
  24416. }
  24417. oldValue, err := m.oldValue(ctx)
  24418. if err != nil {
  24419. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  24420. }
  24421. return oldValue.SessionID, nil
  24422. }
  24423. // AddSessionID adds u to the "session_id" field.
  24424. func (m *UsageDetailMutation) AddSessionID(u int64) {
  24425. if m.addsession_id != nil {
  24426. *m.addsession_id += u
  24427. } else {
  24428. m.addsession_id = &u
  24429. }
  24430. }
  24431. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  24432. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  24433. v := m.addsession_id
  24434. if v == nil {
  24435. return
  24436. }
  24437. return *v, true
  24438. }
  24439. // ClearSessionID clears the value of the "session_id" field.
  24440. func (m *UsageDetailMutation) ClearSessionID() {
  24441. m.session_id = nil
  24442. m.addsession_id = nil
  24443. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  24444. }
  24445. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  24446. func (m *UsageDetailMutation) SessionIDCleared() bool {
  24447. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  24448. return ok
  24449. }
  24450. // ResetSessionID resets all changes to the "session_id" field.
  24451. func (m *UsageDetailMutation) ResetSessionID() {
  24452. m.session_id = nil
  24453. m.addsession_id = nil
  24454. delete(m.clearedFields, usagedetail.FieldSessionID)
  24455. }
  24456. // SetRequest sets the "request" field.
  24457. func (m *UsageDetailMutation) SetRequest(s string) {
  24458. m.request = &s
  24459. }
  24460. // Request returns the value of the "request" field in the mutation.
  24461. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  24462. v := m.request
  24463. if v == nil {
  24464. return
  24465. }
  24466. return *v, true
  24467. }
  24468. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  24469. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24471. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  24472. if !m.op.Is(OpUpdateOne) {
  24473. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  24474. }
  24475. if m.id == nil || m.oldValue == nil {
  24476. return v, errors.New("OldRequest requires an ID field in the mutation")
  24477. }
  24478. oldValue, err := m.oldValue(ctx)
  24479. if err != nil {
  24480. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  24481. }
  24482. return oldValue.Request, nil
  24483. }
  24484. // ResetRequest resets all changes to the "request" field.
  24485. func (m *UsageDetailMutation) ResetRequest() {
  24486. m.request = nil
  24487. }
  24488. // SetResponse sets the "response" field.
  24489. func (m *UsageDetailMutation) SetResponse(s string) {
  24490. m.response = &s
  24491. }
  24492. // Response returns the value of the "response" field in the mutation.
  24493. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  24494. v := m.response
  24495. if v == nil {
  24496. return
  24497. }
  24498. return *v, true
  24499. }
  24500. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  24501. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24503. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  24504. if !m.op.Is(OpUpdateOne) {
  24505. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  24506. }
  24507. if m.id == nil || m.oldValue == nil {
  24508. return v, errors.New("OldResponse requires an ID field in the mutation")
  24509. }
  24510. oldValue, err := m.oldValue(ctx)
  24511. if err != nil {
  24512. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  24513. }
  24514. return oldValue.Response, nil
  24515. }
  24516. // ResetResponse resets all changes to the "response" field.
  24517. func (m *UsageDetailMutation) ResetResponse() {
  24518. m.response = nil
  24519. }
  24520. // SetTotalTokens sets the "total_tokens" field.
  24521. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  24522. m.total_tokens = &u
  24523. m.addtotal_tokens = nil
  24524. }
  24525. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  24526. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  24527. v := m.total_tokens
  24528. if v == nil {
  24529. return
  24530. }
  24531. return *v, true
  24532. }
  24533. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  24534. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24536. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  24537. if !m.op.Is(OpUpdateOne) {
  24538. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  24539. }
  24540. if m.id == nil || m.oldValue == nil {
  24541. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  24542. }
  24543. oldValue, err := m.oldValue(ctx)
  24544. if err != nil {
  24545. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  24546. }
  24547. return oldValue.TotalTokens, nil
  24548. }
  24549. // AddTotalTokens adds u to the "total_tokens" field.
  24550. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  24551. if m.addtotal_tokens != nil {
  24552. *m.addtotal_tokens += u
  24553. } else {
  24554. m.addtotal_tokens = &u
  24555. }
  24556. }
  24557. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  24558. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  24559. v := m.addtotal_tokens
  24560. if v == nil {
  24561. return
  24562. }
  24563. return *v, true
  24564. }
  24565. // ClearTotalTokens clears the value of the "total_tokens" field.
  24566. func (m *UsageDetailMutation) ClearTotalTokens() {
  24567. m.total_tokens = nil
  24568. m.addtotal_tokens = nil
  24569. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  24570. }
  24571. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  24572. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  24573. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  24574. return ok
  24575. }
  24576. // ResetTotalTokens resets all changes to the "total_tokens" field.
  24577. func (m *UsageDetailMutation) ResetTotalTokens() {
  24578. m.total_tokens = nil
  24579. m.addtotal_tokens = nil
  24580. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  24581. }
  24582. // SetPromptTokens sets the "prompt_tokens" field.
  24583. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  24584. m.prompt_tokens = &u
  24585. m.addprompt_tokens = nil
  24586. }
  24587. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  24588. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  24589. v := m.prompt_tokens
  24590. if v == nil {
  24591. return
  24592. }
  24593. return *v, true
  24594. }
  24595. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  24596. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24598. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  24599. if !m.op.Is(OpUpdateOne) {
  24600. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  24601. }
  24602. if m.id == nil || m.oldValue == nil {
  24603. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  24604. }
  24605. oldValue, err := m.oldValue(ctx)
  24606. if err != nil {
  24607. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  24608. }
  24609. return oldValue.PromptTokens, nil
  24610. }
  24611. // AddPromptTokens adds u to the "prompt_tokens" field.
  24612. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  24613. if m.addprompt_tokens != nil {
  24614. *m.addprompt_tokens += u
  24615. } else {
  24616. m.addprompt_tokens = &u
  24617. }
  24618. }
  24619. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  24620. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  24621. v := m.addprompt_tokens
  24622. if v == nil {
  24623. return
  24624. }
  24625. return *v, true
  24626. }
  24627. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  24628. func (m *UsageDetailMutation) ClearPromptTokens() {
  24629. m.prompt_tokens = nil
  24630. m.addprompt_tokens = nil
  24631. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  24632. }
  24633. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  24634. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  24635. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  24636. return ok
  24637. }
  24638. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  24639. func (m *UsageDetailMutation) ResetPromptTokens() {
  24640. m.prompt_tokens = nil
  24641. m.addprompt_tokens = nil
  24642. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  24643. }
  24644. // SetCompletionTokens sets the "completion_tokens" field.
  24645. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  24646. m.completion_tokens = &u
  24647. m.addcompletion_tokens = nil
  24648. }
  24649. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  24650. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  24651. v := m.completion_tokens
  24652. if v == nil {
  24653. return
  24654. }
  24655. return *v, true
  24656. }
  24657. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  24658. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24660. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  24661. if !m.op.Is(OpUpdateOne) {
  24662. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  24663. }
  24664. if m.id == nil || m.oldValue == nil {
  24665. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  24666. }
  24667. oldValue, err := m.oldValue(ctx)
  24668. if err != nil {
  24669. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  24670. }
  24671. return oldValue.CompletionTokens, nil
  24672. }
  24673. // AddCompletionTokens adds u to the "completion_tokens" field.
  24674. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  24675. if m.addcompletion_tokens != nil {
  24676. *m.addcompletion_tokens += u
  24677. } else {
  24678. m.addcompletion_tokens = &u
  24679. }
  24680. }
  24681. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  24682. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  24683. v := m.addcompletion_tokens
  24684. if v == nil {
  24685. return
  24686. }
  24687. return *v, true
  24688. }
  24689. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  24690. func (m *UsageDetailMutation) ClearCompletionTokens() {
  24691. m.completion_tokens = nil
  24692. m.addcompletion_tokens = nil
  24693. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  24694. }
  24695. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  24696. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  24697. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  24698. return ok
  24699. }
  24700. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  24701. func (m *UsageDetailMutation) ResetCompletionTokens() {
  24702. m.completion_tokens = nil
  24703. m.addcompletion_tokens = nil
  24704. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  24705. }
  24706. // SetOrganizationID sets the "organization_id" field.
  24707. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  24708. m.organization_id = &u
  24709. m.addorganization_id = nil
  24710. }
  24711. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24712. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  24713. v := m.organization_id
  24714. if v == nil {
  24715. return
  24716. }
  24717. return *v, true
  24718. }
  24719. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  24720. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  24721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24722. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24723. if !m.op.Is(OpUpdateOne) {
  24724. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24725. }
  24726. if m.id == nil || m.oldValue == nil {
  24727. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24728. }
  24729. oldValue, err := m.oldValue(ctx)
  24730. if err != nil {
  24731. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24732. }
  24733. return oldValue.OrganizationID, nil
  24734. }
  24735. // AddOrganizationID adds u to the "organization_id" field.
  24736. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  24737. if m.addorganization_id != nil {
  24738. *m.addorganization_id += u
  24739. } else {
  24740. m.addorganization_id = &u
  24741. }
  24742. }
  24743. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24744. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  24745. v := m.addorganization_id
  24746. if v == nil {
  24747. return
  24748. }
  24749. return *v, true
  24750. }
  24751. // ClearOrganizationID clears the value of the "organization_id" field.
  24752. func (m *UsageDetailMutation) ClearOrganizationID() {
  24753. m.organization_id = nil
  24754. m.addorganization_id = nil
  24755. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  24756. }
  24757. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24758. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  24759. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  24760. return ok
  24761. }
  24762. // ResetOrganizationID resets all changes to the "organization_id" field.
  24763. func (m *UsageDetailMutation) ResetOrganizationID() {
  24764. m.organization_id = nil
  24765. m.addorganization_id = nil
  24766. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  24767. }
  24768. // Where appends a list predicates to the UsageDetailMutation builder.
  24769. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  24770. m.predicates = append(m.predicates, ps...)
  24771. }
  24772. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  24773. // users can use type-assertion to append predicates that do not depend on any generated package.
  24774. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  24775. p := make([]predicate.UsageDetail, len(ps))
  24776. for i := range ps {
  24777. p[i] = ps[i]
  24778. }
  24779. m.Where(p...)
  24780. }
  24781. // Op returns the operation name.
  24782. func (m *UsageDetailMutation) Op() Op {
  24783. return m.op
  24784. }
  24785. // SetOp allows setting the mutation operation.
  24786. func (m *UsageDetailMutation) SetOp(op Op) {
  24787. m.op = op
  24788. }
  24789. // Type returns the node type of this mutation (UsageDetail).
  24790. func (m *UsageDetailMutation) Type() string {
  24791. return m.typ
  24792. }
  24793. // Fields returns all fields that were changed during this mutation. Note that in
  24794. // order to get all numeric fields that were incremented/decremented, call
  24795. // AddedFields().
  24796. func (m *UsageDetailMutation) Fields() []string {
  24797. fields := make([]string, 0, 14)
  24798. if m.created_at != nil {
  24799. fields = append(fields, usagedetail.FieldCreatedAt)
  24800. }
  24801. if m.updated_at != nil {
  24802. fields = append(fields, usagedetail.FieldUpdatedAt)
  24803. }
  24804. if m.status != nil {
  24805. fields = append(fields, usagedetail.FieldStatus)
  24806. }
  24807. if m._type != nil {
  24808. fields = append(fields, usagedetail.FieldType)
  24809. }
  24810. if m.bot_id != nil {
  24811. fields = append(fields, usagedetail.FieldBotID)
  24812. }
  24813. if m.receiver_id != nil {
  24814. fields = append(fields, usagedetail.FieldReceiverID)
  24815. }
  24816. if m.app != nil {
  24817. fields = append(fields, usagedetail.FieldApp)
  24818. }
  24819. if m.session_id != nil {
  24820. fields = append(fields, usagedetail.FieldSessionID)
  24821. }
  24822. if m.request != nil {
  24823. fields = append(fields, usagedetail.FieldRequest)
  24824. }
  24825. if m.response != nil {
  24826. fields = append(fields, usagedetail.FieldResponse)
  24827. }
  24828. if m.total_tokens != nil {
  24829. fields = append(fields, usagedetail.FieldTotalTokens)
  24830. }
  24831. if m.prompt_tokens != nil {
  24832. fields = append(fields, usagedetail.FieldPromptTokens)
  24833. }
  24834. if m.completion_tokens != nil {
  24835. fields = append(fields, usagedetail.FieldCompletionTokens)
  24836. }
  24837. if m.organization_id != nil {
  24838. fields = append(fields, usagedetail.FieldOrganizationID)
  24839. }
  24840. return fields
  24841. }
  24842. // Field returns the value of a field with the given name. The second boolean
  24843. // return value indicates that this field was not set, or was not defined in the
  24844. // schema.
  24845. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  24846. switch name {
  24847. case usagedetail.FieldCreatedAt:
  24848. return m.CreatedAt()
  24849. case usagedetail.FieldUpdatedAt:
  24850. return m.UpdatedAt()
  24851. case usagedetail.FieldStatus:
  24852. return m.Status()
  24853. case usagedetail.FieldType:
  24854. return m.GetType()
  24855. case usagedetail.FieldBotID:
  24856. return m.BotID()
  24857. case usagedetail.FieldReceiverID:
  24858. return m.ReceiverID()
  24859. case usagedetail.FieldApp:
  24860. return m.App()
  24861. case usagedetail.FieldSessionID:
  24862. return m.SessionID()
  24863. case usagedetail.FieldRequest:
  24864. return m.Request()
  24865. case usagedetail.FieldResponse:
  24866. return m.Response()
  24867. case usagedetail.FieldTotalTokens:
  24868. return m.TotalTokens()
  24869. case usagedetail.FieldPromptTokens:
  24870. return m.PromptTokens()
  24871. case usagedetail.FieldCompletionTokens:
  24872. return m.CompletionTokens()
  24873. case usagedetail.FieldOrganizationID:
  24874. return m.OrganizationID()
  24875. }
  24876. return nil, false
  24877. }
  24878. // OldField returns the old value of the field from the database. An error is
  24879. // returned if the mutation operation is not UpdateOne, or the query to the
  24880. // database failed.
  24881. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24882. switch name {
  24883. case usagedetail.FieldCreatedAt:
  24884. return m.OldCreatedAt(ctx)
  24885. case usagedetail.FieldUpdatedAt:
  24886. return m.OldUpdatedAt(ctx)
  24887. case usagedetail.FieldStatus:
  24888. return m.OldStatus(ctx)
  24889. case usagedetail.FieldType:
  24890. return m.OldType(ctx)
  24891. case usagedetail.FieldBotID:
  24892. return m.OldBotID(ctx)
  24893. case usagedetail.FieldReceiverID:
  24894. return m.OldReceiverID(ctx)
  24895. case usagedetail.FieldApp:
  24896. return m.OldApp(ctx)
  24897. case usagedetail.FieldSessionID:
  24898. return m.OldSessionID(ctx)
  24899. case usagedetail.FieldRequest:
  24900. return m.OldRequest(ctx)
  24901. case usagedetail.FieldResponse:
  24902. return m.OldResponse(ctx)
  24903. case usagedetail.FieldTotalTokens:
  24904. return m.OldTotalTokens(ctx)
  24905. case usagedetail.FieldPromptTokens:
  24906. return m.OldPromptTokens(ctx)
  24907. case usagedetail.FieldCompletionTokens:
  24908. return m.OldCompletionTokens(ctx)
  24909. case usagedetail.FieldOrganizationID:
  24910. return m.OldOrganizationID(ctx)
  24911. }
  24912. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  24913. }
  24914. // SetField sets the value of a field with the given name. It returns an error if
  24915. // the field is not defined in the schema, or if the type mismatched the field
  24916. // type.
  24917. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  24918. switch name {
  24919. case usagedetail.FieldCreatedAt:
  24920. v, ok := value.(time.Time)
  24921. if !ok {
  24922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24923. }
  24924. m.SetCreatedAt(v)
  24925. return nil
  24926. case usagedetail.FieldUpdatedAt:
  24927. v, ok := value.(time.Time)
  24928. if !ok {
  24929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24930. }
  24931. m.SetUpdatedAt(v)
  24932. return nil
  24933. case usagedetail.FieldStatus:
  24934. v, ok := value.(uint8)
  24935. if !ok {
  24936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24937. }
  24938. m.SetStatus(v)
  24939. return nil
  24940. case usagedetail.FieldType:
  24941. v, ok := value.(int)
  24942. if !ok {
  24943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24944. }
  24945. m.SetType(v)
  24946. return nil
  24947. case usagedetail.FieldBotID:
  24948. v, ok := value.(string)
  24949. if !ok {
  24950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24951. }
  24952. m.SetBotID(v)
  24953. return nil
  24954. case usagedetail.FieldReceiverID:
  24955. v, ok := value.(string)
  24956. if !ok {
  24957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24958. }
  24959. m.SetReceiverID(v)
  24960. return nil
  24961. case usagedetail.FieldApp:
  24962. v, ok := value.(int)
  24963. if !ok {
  24964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24965. }
  24966. m.SetApp(v)
  24967. return nil
  24968. case usagedetail.FieldSessionID:
  24969. v, ok := value.(uint64)
  24970. if !ok {
  24971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24972. }
  24973. m.SetSessionID(v)
  24974. return nil
  24975. case usagedetail.FieldRequest:
  24976. v, ok := value.(string)
  24977. if !ok {
  24978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24979. }
  24980. m.SetRequest(v)
  24981. return nil
  24982. case usagedetail.FieldResponse:
  24983. v, ok := value.(string)
  24984. if !ok {
  24985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24986. }
  24987. m.SetResponse(v)
  24988. return nil
  24989. case usagedetail.FieldTotalTokens:
  24990. v, ok := value.(uint64)
  24991. if !ok {
  24992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24993. }
  24994. m.SetTotalTokens(v)
  24995. return nil
  24996. case usagedetail.FieldPromptTokens:
  24997. v, ok := value.(uint64)
  24998. if !ok {
  24999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25000. }
  25001. m.SetPromptTokens(v)
  25002. return nil
  25003. case usagedetail.FieldCompletionTokens:
  25004. v, ok := value.(uint64)
  25005. if !ok {
  25006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25007. }
  25008. m.SetCompletionTokens(v)
  25009. return nil
  25010. case usagedetail.FieldOrganizationID:
  25011. v, ok := value.(uint64)
  25012. if !ok {
  25013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25014. }
  25015. m.SetOrganizationID(v)
  25016. return nil
  25017. }
  25018. return fmt.Errorf("unknown UsageDetail field %s", name)
  25019. }
  25020. // AddedFields returns all numeric fields that were incremented/decremented during
  25021. // this mutation.
  25022. func (m *UsageDetailMutation) AddedFields() []string {
  25023. var fields []string
  25024. if m.addstatus != nil {
  25025. fields = append(fields, usagedetail.FieldStatus)
  25026. }
  25027. if m.add_type != nil {
  25028. fields = append(fields, usagedetail.FieldType)
  25029. }
  25030. if m.addapp != nil {
  25031. fields = append(fields, usagedetail.FieldApp)
  25032. }
  25033. if m.addsession_id != nil {
  25034. fields = append(fields, usagedetail.FieldSessionID)
  25035. }
  25036. if m.addtotal_tokens != nil {
  25037. fields = append(fields, usagedetail.FieldTotalTokens)
  25038. }
  25039. if m.addprompt_tokens != nil {
  25040. fields = append(fields, usagedetail.FieldPromptTokens)
  25041. }
  25042. if m.addcompletion_tokens != nil {
  25043. fields = append(fields, usagedetail.FieldCompletionTokens)
  25044. }
  25045. if m.addorganization_id != nil {
  25046. fields = append(fields, usagedetail.FieldOrganizationID)
  25047. }
  25048. return fields
  25049. }
  25050. // AddedField returns the numeric value that was incremented/decremented on a field
  25051. // with the given name. The second boolean return value indicates that this field
  25052. // was not set, or was not defined in the schema.
  25053. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  25054. switch name {
  25055. case usagedetail.FieldStatus:
  25056. return m.AddedStatus()
  25057. case usagedetail.FieldType:
  25058. return m.AddedType()
  25059. case usagedetail.FieldApp:
  25060. return m.AddedApp()
  25061. case usagedetail.FieldSessionID:
  25062. return m.AddedSessionID()
  25063. case usagedetail.FieldTotalTokens:
  25064. return m.AddedTotalTokens()
  25065. case usagedetail.FieldPromptTokens:
  25066. return m.AddedPromptTokens()
  25067. case usagedetail.FieldCompletionTokens:
  25068. return m.AddedCompletionTokens()
  25069. case usagedetail.FieldOrganizationID:
  25070. return m.AddedOrganizationID()
  25071. }
  25072. return nil, false
  25073. }
  25074. // AddField adds the value to the field with the given name. It returns an error if
  25075. // the field is not defined in the schema, or if the type mismatched the field
  25076. // type.
  25077. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  25078. switch name {
  25079. case usagedetail.FieldStatus:
  25080. v, ok := value.(int8)
  25081. if !ok {
  25082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25083. }
  25084. m.AddStatus(v)
  25085. return nil
  25086. case usagedetail.FieldType:
  25087. v, ok := value.(int)
  25088. if !ok {
  25089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25090. }
  25091. m.AddType(v)
  25092. return nil
  25093. case usagedetail.FieldApp:
  25094. v, ok := value.(int)
  25095. if !ok {
  25096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25097. }
  25098. m.AddApp(v)
  25099. return nil
  25100. case usagedetail.FieldSessionID:
  25101. v, ok := value.(int64)
  25102. if !ok {
  25103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25104. }
  25105. m.AddSessionID(v)
  25106. return nil
  25107. case usagedetail.FieldTotalTokens:
  25108. v, ok := value.(int64)
  25109. if !ok {
  25110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25111. }
  25112. m.AddTotalTokens(v)
  25113. return nil
  25114. case usagedetail.FieldPromptTokens:
  25115. v, ok := value.(int64)
  25116. if !ok {
  25117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25118. }
  25119. m.AddPromptTokens(v)
  25120. return nil
  25121. case usagedetail.FieldCompletionTokens:
  25122. v, ok := value.(int64)
  25123. if !ok {
  25124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25125. }
  25126. m.AddCompletionTokens(v)
  25127. return nil
  25128. case usagedetail.FieldOrganizationID:
  25129. v, ok := value.(int64)
  25130. if !ok {
  25131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25132. }
  25133. m.AddOrganizationID(v)
  25134. return nil
  25135. }
  25136. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  25137. }
  25138. // ClearedFields returns all nullable fields that were cleared during this
  25139. // mutation.
  25140. func (m *UsageDetailMutation) ClearedFields() []string {
  25141. var fields []string
  25142. if m.FieldCleared(usagedetail.FieldStatus) {
  25143. fields = append(fields, usagedetail.FieldStatus)
  25144. }
  25145. if m.FieldCleared(usagedetail.FieldType) {
  25146. fields = append(fields, usagedetail.FieldType)
  25147. }
  25148. if m.FieldCleared(usagedetail.FieldApp) {
  25149. fields = append(fields, usagedetail.FieldApp)
  25150. }
  25151. if m.FieldCleared(usagedetail.FieldSessionID) {
  25152. fields = append(fields, usagedetail.FieldSessionID)
  25153. }
  25154. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  25155. fields = append(fields, usagedetail.FieldTotalTokens)
  25156. }
  25157. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  25158. fields = append(fields, usagedetail.FieldPromptTokens)
  25159. }
  25160. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  25161. fields = append(fields, usagedetail.FieldCompletionTokens)
  25162. }
  25163. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  25164. fields = append(fields, usagedetail.FieldOrganizationID)
  25165. }
  25166. return fields
  25167. }
  25168. // FieldCleared returns a boolean indicating if a field with the given name was
  25169. // cleared in this mutation.
  25170. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  25171. _, ok := m.clearedFields[name]
  25172. return ok
  25173. }
  25174. // ClearField clears the value of the field with the given name. It returns an
  25175. // error if the field is not defined in the schema.
  25176. func (m *UsageDetailMutation) ClearField(name string) error {
  25177. switch name {
  25178. case usagedetail.FieldStatus:
  25179. m.ClearStatus()
  25180. return nil
  25181. case usagedetail.FieldType:
  25182. m.ClearType()
  25183. return nil
  25184. case usagedetail.FieldApp:
  25185. m.ClearApp()
  25186. return nil
  25187. case usagedetail.FieldSessionID:
  25188. m.ClearSessionID()
  25189. return nil
  25190. case usagedetail.FieldTotalTokens:
  25191. m.ClearTotalTokens()
  25192. return nil
  25193. case usagedetail.FieldPromptTokens:
  25194. m.ClearPromptTokens()
  25195. return nil
  25196. case usagedetail.FieldCompletionTokens:
  25197. m.ClearCompletionTokens()
  25198. return nil
  25199. case usagedetail.FieldOrganizationID:
  25200. m.ClearOrganizationID()
  25201. return nil
  25202. }
  25203. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  25204. }
  25205. // ResetField resets all changes in the mutation for the field with the given name.
  25206. // It returns an error if the field is not defined in the schema.
  25207. func (m *UsageDetailMutation) ResetField(name string) error {
  25208. switch name {
  25209. case usagedetail.FieldCreatedAt:
  25210. m.ResetCreatedAt()
  25211. return nil
  25212. case usagedetail.FieldUpdatedAt:
  25213. m.ResetUpdatedAt()
  25214. return nil
  25215. case usagedetail.FieldStatus:
  25216. m.ResetStatus()
  25217. return nil
  25218. case usagedetail.FieldType:
  25219. m.ResetType()
  25220. return nil
  25221. case usagedetail.FieldBotID:
  25222. m.ResetBotID()
  25223. return nil
  25224. case usagedetail.FieldReceiverID:
  25225. m.ResetReceiverID()
  25226. return nil
  25227. case usagedetail.FieldApp:
  25228. m.ResetApp()
  25229. return nil
  25230. case usagedetail.FieldSessionID:
  25231. m.ResetSessionID()
  25232. return nil
  25233. case usagedetail.FieldRequest:
  25234. m.ResetRequest()
  25235. return nil
  25236. case usagedetail.FieldResponse:
  25237. m.ResetResponse()
  25238. return nil
  25239. case usagedetail.FieldTotalTokens:
  25240. m.ResetTotalTokens()
  25241. return nil
  25242. case usagedetail.FieldPromptTokens:
  25243. m.ResetPromptTokens()
  25244. return nil
  25245. case usagedetail.FieldCompletionTokens:
  25246. m.ResetCompletionTokens()
  25247. return nil
  25248. case usagedetail.FieldOrganizationID:
  25249. m.ResetOrganizationID()
  25250. return nil
  25251. }
  25252. return fmt.Errorf("unknown UsageDetail field %s", name)
  25253. }
  25254. // AddedEdges returns all edge names that were set/added in this mutation.
  25255. func (m *UsageDetailMutation) AddedEdges() []string {
  25256. edges := make([]string, 0, 0)
  25257. return edges
  25258. }
  25259. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25260. // name in this mutation.
  25261. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  25262. return nil
  25263. }
  25264. // RemovedEdges returns all edge names that were removed in this mutation.
  25265. func (m *UsageDetailMutation) RemovedEdges() []string {
  25266. edges := make([]string, 0, 0)
  25267. return edges
  25268. }
  25269. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25270. // the given name in this mutation.
  25271. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  25272. return nil
  25273. }
  25274. // ClearedEdges returns all edge names that were cleared in this mutation.
  25275. func (m *UsageDetailMutation) ClearedEdges() []string {
  25276. edges := make([]string, 0, 0)
  25277. return edges
  25278. }
  25279. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25280. // was cleared in this mutation.
  25281. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  25282. return false
  25283. }
  25284. // ClearEdge clears the value of the edge with the given name. It returns an error
  25285. // if that edge is not defined in the schema.
  25286. func (m *UsageDetailMutation) ClearEdge(name string) error {
  25287. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  25288. }
  25289. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25290. // It returns an error if the edge is not defined in the schema.
  25291. func (m *UsageDetailMutation) ResetEdge(name string) error {
  25292. return fmt.Errorf("unknown UsageDetail edge %s", name)
  25293. }
  25294. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  25295. type UsageStatisticDayMutation struct {
  25296. config
  25297. op Op
  25298. typ string
  25299. id *uint64
  25300. created_at *time.Time
  25301. updated_at *time.Time
  25302. status *uint8
  25303. addstatus *int8
  25304. deleted_at *time.Time
  25305. addtime *uint64
  25306. addaddtime *int64
  25307. _type *int
  25308. add_type *int
  25309. bot_id *string
  25310. organization_id *uint64
  25311. addorganization_id *int64
  25312. ai_response *uint64
  25313. addai_response *int64
  25314. sop_run *uint64
  25315. addsop_run *int64
  25316. total_friend *uint64
  25317. addtotal_friend *int64
  25318. total_group *uint64
  25319. addtotal_group *int64
  25320. account_balance *uint64
  25321. addaccount_balance *int64
  25322. consume_token *uint64
  25323. addconsume_token *int64
  25324. active_user *uint64
  25325. addactive_user *int64
  25326. new_user *int64
  25327. addnew_user *int64
  25328. label_dist *[]custom_types.LabelDist
  25329. appendlabel_dist []custom_types.LabelDist
  25330. clearedFields map[string]struct{}
  25331. done bool
  25332. oldValue func(context.Context) (*UsageStatisticDay, error)
  25333. predicates []predicate.UsageStatisticDay
  25334. }
  25335. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  25336. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  25337. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  25338. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  25339. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  25340. m := &UsageStatisticDayMutation{
  25341. config: c,
  25342. op: op,
  25343. typ: TypeUsageStatisticDay,
  25344. clearedFields: make(map[string]struct{}),
  25345. }
  25346. for _, opt := range opts {
  25347. opt(m)
  25348. }
  25349. return m
  25350. }
  25351. // withUsageStatisticDayID sets the ID field of the mutation.
  25352. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  25353. return func(m *UsageStatisticDayMutation) {
  25354. var (
  25355. err error
  25356. once sync.Once
  25357. value *UsageStatisticDay
  25358. )
  25359. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  25360. once.Do(func() {
  25361. if m.done {
  25362. err = errors.New("querying old values post mutation is not allowed")
  25363. } else {
  25364. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  25365. }
  25366. })
  25367. return value, err
  25368. }
  25369. m.id = &id
  25370. }
  25371. }
  25372. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  25373. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  25374. return func(m *UsageStatisticDayMutation) {
  25375. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  25376. return node, nil
  25377. }
  25378. m.id = &node.ID
  25379. }
  25380. }
  25381. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25382. // executed in a transaction (ent.Tx), a transactional client is returned.
  25383. func (m UsageStatisticDayMutation) Client() *Client {
  25384. client := &Client{config: m.config}
  25385. client.init()
  25386. return client
  25387. }
  25388. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25389. // it returns an error otherwise.
  25390. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  25391. if _, ok := m.driver.(*txDriver); !ok {
  25392. return nil, errors.New("ent: mutation is not running in a transaction")
  25393. }
  25394. tx := &Tx{config: m.config}
  25395. tx.init()
  25396. return tx, nil
  25397. }
  25398. // SetID sets the value of the id field. Note that this
  25399. // operation is only accepted on creation of UsageStatisticDay entities.
  25400. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  25401. m.id = &id
  25402. }
  25403. // ID returns the ID value in the mutation. Note that the ID is only available
  25404. // if it was provided to the builder or after it was returned from the database.
  25405. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  25406. if m.id == nil {
  25407. return
  25408. }
  25409. return *m.id, true
  25410. }
  25411. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25412. // That means, if the mutation is applied within a transaction with an isolation level such
  25413. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25414. // or updated by the mutation.
  25415. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  25416. switch {
  25417. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25418. id, exists := m.ID()
  25419. if exists {
  25420. return []uint64{id}, nil
  25421. }
  25422. fallthrough
  25423. case m.op.Is(OpUpdate | OpDelete):
  25424. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  25425. default:
  25426. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25427. }
  25428. }
  25429. // SetCreatedAt sets the "created_at" field.
  25430. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  25431. m.created_at = &t
  25432. }
  25433. // CreatedAt returns the value of the "created_at" field in the mutation.
  25434. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  25435. v := m.created_at
  25436. if v == nil {
  25437. return
  25438. }
  25439. return *v, true
  25440. }
  25441. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  25442. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25444. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25445. if !m.op.Is(OpUpdateOne) {
  25446. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25447. }
  25448. if m.id == nil || m.oldValue == nil {
  25449. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25450. }
  25451. oldValue, err := m.oldValue(ctx)
  25452. if err != nil {
  25453. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25454. }
  25455. return oldValue.CreatedAt, nil
  25456. }
  25457. // ResetCreatedAt resets all changes to the "created_at" field.
  25458. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  25459. m.created_at = nil
  25460. }
  25461. // SetUpdatedAt sets the "updated_at" field.
  25462. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  25463. m.updated_at = &t
  25464. }
  25465. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25466. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  25467. v := m.updated_at
  25468. if v == nil {
  25469. return
  25470. }
  25471. return *v, true
  25472. }
  25473. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  25474. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25476. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25477. if !m.op.Is(OpUpdateOne) {
  25478. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25479. }
  25480. if m.id == nil || m.oldValue == nil {
  25481. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25482. }
  25483. oldValue, err := m.oldValue(ctx)
  25484. if err != nil {
  25485. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25486. }
  25487. return oldValue.UpdatedAt, nil
  25488. }
  25489. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25490. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  25491. m.updated_at = nil
  25492. }
  25493. // SetStatus sets the "status" field.
  25494. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  25495. m.status = &u
  25496. m.addstatus = nil
  25497. }
  25498. // Status returns the value of the "status" field in the mutation.
  25499. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  25500. v := m.status
  25501. if v == nil {
  25502. return
  25503. }
  25504. return *v, true
  25505. }
  25506. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  25507. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25509. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25510. if !m.op.Is(OpUpdateOne) {
  25511. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25512. }
  25513. if m.id == nil || m.oldValue == nil {
  25514. return v, errors.New("OldStatus requires an ID field in the mutation")
  25515. }
  25516. oldValue, err := m.oldValue(ctx)
  25517. if err != nil {
  25518. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25519. }
  25520. return oldValue.Status, nil
  25521. }
  25522. // AddStatus adds u to the "status" field.
  25523. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  25524. if m.addstatus != nil {
  25525. *m.addstatus += u
  25526. } else {
  25527. m.addstatus = &u
  25528. }
  25529. }
  25530. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25531. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  25532. v := m.addstatus
  25533. if v == nil {
  25534. return
  25535. }
  25536. return *v, true
  25537. }
  25538. // ClearStatus clears the value of the "status" field.
  25539. func (m *UsageStatisticDayMutation) ClearStatus() {
  25540. m.status = nil
  25541. m.addstatus = nil
  25542. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  25543. }
  25544. // StatusCleared returns if the "status" field was cleared in this mutation.
  25545. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  25546. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  25547. return ok
  25548. }
  25549. // ResetStatus resets all changes to the "status" field.
  25550. func (m *UsageStatisticDayMutation) ResetStatus() {
  25551. m.status = nil
  25552. m.addstatus = nil
  25553. delete(m.clearedFields, usagestatisticday.FieldStatus)
  25554. }
  25555. // SetDeletedAt sets the "deleted_at" field.
  25556. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  25557. m.deleted_at = &t
  25558. }
  25559. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25560. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  25561. v := m.deleted_at
  25562. if v == nil {
  25563. return
  25564. }
  25565. return *v, true
  25566. }
  25567. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  25568. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25570. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25571. if !m.op.Is(OpUpdateOne) {
  25572. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25573. }
  25574. if m.id == nil || m.oldValue == nil {
  25575. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25576. }
  25577. oldValue, err := m.oldValue(ctx)
  25578. if err != nil {
  25579. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25580. }
  25581. return oldValue.DeletedAt, nil
  25582. }
  25583. // ClearDeletedAt clears the value of the "deleted_at" field.
  25584. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  25585. m.deleted_at = nil
  25586. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  25587. }
  25588. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25589. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  25590. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  25591. return ok
  25592. }
  25593. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25594. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  25595. m.deleted_at = nil
  25596. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  25597. }
  25598. // SetAddtime sets the "addtime" field.
  25599. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  25600. m.addtime = &u
  25601. m.addaddtime = nil
  25602. }
  25603. // Addtime returns the value of the "addtime" field in the mutation.
  25604. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  25605. v := m.addtime
  25606. if v == nil {
  25607. return
  25608. }
  25609. return *v, true
  25610. }
  25611. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  25612. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25614. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  25615. if !m.op.Is(OpUpdateOne) {
  25616. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  25617. }
  25618. if m.id == nil || m.oldValue == nil {
  25619. return v, errors.New("OldAddtime requires an ID field in the mutation")
  25620. }
  25621. oldValue, err := m.oldValue(ctx)
  25622. if err != nil {
  25623. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  25624. }
  25625. return oldValue.Addtime, nil
  25626. }
  25627. // AddAddtime adds u to the "addtime" field.
  25628. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  25629. if m.addaddtime != nil {
  25630. *m.addaddtime += u
  25631. } else {
  25632. m.addaddtime = &u
  25633. }
  25634. }
  25635. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  25636. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  25637. v := m.addaddtime
  25638. if v == nil {
  25639. return
  25640. }
  25641. return *v, true
  25642. }
  25643. // ResetAddtime resets all changes to the "addtime" field.
  25644. func (m *UsageStatisticDayMutation) ResetAddtime() {
  25645. m.addtime = nil
  25646. m.addaddtime = nil
  25647. }
  25648. // SetType sets the "type" field.
  25649. func (m *UsageStatisticDayMutation) SetType(i int) {
  25650. m._type = &i
  25651. m.add_type = nil
  25652. }
  25653. // GetType returns the value of the "type" field in the mutation.
  25654. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  25655. v := m._type
  25656. if v == nil {
  25657. return
  25658. }
  25659. return *v, true
  25660. }
  25661. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  25662. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25664. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  25665. if !m.op.Is(OpUpdateOne) {
  25666. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25667. }
  25668. if m.id == nil || m.oldValue == nil {
  25669. return v, errors.New("OldType requires an ID field in the mutation")
  25670. }
  25671. oldValue, err := m.oldValue(ctx)
  25672. if err != nil {
  25673. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25674. }
  25675. return oldValue.Type, nil
  25676. }
  25677. // AddType adds i to the "type" field.
  25678. func (m *UsageStatisticDayMutation) AddType(i int) {
  25679. if m.add_type != nil {
  25680. *m.add_type += i
  25681. } else {
  25682. m.add_type = &i
  25683. }
  25684. }
  25685. // AddedType returns the value that was added to the "type" field in this mutation.
  25686. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  25687. v := m.add_type
  25688. if v == nil {
  25689. return
  25690. }
  25691. return *v, true
  25692. }
  25693. // ResetType resets all changes to the "type" field.
  25694. func (m *UsageStatisticDayMutation) ResetType() {
  25695. m._type = nil
  25696. m.add_type = nil
  25697. }
  25698. // SetBotID sets the "bot_id" field.
  25699. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  25700. m.bot_id = &s
  25701. }
  25702. // BotID returns the value of the "bot_id" field in the mutation.
  25703. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  25704. v := m.bot_id
  25705. if v == nil {
  25706. return
  25707. }
  25708. return *v, true
  25709. }
  25710. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  25711. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25713. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  25714. if !m.op.Is(OpUpdateOne) {
  25715. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  25716. }
  25717. if m.id == nil || m.oldValue == nil {
  25718. return v, errors.New("OldBotID requires an ID field in the mutation")
  25719. }
  25720. oldValue, err := m.oldValue(ctx)
  25721. if err != nil {
  25722. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  25723. }
  25724. return oldValue.BotID, nil
  25725. }
  25726. // ClearBotID clears the value of the "bot_id" field.
  25727. func (m *UsageStatisticDayMutation) ClearBotID() {
  25728. m.bot_id = nil
  25729. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  25730. }
  25731. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  25732. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  25733. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  25734. return ok
  25735. }
  25736. // ResetBotID resets all changes to the "bot_id" field.
  25737. func (m *UsageStatisticDayMutation) ResetBotID() {
  25738. m.bot_id = nil
  25739. delete(m.clearedFields, usagestatisticday.FieldBotID)
  25740. }
  25741. // SetOrganizationID sets the "organization_id" field.
  25742. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  25743. m.organization_id = &u
  25744. m.addorganization_id = nil
  25745. }
  25746. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25747. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  25748. v := m.organization_id
  25749. if v == nil {
  25750. return
  25751. }
  25752. return *v, true
  25753. }
  25754. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  25755. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25757. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25758. if !m.op.Is(OpUpdateOne) {
  25759. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25760. }
  25761. if m.id == nil || m.oldValue == nil {
  25762. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25763. }
  25764. oldValue, err := m.oldValue(ctx)
  25765. if err != nil {
  25766. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25767. }
  25768. return oldValue.OrganizationID, nil
  25769. }
  25770. // AddOrganizationID adds u to the "organization_id" field.
  25771. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  25772. if m.addorganization_id != nil {
  25773. *m.addorganization_id += u
  25774. } else {
  25775. m.addorganization_id = &u
  25776. }
  25777. }
  25778. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25779. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  25780. v := m.addorganization_id
  25781. if v == nil {
  25782. return
  25783. }
  25784. return *v, true
  25785. }
  25786. // ClearOrganizationID clears the value of the "organization_id" field.
  25787. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  25788. m.organization_id = nil
  25789. m.addorganization_id = nil
  25790. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  25791. }
  25792. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25793. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  25794. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  25795. return ok
  25796. }
  25797. // ResetOrganizationID resets all changes to the "organization_id" field.
  25798. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  25799. m.organization_id = nil
  25800. m.addorganization_id = nil
  25801. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  25802. }
  25803. // SetAiResponse sets the "ai_response" field.
  25804. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  25805. m.ai_response = &u
  25806. m.addai_response = nil
  25807. }
  25808. // AiResponse returns the value of the "ai_response" field in the mutation.
  25809. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  25810. v := m.ai_response
  25811. if v == nil {
  25812. return
  25813. }
  25814. return *v, true
  25815. }
  25816. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  25817. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25819. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  25820. if !m.op.Is(OpUpdateOne) {
  25821. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  25822. }
  25823. if m.id == nil || m.oldValue == nil {
  25824. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  25825. }
  25826. oldValue, err := m.oldValue(ctx)
  25827. if err != nil {
  25828. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  25829. }
  25830. return oldValue.AiResponse, nil
  25831. }
  25832. // AddAiResponse adds u to the "ai_response" field.
  25833. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  25834. if m.addai_response != nil {
  25835. *m.addai_response += u
  25836. } else {
  25837. m.addai_response = &u
  25838. }
  25839. }
  25840. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  25841. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  25842. v := m.addai_response
  25843. if v == nil {
  25844. return
  25845. }
  25846. return *v, true
  25847. }
  25848. // ResetAiResponse resets all changes to the "ai_response" field.
  25849. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  25850. m.ai_response = nil
  25851. m.addai_response = nil
  25852. }
  25853. // SetSopRun sets the "sop_run" field.
  25854. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  25855. m.sop_run = &u
  25856. m.addsop_run = nil
  25857. }
  25858. // SopRun returns the value of the "sop_run" field in the mutation.
  25859. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  25860. v := m.sop_run
  25861. if v == nil {
  25862. return
  25863. }
  25864. return *v, true
  25865. }
  25866. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  25867. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25869. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  25870. if !m.op.Is(OpUpdateOne) {
  25871. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  25872. }
  25873. if m.id == nil || m.oldValue == nil {
  25874. return v, errors.New("OldSopRun requires an ID field in the mutation")
  25875. }
  25876. oldValue, err := m.oldValue(ctx)
  25877. if err != nil {
  25878. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  25879. }
  25880. return oldValue.SopRun, nil
  25881. }
  25882. // AddSopRun adds u to the "sop_run" field.
  25883. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  25884. if m.addsop_run != nil {
  25885. *m.addsop_run += u
  25886. } else {
  25887. m.addsop_run = &u
  25888. }
  25889. }
  25890. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  25891. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  25892. v := m.addsop_run
  25893. if v == nil {
  25894. return
  25895. }
  25896. return *v, true
  25897. }
  25898. // ResetSopRun resets all changes to the "sop_run" field.
  25899. func (m *UsageStatisticDayMutation) ResetSopRun() {
  25900. m.sop_run = nil
  25901. m.addsop_run = nil
  25902. }
  25903. // SetTotalFriend sets the "total_friend" field.
  25904. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  25905. m.total_friend = &u
  25906. m.addtotal_friend = nil
  25907. }
  25908. // TotalFriend returns the value of the "total_friend" field in the mutation.
  25909. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  25910. v := m.total_friend
  25911. if v == nil {
  25912. return
  25913. }
  25914. return *v, true
  25915. }
  25916. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  25917. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25919. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  25920. if !m.op.Is(OpUpdateOne) {
  25921. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  25922. }
  25923. if m.id == nil || m.oldValue == nil {
  25924. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  25925. }
  25926. oldValue, err := m.oldValue(ctx)
  25927. if err != nil {
  25928. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  25929. }
  25930. return oldValue.TotalFriend, nil
  25931. }
  25932. // AddTotalFriend adds u to the "total_friend" field.
  25933. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  25934. if m.addtotal_friend != nil {
  25935. *m.addtotal_friend += u
  25936. } else {
  25937. m.addtotal_friend = &u
  25938. }
  25939. }
  25940. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  25941. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  25942. v := m.addtotal_friend
  25943. if v == nil {
  25944. return
  25945. }
  25946. return *v, true
  25947. }
  25948. // ResetTotalFriend resets all changes to the "total_friend" field.
  25949. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  25950. m.total_friend = nil
  25951. m.addtotal_friend = nil
  25952. }
  25953. // SetTotalGroup sets the "total_group" field.
  25954. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  25955. m.total_group = &u
  25956. m.addtotal_group = nil
  25957. }
  25958. // TotalGroup returns the value of the "total_group" field in the mutation.
  25959. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  25960. v := m.total_group
  25961. if v == nil {
  25962. return
  25963. }
  25964. return *v, true
  25965. }
  25966. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  25967. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25969. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  25970. if !m.op.Is(OpUpdateOne) {
  25971. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  25972. }
  25973. if m.id == nil || m.oldValue == nil {
  25974. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  25975. }
  25976. oldValue, err := m.oldValue(ctx)
  25977. if err != nil {
  25978. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  25979. }
  25980. return oldValue.TotalGroup, nil
  25981. }
  25982. // AddTotalGroup adds u to the "total_group" field.
  25983. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  25984. if m.addtotal_group != nil {
  25985. *m.addtotal_group += u
  25986. } else {
  25987. m.addtotal_group = &u
  25988. }
  25989. }
  25990. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  25991. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  25992. v := m.addtotal_group
  25993. if v == nil {
  25994. return
  25995. }
  25996. return *v, true
  25997. }
  25998. // ResetTotalGroup resets all changes to the "total_group" field.
  25999. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  26000. m.total_group = nil
  26001. m.addtotal_group = nil
  26002. }
  26003. // SetAccountBalance sets the "account_balance" field.
  26004. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  26005. m.account_balance = &u
  26006. m.addaccount_balance = nil
  26007. }
  26008. // AccountBalance returns the value of the "account_balance" field in the mutation.
  26009. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  26010. v := m.account_balance
  26011. if v == nil {
  26012. return
  26013. }
  26014. return *v, true
  26015. }
  26016. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  26017. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26019. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  26020. if !m.op.Is(OpUpdateOne) {
  26021. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  26022. }
  26023. if m.id == nil || m.oldValue == nil {
  26024. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  26025. }
  26026. oldValue, err := m.oldValue(ctx)
  26027. if err != nil {
  26028. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  26029. }
  26030. return oldValue.AccountBalance, nil
  26031. }
  26032. // AddAccountBalance adds u to the "account_balance" field.
  26033. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  26034. if m.addaccount_balance != nil {
  26035. *m.addaccount_balance += u
  26036. } else {
  26037. m.addaccount_balance = &u
  26038. }
  26039. }
  26040. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  26041. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  26042. v := m.addaccount_balance
  26043. if v == nil {
  26044. return
  26045. }
  26046. return *v, true
  26047. }
  26048. // ResetAccountBalance resets all changes to the "account_balance" field.
  26049. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  26050. m.account_balance = nil
  26051. m.addaccount_balance = nil
  26052. }
  26053. // SetConsumeToken sets the "consume_token" field.
  26054. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  26055. m.consume_token = &u
  26056. m.addconsume_token = nil
  26057. }
  26058. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  26059. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  26060. v := m.consume_token
  26061. if v == nil {
  26062. return
  26063. }
  26064. return *v, true
  26065. }
  26066. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  26067. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26069. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  26070. if !m.op.Is(OpUpdateOne) {
  26071. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  26072. }
  26073. if m.id == nil || m.oldValue == nil {
  26074. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  26075. }
  26076. oldValue, err := m.oldValue(ctx)
  26077. if err != nil {
  26078. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  26079. }
  26080. return oldValue.ConsumeToken, nil
  26081. }
  26082. // AddConsumeToken adds u to the "consume_token" field.
  26083. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  26084. if m.addconsume_token != nil {
  26085. *m.addconsume_token += u
  26086. } else {
  26087. m.addconsume_token = &u
  26088. }
  26089. }
  26090. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  26091. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  26092. v := m.addconsume_token
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // ResetConsumeToken resets all changes to the "consume_token" field.
  26099. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  26100. m.consume_token = nil
  26101. m.addconsume_token = nil
  26102. }
  26103. // SetActiveUser sets the "active_user" field.
  26104. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  26105. m.active_user = &u
  26106. m.addactive_user = nil
  26107. }
  26108. // ActiveUser returns the value of the "active_user" field in the mutation.
  26109. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  26110. v := m.active_user
  26111. if v == nil {
  26112. return
  26113. }
  26114. return *v, true
  26115. }
  26116. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  26117. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26119. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  26120. if !m.op.Is(OpUpdateOne) {
  26121. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  26122. }
  26123. if m.id == nil || m.oldValue == nil {
  26124. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  26125. }
  26126. oldValue, err := m.oldValue(ctx)
  26127. if err != nil {
  26128. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  26129. }
  26130. return oldValue.ActiveUser, nil
  26131. }
  26132. // AddActiveUser adds u to the "active_user" field.
  26133. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  26134. if m.addactive_user != nil {
  26135. *m.addactive_user += u
  26136. } else {
  26137. m.addactive_user = &u
  26138. }
  26139. }
  26140. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  26141. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  26142. v := m.addactive_user
  26143. if v == nil {
  26144. return
  26145. }
  26146. return *v, true
  26147. }
  26148. // ResetActiveUser resets all changes to the "active_user" field.
  26149. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  26150. m.active_user = nil
  26151. m.addactive_user = nil
  26152. }
  26153. // SetNewUser sets the "new_user" field.
  26154. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  26155. m.new_user = &i
  26156. m.addnew_user = nil
  26157. }
  26158. // NewUser returns the value of the "new_user" field in the mutation.
  26159. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  26160. v := m.new_user
  26161. if v == nil {
  26162. return
  26163. }
  26164. return *v, true
  26165. }
  26166. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  26167. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26169. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  26170. if !m.op.Is(OpUpdateOne) {
  26171. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  26172. }
  26173. if m.id == nil || m.oldValue == nil {
  26174. return v, errors.New("OldNewUser requires an ID field in the mutation")
  26175. }
  26176. oldValue, err := m.oldValue(ctx)
  26177. if err != nil {
  26178. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  26179. }
  26180. return oldValue.NewUser, nil
  26181. }
  26182. // AddNewUser adds i to the "new_user" field.
  26183. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  26184. if m.addnew_user != nil {
  26185. *m.addnew_user += i
  26186. } else {
  26187. m.addnew_user = &i
  26188. }
  26189. }
  26190. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  26191. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  26192. v := m.addnew_user
  26193. if v == nil {
  26194. return
  26195. }
  26196. return *v, true
  26197. }
  26198. // ResetNewUser resets all changes to the "new_user" field.
  26199. func (m *UsageStatisticDayMutation) ResetNewUser() {
  26200. m.new_user = nil
  26201. m.addnew_user = nil
  26202. }
  26203. // SetLabelDist sets the "label_dist" field.
  26204. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  26205. m.label_dist = &ctd
  26206. m.appendlabel_dist = nil
  26207. }
  26208. // LabelDist returns the value of the "label_dist" field in the mutation.
  26209. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  26210. v := m.label_dist
  26211. if v == nil {
  26212. return
  26213. }
  26214. return *v, true
  26215. }
  26216. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  26217. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  26218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26219. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  26220. if !m.op.Is(OpUpdateOne) {
  26221. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  26222. }
  26223. if m.id == nil || m.oldValue == nil {
  26224. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  26225. }
  26226. oldValue, err := m.oldValue(ctx)
  26227. if err != nil {
  26228. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  26229. }
  26230. return oldValue.LabelDist, nil
  26231. }
  26232. // AppendLabelDist adds ctd to the "label_dist" field.
  26233. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  26234. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  26235. }
  26236. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  26237. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  26238. if len(m.appendlabel_dist) == 0 {
  26239. return nil, false
  26240. }
  26241. return m.appendlabel_dist, true
  26242. }
  26243. // ResetLabelDist resets all changes to the "label_dist" field.
  26244. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  26245. m.label_dist = nil
  26246. m.appendlabel_dist = nil
  26247. }
  26248. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  26249. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  26250. m.predicates = append(m.predicates, ps...)
  26251. }
  26252. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  26253. // users can use type-assertion to append predicates that do not depend on any generated package.
  26254. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  26255. p := make([]predicate.UsageStatisticDay, len(ps))
  26256. for i := range ps {
  26257. p[i] = ps[i]
  26258. }
  26259. m.Where(p...)
  26260. }
  26261. // Op returns the operation name.
  26262. func (m *UsageStatisticDayMutation) Op() Op {
  26263. return m.op
  26264. }
  26265. // SetOp allows setting the mutation operation.
  26266. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  26267. m.op = op
  26268. }
  26269. // Type returns the node type of this mutation (UsageStatisticDay).
  26270. func (m *UsageStatisticDayMutation) Type() string {
  26271. return m.typ
  26272. }
  26273. // Fields returns all fields that were changed during this mutation. Note that in
  26274. // order to get all numeric fields that were incremented/decremented, call
  26275. // AddedFields().
  26276. func (m *UsageStatisticDayMutation) Fields() []string {
  26277. fields := make([]string, 0, 17)
  26278. if m.created_at != nil {
  26279. fields = append(fields, usagestatisticday.FieldCreatedAt)
  26280. }
  26281. if m.updated_at != nil {
  26282. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  26283. }
  26284. if m.status != nil {
  26285. fields = append(fields, usagestatisticday.FieldStatus)
  26286. }
  26287. if m.deleted_at != nil {
  26288. fields = append(fields, usagestatisticday.FieldDeletedAt)
  26289. }
  26290. if m.addtime != nil {
  26291. fields = append(fields, usagestatisticday.FieldAddtime)
  26292. }
  26293. if m._type != nil {
  26294. fields = append(fields, usagestatisticday.FieldType)
  26295. }
  26296. if m.bot_id != nil {
  26297. fields = append(fields, usagestatisticday.FieldBotID)
  26298. }
  26299. if m.organization_id != nil {
  26300. fields = append(fields, usagestatisticday.FieldOrganizationID)
  26301. }
  26302. if m.ai_response != nil {
  26303. fields = append(fields, usagestatisticday.FieldAiResponse)
  26304. }
  26305. if m.sop_run != nil {
  26306. fields = append(fields, usagestatisticday.FieldSopRun)
  26307. }
  26308. if m.total_friend != nil {
  26309. fields = append(fields, usagestatisticday.FieldTotalFriend)
  26310. }
  26311. if m.total_group != nil {
  26312. fields = append(fields, usagestatisticday.FieldTotalGroup)
  26313. }
  26314. if m.account_balance != nil {
  26315. fields = append(fields, usagestatisticday.FieldAccountBalance)
  26316. }
  26317. if m.consume_token != nil {
  26318. fields = append(fields, usagestatisticday.FieldConsumeToken)
  26319. }
  26320. if m.active_user != nil {
  26321. fields = append(fields, usagestatisticday.FieldActiveUser)
  26322. }
  26323. if m.new_user != nil {
  26324. fields = append(fields, usagestatisticday.FieldNewUser)
  26325. }
  26326. if m.label_dist != nil {
  26327. fields = append(fields, usagestatisticday.FieldLabelDist)
  26328. }
  26329. return fields
  26330. }
  26331. // Field returns the value of a field with the given name. The second boolean
  26332. // return value indicates that this field was not set, or was not defined in the
  26333. // schema.
  26334. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  26335. switch name {
  26336. case usagestatisticday.FieldCreatedAt:
  26337. return m.CreatedAt()
  26338. case usagestatisticday.FieldUpdatedAt:
  26339. return m.UpdatedAt()
  26340. case usagestatisticday.FieldStatus:
  26341. return m.Status()
  26342. case usagestatisticday.FieldDeletedAt:
  26343. return m.DeletedAt()
  26344. case usagestatisticday.FieldAddtime:
  26345. return m.Addtime()
  26346. case usagestatisticday.FieldType:
  26347. return m.GetType()
  26348. case usagestatisticday.FieldBotID:
  26349. return m.BotID()
  26350. case usagestatisticday.FieldOrganizationID:
  26351. return m.OrganizationID()
  26352. case usagestatisticday.FieldAiResponse:
  26353. return m.AiResponse()
  26354. case usagestatisticday.FieldSopRun:
  26355. return m.SopRun()
  26356. case usagestatisticday.FieldTotalFriend:
  26357. return m.TotalFriend()
  26358. case usagestatisticday.FieldTotalGroup:
  26359. return m.TotalGroup()
  26360. case usagestatisticday.FieldAccountBalance:
  26361. return m.AccountBalance()
  26362. case usagestatisticday.FieldConsumeToken:
  26363. return m.ConsumeToken()
  26364. case usagestatisticday.FieldActiveUser:
  26365. return m.ActiveUser()
  26366. case usagestatisticday.FieldNewUser:
  26367. return m.NewUser()
  26368. case usagestatisticday.FieldLabelDist:
  26369. return m.LabelDist()
  26370. }
  26371. return nil, false
  26372. }
  26373. // OldField returns the old value of the field from the database. An error is
  26374. // returned if the mutation operation is not UpdateOne, or the query to the
  26375. // database failed.
  26376. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26377. switch name {
  26378. case usagestatisticday.FieldCreatedAt:
  26379. return m.OldCreatedAt(ctx)
  26380. case usagestatisticday.FieldUpdatedAt:
  26381. return m.OldUpdatedAt(ctx)
  26382. case usagestatisticday.FieldStatus:
  26383. return m.OldStatus(ctx)
  26384. case usagestatisticday.FieldDeletedAt:
  26385. return m.OldDeletedAt(ctx)
  26386. case usagestatisticday.FieldAddtime:
  26387. return m.OldAddtime(ctx)
  26388. case usagestatisticday.FieldType:
  26389. return m.OldType(ctx)
  26390. case usagestatisticday.FieldBotID:
  26391. return m.OldBotID(ctx)
  26392. case usagestatisticday.FieldOrganizationID:
  26393. return m.OldOrganizationID(ctx)
  26394. case usagestatisticday.FieldAiResponse:
  26395. return m.OldAiResponse(ctx)
  26396. case usagestatisticday.FieldSopRun:
  26397. return m.OldSopRun(ctx)
  26398. case usagestatisticday.FieldTotalFriend:
  26399. return m.OldTotalFriend(ctx)
  26400. case usagestatisticday.FieldTotalGroup:
  26401. return m.OldTotalGroup(ctx)
  26402. case usagestatisticday.FieldAccountBalance:
  26403. return m.OldAccountBalance(ctx)
  26404. case usagestatisticday.FieldConsumeToken:
  26405. return m.OldConsumeToken(ctx)
  26406. case usagestatisticday.FieldActiveUser:
  26407. return m.OldActiveUser(ctx)
  26408. case usagestatisticday.FieldNewUser:
  26409. return m.OldNewUser(ctx)
  26410. case usagestatisticday.FieldLabelDist:
  26411. return m.OldLabelDist(ctx)
  26412. }
  26413. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  26414. }
  26415. // SetField sets the value of a field with the given name. It returns an error if
  26416. // the field is not defined in the schema, or if the type mismatched the field
  26417. // type.
  26418. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  26419. switch name {
  26420. case usagestatisticday.FieldCreatedAt:
  26421. v, ok := value.(time.Time)
  26422. if !ok {
  26423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26424. }
  26425. m.SetCreatedAt(v)
  26426. return nil
  26427. case usagestatisticday.FieldUpdatedAt:
  26428. v, ok := value.(time.Time)
  26429. if !ok {
  26430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26431. }
  26432. m.SetUpdatedAt(v)
  26433. return nil
  26434. case usagestatisticday.FieldStatus:
  26435. v, ok := value.(uint8)
  26436. if !ok {
  26437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26438. }
  26439. m.SetStatus(v)
  26440. return nil
  26441. case usagestatisticday.FieldDeletedAt:
  26442. v, ok := value.(time.Time)
  26443. if !ok {
  26444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26445. }
  26446. m.SetDeletedAt(v)
  26447. return nil
  26448. case usagestatisticday.FieldAddtime:
  26449. v, ok := value.(uint64)
  26450. if !ok {
  26451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26452. }
  26453. m.SetAddtime(v)
  26454. return nil
  26455. case usagestatisticday.FieldType:
  26456. v, ok := value.(int)
  26457. if !ok {
  26458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26459. }
  26460. m.SetType(v)
  26461. return nil
  26462. case usagestatisticday.FieldBotID:
  26463. v, ok := value.(string)
  26464. if !ok {
  26465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26466. }
  26467. m.SetBotID(v)
  26468. return nil
  26469. case usagestatisticday.FieldOrganizationID:
  26470. v, ok := value.(uint64)
  26471. if !ok {
  26472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26473. }
  26474. m.SetOrganizationID(v)
  26475. return nil
  26476. case usagestatisticday.FieldAiResponse:
  26477. v, ok := value.(uint64)
  26478. if !ok {
  26479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26480. }
  26481. m.SetAiResponse(v)
  26482. return nil
  26483. case usagestatisticday.FieldSopRun:
  26484. v, ok := value.(uint64)
  26485. if !ok {
  26486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26487. }
  26488. m.SetSopRun(v)
  26489. return nil
  26490. case usagestatisticday.FieldTotalFriend:
  26491. v, ok := value.(uint64)
  26492. if !ok {
  26493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26494. }
  26495. m.SetTotalFriend(v)
  26496. return nil
  26497. case usagestatisticday.FieldTotalGroup:
  26498. v, ok := value.(uint64)
  26499. if !ok {
  26500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26501. }
  26502. m.SetTotalGroup(v)
  26503. return nil
  26504. case usagestatisticday.FieldAccountBalance:
  26505. v, ok := value.(uint64)
  26506. if !ok {
  26507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26508. }
  26509. m.SetAccountBalance(v)
  26510. return nil
  26511. case usagestatisticday.FieldConsumeToken:
  26512. v, ok := value.(uint64)
  26513. if !ok {
  26514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26515. }
  26516. m.SetConsumeToken(v)
  26517. return nil
  26518. case usagestatisticday.FieldActiveUser:
  26519. v, ok := value.(uint64)
  26520. if !ok {
  26521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26522. }
  26523. m.SetActiveUser(v)
  26524. return nil
  26525. case usagestatisticday.FieldNewUser:
  26526. v, ok := value.(int64)
  26527. if !ok {
  26528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26529. }
  26530. m.SetNewUser(v)
  26531. return nil
  26532. case usagestatisticday.FieldLabelDist:
  26533. v, ok := value.([]custom_types.LabelDist)
  26534. if !ok {
  26535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26536. }
  26537. m.SetLabelDist(v)
  26538. return nil
  26539. }
  26540. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  26541. }
  26542. // AddedFields returns all numeric fields that were incremented/decremented during
  26543. // this mutation.
  26544. func (m *UsageStatisticDayMutation) AddedFields() []string {
  26545. var fields []string
  26546. if m.addstatus != nil {
  26547. fields = append(fields, usagestatisticday.FieldStatus)
  26548. }
  26549. if m.addaddtime != nil {
  26550. fields = append(fields, usagestatisticday.FieldAddtime)
  26551. }
  26552. if m.add_type != nil {
  26553. fields = append(fields, usagestatisticday.FieldType)
  26554. }
  26555. if m.addorganization_id != nil {
  26556. fields = append(fields, usagestatisticday.FieldOrganizationID)
  26557. }
  26558. if m.addai_response != nil {
  26559. fields = append(fields, usagestatisticday.FieldAiResponse)
  26560. }
  26561. if m.addsop_run != nil {
  26562. fields = append(fields, usagestatisticday.FieldSopRun)
  26563. }
  26564. if m.addtotal_friend != nil {
  26565. fields = append(fields, usagestatisticday.FieldTotalFriend)
  26566. }
  26567. if m.addtotal_group != nil {
  26568. fields = append(fields, usagestatisticday.FieldTotalGroup)
  26569. }
  26570. if m.addaccount_balance != nil {
  26571. fields = append(fields, usagestatisticday.FieldAccountBalance)
  26572. }
  26573. if m.addconsume_token != nil {
  26574. fields = append(fields, usagestatisticday.FieldConsumeToken)
  26575. }
  26576. if m.addactive_user != nil {
  26577. fields = append(fields, usagestatisticday.FieldActiveUser)
  26578. }
  26579. if m.addnew_user != nil {
  26580. fields = append(fields, usagestatisticday.FieldNewUser)
  26581. }
  26582. return fields
  26583. }
  26584. // AddedField returns the numeric value that was incremented/decremented on a field
  26585. // with the given name. The second boolean return value indicates that this field
  26586. // was not set, or was not defined in the schema.
  26587. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  26588. switch name {
  26589. case usagestatisticday.FieldStatus:
  26590. return m.AddedStatus()
  26591. case usagestatisticday.FieldAddtime:
  26592. return m.AddedAddtime()
  26593. case usagestatisticday.FieldType:
  26594. return m.AddedType()
  26595. case usagestatisticday.FieldOrganizationID:
  26596. return m.AddedOrganizationID()
  26597. case usagestatisticday.FieldAiResponse:
  26598. return m.AddedAiResponse()
  26599. case usagestatisticday.FieldSopRun:
  26600. return m.AddedSopRun()
  26601. case usagestatisticday.FieldTotalFriend:
  26602. return m.AddedTotalFriend()
  26603. case usagestatisticday.FieldTotalGroup:
  26604. return m.AddedTotalGroup()
  26605. case usagestatisticday.FieldAccountBalance:
  26606. return m.AddedAccountBalance()
  26607. case usagestatisticday.FieldConsumeToken:
  26608. return m.AddedConsumeToken()
  26609. case usagestatisticday.FieldActiveUser:
  26610. return m.AddedActiveUser()
  26611. case usagestatisticday.FieldNewUser:
  26612. return m.AddedNewUser()
  26613. }
  26614. return nil, false
  26615. }
  26616. // AddField adds the value to the field with the given name. It returns an error if
  26617. // the field is not defined in the schema, or if the type mismatched the field
  26618. // type.
  26619. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  26620. switch name {
  26621. case usagestatisticday.FieldStatus:
  26622. v, ok := value.(int8)
  26623. if !ok {
  26624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26625. }
  26626. m.AddStatus(v)
  26627. return nil
  26628. case usagestatisticday.FieldAddtime:
  26629. v, ok := value.(int64)
  26630. if !ok {
  26631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26632. }
  26633. m.AddAddtime(v)
  26634. return nil
  26635. case usagestatisticday.FieldType:
  26636. v, ok := value.(int)
  26637. if !ok {
  26638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26639. }
  26640. m.AddType(v)
  26641. return nil
  26642. case usagestatisticday.FieldOrganizationID:
  26643. v, ok := value.(int64)
  26644. if !ok {
  26645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26646. }
  26647. m.AddOrganizationID(v)
  26648. return nil
  26649. case usagestatisticday.FieldAiResponse:
  26650. v, ok := value.(int64)
  26651. if !ok {
  26652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26653. }
  26654. m.AddAiResponse(v)
  26655. return nil
  26656. case usagestatisticday.FieldSopRun:
  26657. v, ok := value.(int64)
  26658. if !ok {
  26659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26660. }
  26661. m.AddSopRun(v)
  26662. return nil
  26663. case usagestatisticday.FieldTotalFriend:
  26664. v, ok := value.(int64)
  26665. if !ok {
  26666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26667. }
  26668. m.AddTotalFriend(v)
  26669. return nil
  26670. case usagestatisticday.FieldTotalGroup:
  26671. v, ok := value.(int64)
  26672. if !ok {
  26673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26674. }
  26675. m.AddTotalGroup(v)
  26676. return nil
  26677. case usagestatisticday.FieldAccountBalance:
  26678. v, ok := value.(int64)
  26679. if !ok {
  26680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26681. }
  26682. m.AddAccountBalance(v)
  26683. return nil
  26684. case usagestatisticday.FieldConsumeToken:
  26685. v, ok := value.(int64)
  26686. if !ok {
  26687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26688. }
  26689. m.AddConsumeToken(v)
  26690. return nil
  26691. case usagestatisticday.FieldActiveUser:
  26692. v, ok := value.(int64)
  26693. if !ok {
  26694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26695. }
  26696. m.AddActiveUser(v)
  26697. return nil
  26698. case usagestatisticday.FieldNewUser:
  26699. v, ok := value.(int64)
  26700. if !ok {
  26701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26702. }
  26703. m.AddNewUser(v)
  26704. return nil
  26705. }
  26706. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  26707. }
  26708. // ClearedFields returns all nullable fields that were cleared during this
  26709. // mutation.
  26710. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  26711. var fields []string
  26712. if m.FieldCleared(usagestatisticday.FieldStatus) {
  26713. fields = append(fields, usagestatisticday.FieldStatus)
  26714. }
  26715. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  26716. fields = append(fields, usagestatisticday.FieldDeletedAt)
  26717. }
  26718. if m.FieldCleared(usagestatisticday.FieldBotID) {
  26719. fields = append(fields, usagestatisticday.FieldBotID)
  26720. }
  26721. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  26722. fields = append(fields, usagestatisticday.FieldOrganizationID)
  26723. }
  26724. return fields
  26725. }
  26726. // FieldCleared returns a boolean indicating if a field with the given name was
  26727. // cleared in this mutation.
  26728. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  26729. _, ok := m.clearedFields[name]
  26730. return ok
  26731. }
  26732. // ClearField clears the value of the field with the given name. It returns an
  26733. // error if the field is not defined in the schema.
  26734. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  26735. switch name {
  26736. case usagestatisticday.FieldStatus:
  26737. m.ClearStatus()
  26738. return nil
  26739. case usagestatisticday.FieldDeletedAt:
  26740. m.ClearDeletedAt()
  26741. return nil
  26742. case usagestatisticday.FieldBotID:
  26743. m.ClearBotID()
  26744. return nil
  26745. case usagestatisticday.FieldOrganizationID:
  26746. m.ClearOrganizationID()
  26747. return nil
  26748. }
  26749. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  26750. }
  26751. // ResetField resets all changes in the mutation for the field with the given name.
  26752. // It returns an error if the field is not defined in the schema.
  26753. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  26754. switch name {
  26755. case usagestatisticday.FieldCreatedAt:
  26756. m.ResetCreatedAt()
  26757. return nil
  26758. case usagestatisticday.FieldUpdatedAt:
  26759. m.ResetUpdatedAt()
  26760. return nil
  26761. case usagestatisticday.FieldStatus:
  26762. m.ResetStatus()
  26763. return nil
  26764. case usagestatisticday.FieldDeletedAt:
  26765. m.ResetDeletedAt()
  26766. return nil
  26767. case usagestatisticday.FieldAddtime:
  26768. m.ResetAddtime()
  26769. return nil
  26770. case usagestatisticday.FieldType:
  26771. m.ResetType()
  26772. return nil
  26773. case usagestatisticday.FieldBotID:
  26774. m.ResetBotID()
  26775. return nil
  26776. case usagestatisticday.FieldOrganizationID:
  26777. m.ResetOrganizationID()
  26778. return nil
  26779. case usagestatisticday.FieldAiResponse:
  26780. m.ResetAiResponse()
  26781. return nil
  26782. case usagestatisticday.FieldSopRun:
  26783. m.ResetSopRun()
  26784. return nil
  26785. case usagestatisticday.FieldTotalFriend:
  26786. m.ResetTotalFriend()
  26787. return nil
  26788. case usagestatisticday.FieldTotalGroup:
  26789. m.ResetTotalGroup()
  26790. return nil
  26791. case usagestatisticday.FieldAccountBalance:
  26792. m.ResetAccountBalance()
  26793. return nil
  26794. case usagestatisticday.FieldConsumeToken:
  26795. m.ResetConsumeToken()
  26796. return nil
  26797. case usagestatisticday.FieldActiveUser:
  26798. m.ResetActiveUser()
  26799. return nil
  26800. case usagestatisticday.FieldNewUser:
  26801. m.ResetNewUser()
  26802. return nil
  26803. case usagestatisticday.FieldLabelDist:
  26804. m.ResetLabelDist()
  26805. return nil
  26806. }
  26807. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  26808. }
  26809. // AddedEdges returns all edge names that were set/added in this mutation.
  26810. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  26811. edges := make([]string, 0, 0)
  26812. return edges
  26813. }
  26814. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26815. // name in this mutation.
  26816. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  26817. return nil
  26818. }
  26819. // RemovedEdges returns all edge names that were removed in this mutation.
  26820. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  26821. edges := make([]string, 0, 0)
  26822. return edges
  26823. }
  26824. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26825. // the given name in this mutation.
  26826. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  26827. return nil
  26828. }
  26829. // ClearedEdges returns all edge names that were cleared in this mutation.
  26830. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  26831. edges := make([]string, 0, 0)
  26832. return edges
  26833. }
  26834. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26835. // was cleared in this mutation.
  26836. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  26837. return false
  26838. }
  26839. // ClearEdge clears the value of the edge with the given name. It returns an error
  26840. // if that edge is not defined in the schema.
  26841. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  26842. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  26843. }
  26844. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26845. // It returns an error if the edge is not defined in the schema.
  26846. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  26847. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  26848. }
  26849. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  26850. type UsageStatisticHourMutation struct {
  26851. config
  26852. op Op
  26853. typ string
  26854. id *uint64
  26855. created_at *time.Time
  26856. updated_at *time.Time
  26857. status *uint8
  26858. addstatus *int8
  26859. deleted_at *time.Time
  26860. addtime *uint64
  26861. addaddtime *int64
  26862. _type *int
  26863. add_type *int
  26864. bot_id *string
  26865. organization_id *uint64
  26866. addorganization_id *int64
  26867. ai_response *uint64
  26868. addai_response *int64
  26869. sop_run *uint64
  26870. addsop_run *int64
  26871. total_friend *uint64
  26872. addtotal_friend *int64
  26873. total_group *uint64
  26874. addtotal_group *int64
  26875. account_balance *uint64
  26876. addaccount_balance *int64
  26877. consume_token *uint64
  26878. addconsume_token *int64
  26879. active_user *uint64
  26880. addactive_user *int64
  26881. new_user *int64
  26882. addnew_user *int64
  26883. label_dist *[]custom_types.LabelDist
  26884. appendlabel_dist []custom_types.LabelDist
  26885. clearedFields map[string]struct{}
  26886. done bool
  26887. oldValue func(context.Context) (*UsageStatisticHour, error)
  26888. predicates []predicate.UsageStatisticHour
  26889. }
  26890. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  26891. // usagestatistichourOption allows management of the mutation configuration using functional options.
  26892. type usagestatistichourOption func(*UsageStatisticHourMutation)
  26893. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  26894. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  26895. m := &UsageStatisticHourMutation{
  26896. config: c,
  26897. op: op,
  26898. typ: TypeUsageStatisticHour,
  26899. clearedFields: make(map[string]struct{}),
  26900. }
  26901. for _, opt := range opts {
  26902. opt(m)
  26903. }
  26904. return m
  26905. }
  26906. // withUsageStatisticHourID sets the ID field of the mutation.
  26907. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  26908. return func(m *UsageStatisticHourMutation) {
  26909. var (
  26910. err error
  26911. once sync.Once
  26912. value *UsageStatisticHour
  26913. )
  26914. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  26915. once.Do(func() {
  26916. if m.done {
  26917. err = errors.New("querying old values post mutation is not allowed")
  26918. } else {
  26919. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  26920. }
  26921. })
  26922. return value, err
  26923. }
  26924. m.id = &id
  26925. }
  26926. }
  26927. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  26928. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  26929. return func(m *UsageStatisticHourMutation) {
  26930. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  26931. return node, nil
  26932. }
  26933. m.id = &node.ID
  26934. }
  26935. }
  26936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26937. // executed in a transaction (ent.Tx), a transactional client is returned.
  26938. func (m UsageStatisticHourMutation) Client() *Client {
  26939. client := &Client{config: m.config}
  26940. client.init()
  26941. return client
  26942. }
  26943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26944. // it returns an error otherwise.
  26945. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  26946. if _, ok := m.driver.(*txDriver); !ok {
  26947. return nil, errors.New("ent: mutation is not running in a transaction")
  26948. }
  26949. tx := &Tx{config: m.config}
  26950. tx.init()
  26951. return tx, nil
  26952. }
  26953. // SetID sets the value of the id field. Note that this
  26954. // operation is only accepted on creation of UsageStatisticHour entities.
  26955. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  26956. m.id = &id
  26957. }
  26958. // ID returns the ID value in the mutation. Note that the ID is only available
  26959. // if it was provided to the builder or after it was returned from the database.
  26960. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  26961. if m.id == nil {
  26962. return
  26963. }
  26964. return *m.id, true
  26965. }
  26966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26967. // That means, if the mutation is applied within a transaction with an isolation level such
  26968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26969. // or updated by the mutation.
  26970. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  26971. switch {
  26972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26973. id, exists := m.ID()
  26974. if exists {
  26975. return []uint64{id}, nil
  26976. }
  26977. fallthrough
  26978. case m.op.Is(OpUpdate | OpDelete):
  26979. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  26980. default:
  26981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26982. }
  26983. }
  26984. // SetCreatedAt sets the "created_at" field.
  26985. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  26986. m.created_at = &t
  26987. }
  26988. // CreatedAt returns the value of the "created_at" field in the mutation.
  26989. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  26990. v := m.created_at
  26991. if v == nil {
  26992. return
  26993. }
  26994. return *v, true
  26995. }
  26996. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  26997. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26999. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27000. if !m.op.Is(OpUpdateOne) {
  27001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27002. }
  27003. if m.id == nil || m.oldValue == nil {
  27004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27005. }
  27006. oldValue, err := m.oldValue(ctx)
  27007. if err != nil {
  27008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27009. }
  27010. return oldValue.CreatedAt, nil
  27011. }
  27012. // ResetCreatedAt resets all changes to the "created_at" field.
  27013. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  27014. m.created_at = nil
  27015. }
  27016. // SetUpdatedAt sets the "updated_at" field.
  27017. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  27018. m.updated_at = &t
  27019. }
  27020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27021. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  27022. v := m.updated_at
  27023. if v == nil {
  27024. return
  27025. }
  27026. return *v, true
  27027. }
  27028. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  27029. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27031. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27032. if !m.op.Is(OpUpdateOne) {
  27033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27034. }
  27035. if m.id == nil || m.oldValue == nil {
  27036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27037. }
  27038. oldValue, err := m.oldValue(ctx)
  27039. if err != nil {
  27040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27041. }
  27042. return oldValue.UpdatedAt, nil
  27043. }
  27044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27045. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  27046. m.updated_at = nil
  27047. }
  27048. // SetStatus sets the "status" field.
  27049. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  27050. m.status = &u
  27051. m.addstatus = nil
  27052. }
  27053. // Status returns the value of the "status" field in the mutation.
  27054. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  27055. v := m.status
  27056. if v == nil {
  27057. return
  27058. }
  27059. return *v, true
  27060. }
  27061. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  27062. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27064. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27065. if !m.op.Is(OpUpdateOne) {
  27066. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27067. }
  27068. if m.id == nil || m.oldValue == nil {
  27069. return v, errors.New("OldStatus requires an ID field in the mutation")
  27070. }
  27071. oldValue, err := m.oldValue(ctx)
  27072. if err != nil {
  27073. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27074. }
  27075. return oldValue.Status, nil
  27076. }
  27077. // AddStatus adds u to the "status" field.
  27078. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  27079. if m.addstatus != nil {
  27080. *m.addstatus += u
  27081. } else {
  27082. m.addstatus = &u
  27083. }
  27084. }
  27085. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27086. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  27087. v := m.addstatus
  27088. if v == nil {
  27089. return
  27090. }
  27091. return *v, true
  27092. }
  27093. // ClearStatus clears the value of the "status" field.
  27094. func (m *UsageStatisticHourMutation) ClearStatus() {
  27095. m.status = nil
  27096. m.addstatus = nil
  27097. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  27098. }
  27099. // StatusCleared returns if the "status" field was cleared in this mutation.
  27100. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  27101. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  27102. return ok
  27103. }
  27104. // ResetStatus resets all changes to the "status" field.
  27105. func (m *UsageStatisticHourMutation) ResetStatus() {
  27106. m.status = nil
  27107. m.addstatus = nil
  27108. delete(m.clearedFields, usagestatistichour.FieldStatus)
  27109. }
  27110. // SetDeletedAt sets the "deleted_at" field.
  27111. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  27112. m.deleted_at = &t
  27113. }
  27114. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27115. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  27116. v := m.deleted_at
  27117. if v == nil {
  27118. return
  27119. }
  27120. return *v, true
  27121. }
  27122. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  27123. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27125. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27126. if !m.op.Is(OpUpdateOne) {
  27127. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27128. }
  27129. if m.id == nil || m.oldValue == nil {
  27130. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27131. }
  27132. oldValue, err := m.oldValue(ctx)
  27133. if err != nil {
  27134. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27135. }
  27136. return oldValue.DeletedAt, nil
  27137. }
  27138. // ClearDeletedAt clears the value of the "deleted_at" field.
  27139. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  27140. m.deleted_at = nil
  27141. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  27142. }
  27143. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27144. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  27145. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  27146. return ok
  27147. }
  27148. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27149. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  27150. m.deleted_at = nil
  27151. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  27152. }
  27153. // SetAddtime sets the "addtime" field.
  27154. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  27155. m.addtime = &u
  27156. m.addaddtime = nil
  27157. }
  27158. // Addtime returns the value of the "addtime" field in the mutation.
  27159. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  27160. v := m.addtime
  27161. if v == nil {
  27162. return
  27163. }
  27164. return *v, true
  27165. }
  27166. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  27167. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27169. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  27170. if !m.op.Is(OpUpdateOne) {
  27171. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  27172. }
  27173. if m.id == nil || m.oldValue == nil {
  27174. return v, errors.New("OldAddtime requires an ID field in the mutation")
  27175. }
  27176. oldValue, err := m.oldValue(ctx)
  27177. if err != nil {
  27178. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  27179. }
  27180. return oldValue.Addtime, nil
  27181. }
  27182. // AddAddtime adds u to the "addtime" field.
  27183. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  27184. if m.addaddtime != nil {
  27185. *m.addaddtime += u
  27186. } else {
  27187. m.addaddtime = &u
  27188. }
  27189. }
  27190. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  27191. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  27192. v := m.addaddtime
  27193. if v == nil {
  27194. return
  27195. }
  27196. return *v, true
  27197. }
  27198. // ResetAddtime resets all changes to the "addtime" field.
  27199. func (m *UsageStatisticHourMutation) ResetAddtime() {
  27200. m.addtime = nil
  27201. m.addaddtime = nil
  27202. }
  27203. // SetType sets the "type" field.
  27204. func (m *UsageStatisticHourMutation) SetType(i int) {
  27205. m._type = &i
  27206. m.add_type = nil
  27207. }
  27208. // GetType returns the value of the "type" field in the mutation.
  27209. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  27210. v := m._type
  27211. if v == nil {
  27212. return
  27213. }
  27214. return *v, true
  27215. }
  27216. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  27217. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27219. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  27220. if !m.op.Is(OpUpdateOne) {
  27221. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27222. }
  27223. if m.id == nil || m.oldValue == nil {
  27224. return v, errors.New("OldType requires an ID field in the mutation")
  27225. }
  27226. oldValue, err := m.oldValue(ctx)
  27227. if err != nil {
  27228. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27229. }
  27230. return oldValue.Type, nil
  27231. }
  27232. // AddType adds i to the "type" field.
  27233. func (m *UsageStatisticHourMutation) AddType(i int) {
  27234. if m.add_type != nil {
  27235. *m.add_type += i
  27236. } else {
  27237. m.add_type = &i
  27238. }
  27239. }
  27240. // AddedType returns the value that was added to the "type" field in this mutation.
  27241. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  27242. v := m.add_type
  27243. if v == nil {
  27244. return
  27245. }
  27246. return *v, true
  27247. }
  27248. // ResetType resets all changes to the "type" field.
  27249. func (m *UsageStatisticHourMutation) ResetType() {
  27250. m._type = nil
  27251. m.add_type = nil
  27252. }
  27253. // SetBotID sets the "bot_id" field.
  27254. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  27255. m.bot_id = &s
  27256. }
  27257. // BotID returns the value of the "bot_id" field in the mutation.
  27258. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  27259. v := m.bot_id
  27260. if v == nil {
  27261. return
  27262. }
  27263. return *v, true
  27264. }
  27265. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  27266. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27268. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  27269. if !m.op.Is(OpUpdateOne) {
  27270. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27271. }
  27272. if m.id == nil || m.oldValue == nil {
  27273. return v, errors.New("OldBotID requires an ID field in the mutation")
  27274. }
  27275. oldValue, err := m.oldValue(ctx)
  27276. if err != nil {
  27277. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27278. }
  27279. return oldValue.BotID, nil
  27280. }
  27281. // ClearBotID clears the value of the "bot_id" field.
  27282. func (m *UsageStatisticHourMutation) ClearBotID() {
  27283. m.bot_id = nil
  27284. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  27285. }
  27286. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  27287. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  27288. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  27289. return ok
  27290. }
  27291. // ResetBotID resets all changes to the "bot_id" field.
  27292. func (m *UsageStatisticHourMutation) ResetBotID() {
  27293. m.bot_id = nil
  27294. delete(m.clearedFields, usagestatistichour.FieldBotID)
  27295. }
  27296. // SetOrganizationID sets the "organization_id" field.
  27297. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  27298. m.organization_id = &u
  27299. m.addorganization_id = nil
  27300. }
  27301. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27302. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  27303. v := m.organization_id
  27304. if v == nil {
  27305. return
  27306. }
  27307. return *v, true
  27308. }
  27309. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  27310. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27312. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27313. if !m.op.Is(OpUpdateOne) {
  27314. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27315. }
  27316. if m.id == nil || m.oldValue == nil {
  27317. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27318. }
  27319. oldValue, err := m.oldValue(ctx)
  27320. if err != nil {
  27321. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27322. }
  27323. return oldValue.OrganizationID, nil
  27324. }
  27325. // AddOrganizationID adds u to the "organization_id" field.
  27326. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  27327. if m.addorganization_id != nil {
  27328. *m.addorganization_id += u
  27329. } else {
  27330. m.addorganization_id = &u
  27331. }
  27332. }
  27333. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27334. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  27335. v := m.addorganization_id
  27336. if v == nil {
  27337. return
  27338. }
  27339. return *v, true
  27340. }
  27341. // ClearOrganizationID clears the value of the "organization_id" field.
  27342. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  27343. m.organization_id = nil
  27344. m.addorganization_id = nil
  27345. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  27346. }
  27347. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27348. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  27349. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  27350. return ok
  27351. }
  27352. // ResetOrganizationID resets all changes to the "organization_id" field.
  27353. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  27354. m.organization_id = nil
  27355. m.addorganization_id = nil
  27356. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  27357. }
  27358. // SetAiResponse sets the "ai_response" field.
  27359. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  27360. m.ai_response = &u
  27361. m.addai_response = nil
  27362. }
  27363. // AiResponse returns the value of the "ai_response" field in the mutation.
  27364. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  27365. v := m.ai_response
  27366. if v == nil {
  27367. return
  27368. }
  27369. return *v, true
  27370. }
  27371. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  27372. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27374. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  27375. if !m.op.Is(OpUpdateOne) {
  27376. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  27377. }
  27378. if m.id == nil || m.oldValue == nil {
  27379. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  27380. }
  27381. oldValue, err := m.oldValue(ctx)
  27382. if err != nil {
  27383. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  27384. }
  27385. return oldValue.AiResponse, nil
  27386. }
  27387. // AddAiResponse adds u to the "ai_response" field.
  27388. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  27389. if m.addai_response != nil {
  27390. *m.addai_response += u
  27391. } else {
  27392. m.addai_response = &u
  27393. }
  27394. }
  27395. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  27396. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  27397. v := m.addai_response
  27398. if v == nil {
  27399. return
  27400. }
  27401. return *v, true
  27402. }
  27403. // ResetAiResponse resets all changes to the "ai_response" field.
  27404. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  27405. m.ai_response = nil
  27406. m.addai_response = nil
  27407. }
  27408. // SetSopRun sets the "sop_run" field.
  27409. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  27410. m.sop_run = &u
  27411. m.addsop_run = nil
  27412. }
  27413. // SopRun returns the value of the "sop_run" field in the mutation.
  27414. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  27415. v := m.sop_run
  27416. if v == nil {
  27417. return
  27418. }
  27419. return *v, true
  27420. }
  27421. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  27422. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27424. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  27425. if !m.op.Is(OpUpdateOne) {
  27426. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  27427. }
  27428. if m.id == nil || m.oldValue == nil {
  27429. return v, errors.New("OldSopRun requires an ID field in the mutation")
  27430. }
  27431. oldValue, err := m.oldValue(ctx)
  27432. if err != nil {
  27433. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  27434. }
  27435. return oldValue.SopRun, nil
  27436. }
  27437. // AddSopRun adds u to the "sop_run" field.
  27438. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  27439. if m.addsop_run != nil {
  27440. *m.addsop_run += u
  27441. } else {
  27442. m.addsop_run = &u
  27443. }
  27444. }
  27445. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  27446. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  27447. v := m.addsop_run
  27448. if v == nil {
  27449. return
  27450. }
  27451. return *v, true
  27452. }
  27453. // ResetSopRun resets all changes to the "sop_run" field.
  27454. func (m *UsageStatisticHourMutation) ResetSopRun() {
  27455. m.sop_run = nil
  27456. m.addsop_run = nil
  27457. }
  27458. // SetTotalFriend sets the "total_friend" field.
  27459. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  27460. m.total_friend = &u
  27461. m.addtotal_friend = nil
  27462. }
  27463. // TotalFriend returns the value of the "total_friend" field in the mutation.
  27464. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  27465. v := m.total_friend
  27466. if v == nil {
  27467. return
  27468. }
  27469. return *v, true
  27470. }
  27471. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  27472. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27474. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  27475. if !m.op.Is(OpUpdateOne) {
  27476. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  27477. }
  27478. if m.id == nil || m.oldValue == nil {
  27479. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  27480. }
  27481. oldValue, err := m.oldValue(ctx)
  27482. if err != nil {
  27483. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  27484. }
  27485. return oldValue.TotalFriend, nil
  27486. }
  27487. // AddTotalFriend adds u to the "total_friend" field.
  27488. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  27489. if m.addtotal_friend != nil {
  27490. *m.addtotal_friend += u
  27491. } else {
  27492. m.addtotal_friend = &u
  27493. }
  27494. }
  27495. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  27496. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  27497. v := m.addtotal_friend
  27498. if v == nil {
  27499. return
  27500. }
  27501. return *v, true
  27502. }
  27503. // ResetTotalFriend resets all changes to the "total_friend" field.
  27504. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  27505. m.total_friend = nil
  27506. m.addtotal_friend = nil
  27507. }
  27508. // SetTotalGroup sets the "total_group" field.
  27509. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  27510. m.total_group = &u
  27511. m.addtotal_group = nil
  27512. }
  27513. // TotalGroup returns the value of the "total_group" field in the mutation.
  27514. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  27515. v := m.total_group
  27516. if v == nil {
  27517. return
  27518. }
  27519. return *v, true
  27520. }
  27521. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  27522. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27524. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  27525. if !m.op.Is(OpUpdateOne) {
  27526. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  27527. }
  27528. if m.id == nil || m.oldValue == nil {
  27529. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  27530. }
  27531. oldValue, err := m.oldValue(ctx)
  27532. if err != nil {
  27533. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  27534. }
  27535. return oldValue.TotalGroup, nil
  27536. }
  27537. // AddTotalGroup adds u to the "total_group" field.
  27538. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  27539. if m.addtotal_group != nil {
  27540. *m.addtotal_group += u
  27541. } else {
  27542. m.addtotal_group = &u
  27543. }
  27544. }
  27545. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  27546. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  27547. v := m.addtotal_group
  27548. if v == nil {
  27549. return
  27550. }
  27551. return *v, true
  27552. }
  27553. // ResetTotalGroup resets all changes to the "total_group" field.
  27554. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  27555. m.total_group = nil
  27556. m.addtotal_group = nil
  27557. }
  27558. // SetAccountBalance sets the "account_balance" field.
  27559. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  27560. m.account_balance = &u
  27561. m.addaccount_balance = nil
  27562. }
  27563. // AccountBalance returns the value of the "account_balance" field in the mutation.
  27564. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  27565. v := m.account_balance
  27566. if v == nil {
  27567. return
  27568. }
  27569. return *v, true
  27570. }
  27571. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  27572. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27574. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  27575. if !m.op.Is(OpUpdateOne) {
  27576. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  27577. }
  27578. if m.id == nil || m.oldValue == nil {
  27579. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  27580. }
  27581. oldValue, err := m.oldValue(ctx)
  27582. if err != nil {
  27583. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  27584. }
  27585. return oldValue.AccountBalance, nil
  27586. }
  27587. // AddAccountBalance adds u to the "account_balance" field.
  27588. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  27589. if m.addaccount_balance != nil {
  27590. *m.addaccount_balance += u
  27591. } else {
  27592. m.addaccount_balance = &u
  27593. }
  27594. }
  27595. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  27596. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  27597. v := m.addaccount_balance
  27598. if v == nil {
  27599. return
  27600. }
  27601. return *v, true
  27602. }
  27603. // ResetAccountBalance resets all changes to the "account_balance" field.
  27604. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  27605. m.account_balance = nil
  27606. m.addaccount_balance = nil
  27607. }
  27608. // SetConsumeToken sets the "consume_token" field.
  27609. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  27610. m.consume_token = &u
  27611. m.addconsume_token = nil
  27612. }
  27613. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  27614. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  27615. v := m.consume_token
  27616. if v == nil {
  27617. return
  27618. }
  27619. return *v, true
  27620. }
  27621. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  27622. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27624. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  27625. if !m.op.Is(OpUpdateOne) {
  27626. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  27627. }
  27628. if m.id == nil || m.oldValue == nil {
  27629. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  27630. }
  27631. oldValue, err := m.oldValue(ctx)
  27632. if err != nil {
  27633. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  27634. }
  27635. return oldValue.ConsumeToken, nil
  27636. }
  27637. // AddConsumeToken adds u to the "consume_token" field.
  27638. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  27639. if m.addconsume_token != nil {
  27640. *m.addconsume_token += u
  27641. } else {
  27642. m.addconsume_token = &u
  27643. }
  27644. }
  27645. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  27646. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  27647. v := m.addconsume_token
  27648. if v == nil {
  27649. return
  27650. }
  27651. return *v, true
  27652. }
  27653. // ResetConsumeToken resets all changes to the "consume_token" field.
  27654. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  27655. m.consume_token = nil
  27656. m.addconsume_token = nil
  27657. }
  27658. // SetActiveUser sets the "active_user" field.
  27659. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  27660. m.active_user = &u
  27661. m.addactive_user = nil
  27662. }
  27663. // ActiveUser returns the value of the "active_user" field in the mutation.
  27664. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  27665. v := m.active_user
  27666. if v == nil {
  27667. return
  27668. }
  27669. return *v, true
  27670. }
  27671. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  27672. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27674. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  27675. if !m.op.Is(OpUpdateOne) {
  27676. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  27677. }
  27678. if m.id == nil || m.oldValue == nil {
  27679. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  27680. }
  27681. oldValue, err := m.oldValue(ctx)
  27682. if err != nil {
  27683. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  27684. }
  27685. return oldValue.ActiveUser, nil
  27686. }
  27687. // AddActiveUser adds u to the "active_user" field.
  27688. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  27689. if m.addactive_user != nil {
  27690. *m.addactive_user += u
  27691. } else {
  27692. m.addactive_user = &u
  27693. }
  27694. }
  27695. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  27696. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  27697. v := m.addactive_user
  27698. if v == nil {
  27699. return
  27700. }
  27701. return *v, true
  27702. }
  27703. // ResetActiveUser resets all changes to the "active_user" field.
  27704. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  27705. m.active_user = nil
  27706. m.addactive_user = nil
  27707. }
  27708. // SetNewUser sets the "new_user" field.
  27709. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  27710. m.new_user = &i
  27711. m.addnew_user = nil
  27712. }
  27713. // NewUser returns the value of the "new_user" field in the mutation.
  27714. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  27715. v := m.new_user
  27716. if v == nil {
  27717. return
  27718. }
  27719. return *v, true
  27720. }
  27721. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  27722. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27724. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  27725. if !m.op.Is(OpUpdateOne) {
  27726. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  27727. }
  27728. if m.id == nil || m.oldValue == nil {
  27729. return v, errors.New("OldNewUser requires an ID field in the mutation")
  27730. }
  27731. oldValue, err := m.oldValue(ctx)
  27732. if err != nil {
  27733. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  27734. }
  27735. return oldValue.NewUser, nil
  27736. }
  27737. // AddNewUser adds i to the "new_user" field.
  27738. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  27739. if m.addnew_user != nil {
  27740. *m.addnew_user += i
  27741. } else {
  27742. m.addnew_user = &i
  27743. }
  27744. }
  27745. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  27746. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  27747. v := m.addnew_user
  27748. if v == nil {
  27749. return
  27750. }
  27751. return *v, true
  27752. }
  27753. // ResetNewUser resets all changes to the "new_user" field.
  27754. func (m *UsageStatisticHourMutation) ResetNewUser() {
  27755. m.new_user = nil
  27756. m.addnew_user = nil
  27757. }
  27758. // SetLabelDist sets the "label_dist" field.
  27759. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  27760. m.label_dist = &ctd
  27761. m.appendlabel_dist = nil
  27762. }
  27763. // LabelDist returns the value of the "label_dist" field in the mutation.
  27764. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  27765. v := m.label_dist
  27766. if v == nil {
  27767. return
  27768. }
  27769. return *v, true
  27770. }
  27771. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  27772. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  27773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27774. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  27775. if !m.op.Is(OpUpdateOne) {
  27776. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  27777. }
  27778. if m.id == nil || m.oldValue == nil {
  27779. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  27780. }
  27781. oldValue, err := m.oldValue(ctx)
  27782. if err != nil {
  27783. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  27784. }
  27785. return oldValue.LabelDist, nil
  27786. }
  27787. // AppendLabelDist adds ctd to the "label_dist" field.
  27788. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  27789. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  27790. }
  27791. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  27792. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  27793. if len(m.appendlabel_dist) == 0 {
  27794. return nil, false
  27795. }
  27796. return m.appendlabel_dist, true
  27797. }
  27798. // ResetLabelDist resets all changes to the "label_dist" field.
  27799. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  27800. m.label_dist = nil
  27801. m.appendlabel_dist = nil
  27802. }
  27803. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  27804. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  27805. m.predicates = append(m.predicates, ps...)
  27806. }
  27807. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  27808. // users can use type-assertion to append predicates that do not depend on any generated package.
  27809. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  27810. p := make([]predicate.UsageStatisticHour, len(ps))
  27811. for i := range ps {
  27812. p[i] = ps[i]
  27813. }
  27814. m.Where(p...)
  27815. }
  27816. // Op returns the operation name.
  27817. func (m *UsageStatisticHourMutation) Op() Op {
  27818. return m.op
  27819. }
  27820. // SetOp allows setting the mutation operation.
  27821. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  27822. m.op = op
  27823. }
  27824. // Type returns the node type of this mutation (UsageStatisticHour).
  27825. func (m *UsageStatisticHourMutation) Type() string {
  27826. return m.typ
  27827. }
  27828. // Fields returns all fields that were changed during this mutation. Note that in
  27829. // order to get all numeric fields that were incremented/decremented, call
  27830. // AddedFields().
  27831. func (m *UsageStatisticHourMutation) Fields() []string {
  27832. fields := make([]string, 0, 17)
  27833. if m.created_at != nil {
  27834. fields = append(fields, usagestatistichour.FieldCreatedAt)
  27835. }
  27836. if m.updated_at != nil {
  27837. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  27838. }
  27839. if m.status != nil {
  27840. fields = append(fields, usagestatistichour.FieldStatus)
  27841. }
  27842. if m.deleted_at != nil {
  27843. fields = append(fields, usagestatistichour.FieldDeletedAt)
  27844. }
  27845. if m.addtime != nil {
  27846. fields = append(fields, usagestatistichour.FieldAddtime)
  27847. }
  27848. if m._type != nil {
  27849. fields = append(fields, usagestatistichour.FieldType)
  27850. }
  27851. if m.bot_id != nil {
  27852. fields = append(fields, usagestatistichour.FieldBotID)
  27853. }
  27854. if m.organization_id != nil {
  27855. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27856. }
  27857. if m.ai_response != nil {
  27858. fields = append(fields, usagestatistichour.FieldAiResponse)
  27859. }
  27860. if m.sop_run != nil {
  27861. fields = append(fields, usagestatistichour.FieldSopRun)
  27862. }
  27863. if m.total_friend != nil {
  27864. fields = append(fields, usagestatistichour.FieldTotalFriend)
  27865. }
  27866. if m.total_group != nil {
  27867. fields = append(fields, usagestatistichour.FieldTotalGroup)
  27868. }
  27869. if m.account_balance != nil {
  27870. fields = append(fields, usagestatistichour.FieldAccountBalance)
  27871. }
  27872. if m.consume_token != nil {
  27873. fields = append(fields, usagestatistichour.FieldConsumeToken)
  27874. }
  27875. if m.active_user != nil {
  27876. fields = append(fields, usagestatistichour.FieldActiveUser)
  27877. }
  27878. if m.new_user != nil {
  27879. fields = append(fields, usagestatistichour.FieldNewUser)
  27880. }
  27881. if m.label_dist != nil {
  27882. fields = append(fields, usagestatistichour.FieldLabelDist)
  27883. }
  27884. return fields
  27885. }
  27886. // Field returns the value of a field with the given name. The second boolean
  27887. // return value indicates that this field was not set, or was not defined in the
  27888. // schema.
  27889. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  27890. switch name {
  27891. case usagestatistichour.FieldCreatedAt:
  27892. return m.CreatedAt()
  27893. case usagestatistichour.FieldUpdatedAt:
  27894. return m.UpdatedAt()
  27895. case usagestatistichour.FieldStatus:
  27896. return m.Status()
  27897. case usagestatistichour.FieldDeletedAt:
  27898. return m.DeletedAt()
  27899. case usagestatistichour.FieldAddtime:
  27900. return m.Addtime()
  27901. case usagestatistichour.FieldType:
  27902. return m.GetType()
  27903. case usagestatistichour.FieldBotID:
  27904. return m.BotID()
  27905. case usagestatistichour.FieldOrganizationID:
  27906. return m.OrganizationID()
  27907. case usagestatistichour.FieldAiResponse:
  27908. return m.AiResponse()
  27909. case usagestatistichour.FieldSopRun:
  27910. return m.SopRun()
  27911. case usagestatistichour.FieldTotalFriend:
  27912. return m.TotalFriend()
  27913. case usagestatistichour.FieldTotalGroup:
  27914. return m.TotalGroup()
  27915. case usagestatistichour.FieldAccountBalance:
  27916. return m.AccountBalance()
  27917. case usagestatistichour.FieldConsumeToken:
  27918. return m.ConsumeToken()
  27919. case usagestatistichour.FieldActiveUser:
  27920. return m.ActiveUser()
  27921. case usagestatistichour.FieldNewUser:
  27922. return m.NewUser()
  27923. case usagestatistichour.FieldLabelDist:
  27924. return m.LabelDist()
  27925. }
  27926. return nil, false
  27927. }
  27928. // OldField returns the old value of the field from the database. An error is
  27929. // returned if the mutation operation is not UpdateOne, or the query to the
  27930. // database failed.
  27931. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27932. switch name {
  27933. case usagestatistichour.FieldCreatedAt:
  27934. return m.OldCreatedAt(ctx)
  27935. case usagestatistichour.FieldUpdatedAt:
  27936. return m.OldUpdatedAt(ctx)
  27937. case usagestatistichour.FieldStatus:
  27938. return m.OldStatus(ctx)
  27939. case usagestatistichour.FieldDeletedAt:
  27940. return m.OldDeletedAt(ctx)
  27941. case usagestatistichour.FieldAddtime:
  27942. return m.OldAddtime(ctx)
  27943. case usagestatistichour.FieldType:
  27944. return m.OldType(ctx)
  27945. case usagestatistichour.FieldBotID:
  27946. return m.OldBotID(ctx)
  27947. case usagestatistichour.FieldOrganizationID:
  27948. return m.OldOrganizationID(ctx)
  27949. case usagestatistichour.FieldAiResponse:
  27950. return m.OldAiResponse(ctx)
  27951. case usagestatistichour.FieldSopRun:
  27952. return m.OldSopRun(ctx)
  27953. case usagestatistichour.FieldTotalFriend:
  27954. return m.OldTotalFriend(ctx)
  27955. case usagestatistichour.FieldTotalGroup:
  27956. return m.OldTotalGroup(ctx)
  27957. case usagestatistichour.FieldAccountBalance:
  27958. return m.OldAccountBalance(ctx)
  27959. case usagestatistichour.FieldConsumeToken:
  27960. return m.OldConsumeToken(ctx)
  27961. case usagestatistichour.FieldActiveUser:
  27962. return m.OldActiveUser(ctx)
  27963. case usagestatistichour.FieldNewUser:
  27964. return m.OldNewUser(ctx)
  27965. case usagestatistichour.FieldLabelDist:
  27966. return m.OldLabelDist(ctx)
  27967. }
  27968. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27969. }
  27970. // SetField sets the value of a field with the given name. It returns an error if
  27971. // the field is not defined in the schema, or if the type mismatched the field
  27972. // type.
  27973. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  27974. switch name {
  27975. case usagestatistichour.FieldCreatedAt:
  27976. v, ok := value.(time.Time)
  27977. if !ok {
  27978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27979. }
  27980. m.SetCreatedAt(v)
  27981. return nil
  27982. case usagestatistichour.FieldUpdatedAt:
  27983. v, ok := value.(time.Time)
  27984. if !ok {
  27985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27986. }
  27987. m.SetUpdatedAt(v)
  27988. return nil
  27989. case usagestatistichour.FieldStatus:
  27990. v, ok := value.(uint8)
  27991. if !ok {
  27992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27993. }
  27994. m.SetStatus(v)
  27995. return nil
  27996. case usagestatistichour.FieldDeletedAt:
  27997. v, ok := value.(time.Time)
  27998. if !ok {
  27999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28000. }
  28001. m.SetDeletedAt(v)
  28002. return nil
  28003. case usagestatistichour.FieldAddtime:
  28004. v, ok := value.(uint64)
  28005. if !ok {
  28006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28007. }
  28008. m.SetAddtime(v)
  28009. return nil
  28010. case usagestatistichour.FieldType:
  28011. v, ok := value.(int)
  28012. if !ok {
  28013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28014. }
  28015. m.SetType(v)
  28016. return nil
  28017. case usagestatistichour.FieldBotID:
  28018. v, ok := value.(string)
  28019. if !ok {
  28020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28021. }
  28022. m.SetBotID(v)
  28023. return nil
  28024. case usagestatistichour.FieldOrganizationID:
  28025. v, ok := value.(uint64)
  28026. if !ok {
  28027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28028. }
  28029. m.SetOrganizationID(v)
  28030. return nil
  28031. case usagestatistichour.FieldAiResponse:
  28032. v, ok := value.(uint64)
  28033. if !ok {
  28034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28035. }
  28036. m.SetAiResponse(v)
  28037. return nil
  28038. case usagestatistichour.FieldSopRun:
  28039. v, ok := value.(uint64)
  28040. if !ok {
  28041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28042. }
  28043. m.SetSopRun(v)
  28044. return nil
  28045. case usagestatistichour.FieldTotalFriend:
  28046. v, ok := value.(uint64)
  28047. if !ok {
  28048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28049. }
  28050. m.SetTotalFriend(v)
  28051. return nil
  28052. case usagestatistichour.FieldTotalGroup:
  28053. v, ok := value.(uint64)
  28054. if !ok {
  28055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28056. }
  28057. m.SetTotalGroup(v)
  28058. return nil
  28059. case usagestatistichour.FieldAccountBalance:
  28060. v, ok := value.(uint64)
  28061. if !ok {
  28062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28063. }
  28064. m.SetAccountBalance(v)
  28065. return nil
  28066. case usagestatistichour.FieldConsumeToken:
  28067. v, ok := value.(uint64)
  28068. if !ok {
  28069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28070. }
  28071. m.SetConsumeToken(v)
  28072. return nil
  28073. case usagestatistichour.FieldActiveUser:
  28074. v, ok := value.(uint64)
  28075. if !ok {
  28076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28077. }
  28078. m.SetActiveUser(v)
  28079. return nil
  28080. case usagestatistichour.FieldNewUser:
  28081. v, ok := value.(int64)
  28082. if !ok {
  28083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28084. }
  28085. m.SetNewUser(v)
  28086. return nil
  28087. case usagestatistichour.FieldLabelDist:
  28088. v, ok := value.([]custom_types.LabelDist)
  28089. if !ok {
  28090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28091. }
  28092. m.SetLabelDist(v)
  28093. return nil
  28094. }
  28095. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  28096. }
  28097. // AddedFields returns all numeric fields that were incremented/decremented during
  28098. // this mutation.
  28099. func (m *UsageStatisticHourMutation) AddedFields() []string {
  28100. var fields []string
  28101. if m.addstatus != nil {
  28102. fields = append(fields, usagestatistichour.FieldStatus)
  28103. }
  28104. if m.addaddtime != nil {
  28105. fields = append(fields, usagestatistichour.FieldAddtime)
  28106. }
  28107. if m.add_type != nil {
  28108. fields = append(fields, usagestatistichour.FieldType)
  28109. }
  28110. if m.addorganization_id != nil {
  28111. fields = append(fields, usagestatistichour.FieldOrganizationID)
  28112. }
  28113. if m.addai_response != nil {
  28114. fields = append(fields, usagestatistichour.FieldAiResponse)
  28115. }
  28116. if m.addsop_run != nil {
  28117. fields = append(fields, usagestatistichour.FieldSopRun)
  28118. }
  28119. if m.addtotal_friend != nil {
  28120. fields = append(fields, usagestatistichour.FieldTotalFriend)
  28121. }
  28122. if m.addtotal_group != nil {
  28123. fields = append(fields, usagestatistichour.FieldTotalGroup)
  28124. }
  28125. if m.addaccount_balance != nil {
  28126. fields = append(fields, usagestatistichour.FieldAccountBalance)
  28127. }
  28128. if m.addconsume_token != nil {
  28129. fields = append(fields, usagestatistichour.FieldConsumeToken)
  28130. }
  28131. if m.addactive_user != nil {
  28132. fields = append(fields, usagestatistichour.FieldActiveUser)
  28133. }
  28134. if m.addnew_user != nil {
  28135. fields = append(fields, usagestatistichour.FieldNewUser)
  28136. }
  28137. return fields
  28138. }
  28139. // AddedField returns the numeric value that was incremented/decremented on a field
  28140. // with the given name. The second boolean return value indicates that this field
  28141. // was not set, or was not defined in the schema.
  28142. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  28143. switch name {
  28144. case usagestatistichour.FieldStatus:
  28145. return m.AddedStatus()
  28146. case usagestatistichour.FieldAddtime:
  28147. return m.AddedAddtime()
  28148. case usagestatistichour.FieldType:
  28149. return m.AddedType()
  28150. case usagestatistichour.FieldOrganizationID:
  28151. return m.AddedOrganizationID()
  28152. case usagestatistichour.FieldAiResponse:
  28153. return m.AddedAiResponse()
  28154. case usagestatistichour.FieldSopRun:
  28155. return m.AddedSopRun()
  28156. case usagestatistichour.FieldTotalFriend:
  28157. return m.AddedTotalFriend()
  28158. case usagestatistichour.FieldTotalGroup:
  28159. return m.AddedTotalGroup()
  28160. case usagestatistichour.FieldAccountBalance:
  28161. return m.AddedAccountBalance()
  28162. case usagestatistichour.FieldConsumeToken:
  28163. return m.AddedConsumeToken()
  28164. case usagestatistichour.FieldActiveUser:
  28165. return m.AddedActiveUser()
  28166. case usagestatistichour.FieldNewUser:
  28167. return m.AddedNewUser()
  28168. }
  28169. return nil, false
  28170. }
  28171. // AddField adds the value to the field with the given name. It returns an error if
  28172. // the field is not defined in the schema, or if the type mismatched the field
  28173. // type.
  28174. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  28175. switch name {
  28176. case usagestatistichour.FieldStatus:
  28177. v, ok := value.(int8)
  28178. if !ok {
  28179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28180. }
  28181. m.AddStatus(v)
  28182. return nil
  28183. case usagestatistichour.FieldAddtime:
  28184. v, ok := value.(int64)
  28185. if !ok {
  28186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28187. }
  28188. m.AddAddtime(v)
  28189. return nil
  28190. case usagestatistichour.FieldType:
  28191. v, ok := value.(int)
  28192. if !ok {
  28193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28194. }
  28195. m.AddType(v)
  28196. return nil
  28197. case usagestatistichour.FieldOrganizationID:
  28198. v, ok := value.(int64)
  28199. if !ok {
  28200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28201. }
  28202. m.AddOrganizationID(v)
  28203. return nil
  28204. case usagestatistichour.FieldAiResponse:
  28205. v, ok := value.(int64)
  28206. if !ok {
  28207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28208. }
  28209. m.AddAiResponse(v)
  28210. return nil
  28211. case usagestatistichour.FieldSopRun:
  28212. v, ok := value.(int64)
  28213. if !ok {
  28214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28215. }
  28216. m.AddSopRun(v)
  28217. return nil
  28218. case usagestatistichour.FieldTotalFriend:
  28219. v, ok := value.(int64)
  28220. if !ok {
  28221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28222. }
  28223. m.AddTotalFriend(v)
  28224. return nil
  28225. case usagestatistichour.FieldTotalGroup:
  28226. v, ok := value.(int64)
  28227. if !ok {
  28228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28229. }
  28230. m.AddTotalGroup(v)
  28231. return nil
  28232. case usagestatistichour.FieldAccountBalance:
  28233. v, ok := value.(int64)
  28234. if !ok {
  28235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28236. }
  28237. m.AddAccountBalance(v)
  28238. return nil
  28239. case usagestatistichour.FieldConsumeToken:
  28240. v, ok := value.(int64)
  28241. if !ok {
  28242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28243. }
  28244. m.AddConsumeToken(v)
  28245. return nil
  28246. case usagestatistichour.FieldActiveUser:
  28247. v, ok := value.(int64)
  28248. if !ok {
  28249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28250. }
  28251. m.AddActiveUser(v)
  28252. return nil
  28253. case usagestatistichour.FieldNewUser:
  28254. v, ok := value.(int64)
  28255. if !ok {
  28256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28257. }
  28258. m.AddNewUser(v)
  28259. return nil
  28260. }
  28261. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  28262. }
  28263. // ClearedFields returns all nullable fields that were cleared during this
  28264. // mutation.
  28265. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  28266. var fields []string
  28267. if m.FieldCleared(usagestatistichour.FieldStatus) {
  28268. fields = append(fields, usagestatistichour.FieldStatus)
  28269. }
  28270. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  28271. fields = append(fields, usagestatistichour.FieldDeletedAt)
  28272. }
  28273. if m.FieldCleared(usagestatistichour.FieldBotID) {
  28274. fields = append(fields, usagestatistichour.FieldBotID)
  28275. }
  28276. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  28277. fields = append(fields, usagestatistichour.FieldOrganizationID)
  28278. }
  28279. return fields
  28280. }
  28281. // FieldCleared returns a boolean indicating if a field with the given name was
  28282. // cleared in this mutation.
  28283. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  28284. _, ok := m.clearedFields[name]
  28285. return ok
  28286. }
  28287. // ClearField clears the value of the field with the given name. It returns an
  28288. // error if the field is not defined in the schema.
  28289. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  28290. switch name {
  28291. case usagestatistichour.FieldStatus:
  28292. m.ClearStatus()
  28293. return nil
  28294. case usagestatistichour.FieldDeletedAt:
  28295. m.ClearDeletedAt()
  28296. return nil
  28297. case usagestatistichour.FieldBotID:
  28298. m.ClearBotID()
  28299. return nil
  28300. case usagestatistichour.FieldOrganizationID:
  28301. m.ClearOrganizationID()
  28302. return nil
  28303. }
  28304. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  28305. }
  28306. // ResetField resets all changes in the mutation for the field with the given name.
  28307. // It returns an error if the field is not defined in the schema.
  28308. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  28309. switch name {
  28310. case usagestatistichour.FieldCreatedAt:
  28311. m.ResetCreatedAt()
  28312. return nil
  28313. case usagestatistichour.FieldUpdatedAt:
  28314. m.ResetUpdatedAt()
  28315. return nil
  28316. case usagestatistichour.FieldStatus:
  28317. m.ResetStatus()
  28318. return nil
  28319. case usagestatistichour.FieldDeletedAt:
  28320. m.ResetDeletedAt()
  28321. return nil
  28322. case usagestatistichour.FieldAddtime:
  28323. m.ResetAddtime()
  28324. return nil
  28325. case usagestatistichour.FieldType:
  28326. m.ResetType()
  28327. return nil
  28328. case usagestatistichour.FieldBotID:
  28329. m.ResetBotID()
  28330. return nil
  28331. case usagestatistichour.FieldOrganizationID:
  28332. m.ResetOrganizationID()
  28333. return nil
  28334. case usagestatistichour.FieldAiResponse:
  28335. m.ResetAiResponse()
  28336. return nil
  28337. case usagestatistichour.FieldSopRun:
  28338. m.ResetSopRun()
  28339. return nil
  28340. case usagestatistichour.FieldTotalFriend:
  28341. m.ResetTotalFriend()
  28342. return nil
  28343. case usagestatistichour.FieldTotalGroup:
  28344. m.ResetTotalGroup()
  28345. return nil
  28346. case usagestatistichour.FieldAccountBalance:
  28347. m.ResetAccountBalance()
  28348. return nil
  28349. case usagestatistichour.FieldConsumeToken:
  28350. m.ResetConsumeToken()
  28351. return nil
  28352. case usagestatistichour.FieldActiveUser:
  28353. m.ResetActiveUser()
  28354. return nil
  28355. case usagestatistichour.FieldNewUser:
  28356. m.ResetNewUser()
  28357. return nil
  28358. case usagestatistichour.FieldLabelDist:
  28359. m.ResetLabelDist()
  28360. return nil
  28361. }
  28362. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  28363. }
  28364. // AddedEdges returns all edge names that were set/added in this mutation.
  28365. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  28366. edges := make([]string, 0, 0)
  28367. return edges
  28368. }
  28369. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28370. // name in this mutation.
  28371. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  28372. return nil
  28373. }
  28374. // RemovedEdges returns all edge names that were removed in this mutation.
  28375. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  28376. edges := make([]string, 0, 0)
  28377. return edges
  28378. }
  28379. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28380. // the given name in this mutation.
  28381. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  28382. return nil
  28383. }
  28384. // ClearedEdges returns all edge names that were cleared in this mutation.
  28385. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  28386. edges := make([]string, 0, 0)
  28387. return edges
  28388. }
  28389. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28390. // was cleared in this mutation.
  28391. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  28392. return false
  28393. }
  28394. // ClearEdge clears the value of the edge with the given name. It returns an error
  28395. // if that edge is not defined in the schema.
  28396. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  28397. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  28398. }
  28399. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28400. // It returns an error if the edge is not defined in the schema.
  28401. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  28402. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  28403. }
  28404. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  28405. type UsageStatisticMonthMutation struct {
  28406. config
  28407. op Op
  28408. typ string
  28409. id *uint64
  28410. created_at *time.Time
  28411. updated_at *time.Time
  28412. status *uint8
  28413. addstatus *int8
  28414. deleted_at *time.Time
  28415. addtime *uint64
  28416. addaddtime *int64
  28417. _type *int
  28418. add_type *int
  28419. bot_id *string
  28420. organization_id *uint64
  28421. addorganization_id *int64
  28422. ai_response *uint64
  28423. addai_response *int64
  28424. sop_run *uint64
  28425. addsop_run *int64
  28426. total_friend *uint64
  28427. addtotal_friend *int64
  28428. total_group *uint64
  28429. addtotal_group *int64
  28430. account_balance *uint64
  28431. addaccount_balance *int64
  28432. consume_token *uint64
  28433. addconsume_token *int64
  28434. active_user *uint64
  28435. addactive_user *int64
  28436. new_user *int64
  28437. addnew_user *int64
  28438. label_dist *[]custom_types.LabelDist
  28439. appendlabel_dist []custom_types.LabelDist
  28440. clearedFields map[string]struct{}
  28441. done bool
  28442. oldValue func(context.Context) (*UsageStatisticMonth, error)
  28443. predicates []predicate.UsageStatisticMonth
  28444. }
  28445. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  28446. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  28447. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  28448. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  28449. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  28450. m := &UsageStatisticMonthMutation{
  28451. config: c,
  28452. op: op,
  28453. typ: TypeUsageStatisticMonth,
  28454. clearedFields: make(map[string]struct{}),
  28455. }
  28456. for _, opt := range opts {
  28457. opt(m)
  28458. }
  28459. return m
  28460. }
  28461. // withUsageStatisticMonthID sets the ID field of the mutation.
  28462. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  28463. return func(m *UsageStatisticMonthMutation) {
  28464. var (
  28465. err error
  28466. once sync.Once
  28467. value *UsageStatisticMonth
  28468. )
  28469. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  28470. once.Do(func() {
  28471. if m.done {
  28472. err = errors.New("querying old values post mutation is not allowed")
  28473. } else {
  28474. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  28475. }
  28476. })
  28477. return value, err
  28478. }
  28479. m.id = &id
  28480. }
  28481. }
  28482. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  28483. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  28484. return func(m *UsageStatisticMonthMutation) {
  28485. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  28486. return node, nil
  28487. }
  28488. m.id = &node.ID
  28489. }
  28490. }
  28491. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28492. // executed in a transaction (ent.Tx), a transactional client is returned.
  28493. func (m UsageStatisticMonthMutation) Client() *Client {
  28494. client := &Client{config: m.config}
  28495. client.init()
  28496. return client
  28497. }
  28498. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28499. // it returns an error otherwise.
  28500. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  28501. if _, ok := m.driver.(*txDriver); !ok {
  28502. return nil, errors.New("ent: mutation is not running in a transaction")
  28503. }
  28504. tx := &Tx{config: m.config}
  28505. tx.init()
  28506. return tx, nil
  28507. }
  28508. // SetID sets the value of the id field. Note that this
  28509. // operation is only accepted on creation of UsageStatisticMonth entities.
  28510. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  28511. m.id = &id
  28512. }
  28513. // ID returns the ID value in the mutation. Note that the ID is only available
  28514. // if it was provided to the builder or after it was returned from the database.
  28515. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  28516. if m.id == nil {
  28517. return
  28518. }
  28519. return *m.id, true
  28520. }
  28521. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28522. // That means, if the mutation is applied within a transaction with an isolation level such
  28523. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28524. // or updated by the mutation.
  28525. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  28526. switch {
  28527. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28528. id, exists := m.ID()
  28529. if exists {
  28530. return []uint64{id}, nil
  28531. }
  28532. fallthrough
  28533. case m.op.Is(OpUpdate | OpDelete):
  28534. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  28535. default:
  28536. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28537. }
  28538. }
  28539. // SetCreatedAt sets the "created_at" field.
  28540. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  28541. m.created_at = &t
  28542. }
  28543. // CreatedAt returns the value of the "created_at" field in the mutation.
  28544. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  28545. v := m.created_at
  28546. if v == nil {
  28547. return
  28548. }
  28549. return *v, true
  28550. }
  28551. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  28552. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28554. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28555. if !m.op.Is(OpUpdateOne) {
  28556. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28557. }
  28558. if m.id == nil || m.oldValue == nil {
  28559. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28560. }
  28561. oldValue, err := m.oldValue(ctx)
  28562. if err != nil {
  28563. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28564. }
  28565. return oldValue.CreatedAt, nil
  28566. }
  28567. // ResetCreatedAt resets all changes to the "created_at" field.
  28568. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  28569. m.created_at = nil
  28570. }
  28571. // SetUpdatedAt sets the "updated_at" field.
  28572. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  28573. m.updated_at = &t
  28574. }
  28575. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28576. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  28577. v := m.updated_at
  28578. if v == nil {
  28579. return
  28580. }
  28581. return *v, true
  28582. }
  28583. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  28584. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28586. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28587. if !m.op.Is(OpUpdateOne) {
  28588. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28589. }
  28590. if m.id == nil || m.oldValue == nil {
  28591. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28592. }
  28593. oldValue, err := m.oldValue(ctx)
  28594. if err != nil {
  28595. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28596. }
  28597. return oldValue.UpdatedAt, nil
  28598. }
  28599. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28600. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  28601. m.updated_at = nil
  28602. }
  28603. // SetStatus sets the "status" field.
  28604. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  28605. m.status = &u
  28606. m.addstatus = nil
  28607. }
  28608. // Status returns the value of the "status" field in the mutation.
  28609. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  28610. v := m.status
  28611. if v == nil {
  28612. return
  28613. }
  28614. return *v, true
  28615. }
  28616. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  28617. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28619. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28620. if !m.op.Is(OpUpdateOne) {
  28621. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28622. }
  28623. if m.id == nil || m.oldValue == nil {
  28624. return v, errors.New("OldStatus requires an ID field in the mutation")
  28625. }
  28626. oldValue, err := m.oldValue(ctx)
  28627. if err != nil {
  28628. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28629. }
  28630. return oldValue.Status, nil
  28631. }
  28632. // AddStatus adds u to the "status" field.
  28633. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  28634. if m.addstatus != nil {
  28635. *m.addstatus += u
  28636. } else {
  28637. m.addstatus = &u
  28638. }
  28639. }
  28640. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28641. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  28642. v := m.addstatus
  28643. if v == nil {
  28644. return
  28645. }
  28646. return *v, true
  28647. }
  28648. // ClearStatus clears the value of the "status" field.
  28649. func (m *UsageStatisticMonthMutation) ClearStatus() {
  28650. m.status = nil
  28651. m.addstatus = nil
  28652. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  28653. }
  28654. // StatusCleared returns if the "status" field was cleared in this mutation.
  28655. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  28656. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  28657. return ok
  28658. }
  28659. // ResetStatus resets all changes to the "status" field.
  28660. func (m *UsageStatisticMonthMutation) ResetStatus() {
  28661. m.status = nil
  28662. m.addstatus = nil
  28663. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  28664. }
  28665. // SetDeletedAt sets the "deleted_at" field.
  28666. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  28667. m.deleted_at = &t
  28668. }
  28669. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28670. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  28671. v := m.deleted_at
  28672. if v == nil {
  28673. return
  28674. }
  28675. return *v, true
  28676. }
  28677. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  28678. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28680. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28681. if !m.op.Is(OpUpdateOne) {
  28682. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28683. }
  28684. if m.id == nil || m.oldValue == nil {
  28685. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28686. }
  28687. oldValue, err := m.oldValue(ctx)
  28688. if err != nil {
  28689. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28690. }
  28691. return oldValue.DeletedAt, nil
  28692. }
  28693. // ClearDeletedAt clears the value of the "deleted_at" field.
  28694. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  28695. m.deleted_at = nil
  28696. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  28697. }
  28698. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28699. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  28700. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  28701. return ok
  28702. }
  28703. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28704. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  28705. m.deleted_at = nil
  28706. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  28707. }
  28708. // SetAddtime sets the "addtime" field.
  28709. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  28710. m.addtime = &u
  28711. m.addaddtime = nil
  28712. }
  28713. // Addtime returns the value of the "addtime" field in the mutation.
  28714. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  28715. v := m.addtime
  28716. if v == nil {
  28717. return
  28718. }
  28719. return *v, true
  28720. }
  28721. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  28722. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28724. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28725. if !m.op.Is(OpUpdateOne) {
  28726. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28727. }
  28728. if m.id == nil || m.oldValue == nil {
  28729. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28730. }
  28731. oldValue, err := m.oldValue(ctx)
  28732. if err != nil {
  28733. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28734. }
  28735. return oldValue.Addtime, nil
  28736. }
  28737. // AddAddtime adds u to the "addtime" field.
  28738. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  28739. if m.addaddtime != nil {
  28740. *m.addaddtime += u
  28741. } else {
  28742. m.addaddtime = &u
  28743. }
  28744. }
  28745. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28746. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  28747. v := m.addaddtime
  28748. if v == nil {
  28749. return
  28750. }
  28751. return *v, true
  28752. }
  28753. // ResetAddtime resets all changes to the "addtime" field.
  28754. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  28755. m.addtime = nil
  28756. m.addaddtime = nil
  28757. }
  28758. // SetType sets the "type" field.
  28759. func (m *UsageStatisticMonthMutation) SetType(i int) {
  28760. m._type = &i
  28761. m.add_type = nil
  28762. }
  28763. // GetType returns the value of the "type" field in the mutation.
  28764. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  28765. v := m._type
  28766. if v == nil {
  28767. return
  28768. }
  28769. return *v, true
  28770. }
  28771. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  28772. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28774. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  28775. if !m.op.Is(OpUpdateOne) {
  28776. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28777. }
  28778. if m.id == nil || m.oldValue == nil {
  28779. return v, errors.New("OldType requires an ID field in the mutation")
  28780. }
  28781. oldValue, err := m.oldValue(ctx)
  28782. if err != nil {
  28783. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28784. }
  28785. return oldValue.Type, nil
  28786. }
  28787. // AddType adds i to the "type" field.
  28788. func (m *UsageStatisticMonthMutation) AddType(i int) {
  28789. if m.add_type != nil {
  28790. *m.add_type += i
  28791. } else {
  28792. m.add_type = &i
  28793. }
  28794. }
  28795. // AddedType returns the value that was added to the "type" field in this mutation.
  28796. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  28797. v := m.add_type
  28798. if v == nil {
  28799. return
  28800. }
  28801. return *v, true
  28802. }
  28803. // ResetType resets all changes to the "type" field.
  28804. func (m *UsageStatisticMonthMutation) ResetType() {
  28805. m._type = nil
  28806. m.add_type = nil
  28807. }
  28808. // SetBotID sets the "bot_id" field.
  28809. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  28810. m.bot_id = &s
  28811. }
  28812. // BotID returns the value of the "bot_id" field in the mutation.
  28813. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  28814. v := m.bot_id
  28815. if v == nil {
  28816. return
  28817. }
  28818. return *v, true
  28819. }
  28820. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  28821. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28823. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  28824. if !m.op.Is(OpUpdateOne) {
  28825. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28826. }
  28827. if m.id == nil || m.oldValue == nil {
  28828. return v, errors.New("OldBotID requires an ID field in the mutation")
  28829. }
  28830. oldValue, err := m.oldValue(ctx)
  28831. if err != nil {
  28832. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28833. }
  28834. return oldValue.BotID, nil
  28835. }
  28836. // ClearBotID clears the value of the "bot_id" field.
  28837. func (m *UsageStatisticMonthMutation) ClearBotID() {
  28838. m.bot_id = nil
  28839. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  28840. }
  28841. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28842. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  28843. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  28844. return ok
  28845. }
  28846. // ResetBotID resets all changes to the "bot_id" field.
  28847. func (m *UsageStatisticMonthMutation) ResetBotID() {
  28848. m.bot_id = nil
  28849. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  28850. }
  28851. // SetOrganizationID sets the "organization_id" field.
  28852. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  28853. m.organization_id = &u
  28854. m.addorganization_id = nil
  28855. }
  28856. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28857. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  28858. v := m.organization_id
  28859. if v == nil {
  28860. return
  28861. }
  28862. return *v, true
  28863. }
  28864. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  28865. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28867. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28868. if !m.op.Is(OpUpdateOne) {
  28869. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28870. }
  28871. if m.id == nil || m.oldValue == nil {
  28872. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28873. }
  28874. oldValue, err := m.oldValue(ctx)
  28875. if err != nil {
  28876. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28877. }
  28878. return oldValue.OrganizationID, nil
  28879. }
  28880. // AddOrganizationID adds u to the "organization_id" field.
  28881. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  28882. if m.addorganization_id != nil {
  28883. *m.addorganization_id += u
  28884. } else {
  28885. m.addorganization_id = &u
  28886. }
  28887. }
  28888. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28889. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  28890. v := m.addorganization_id
  28891. if v == nil {
  28892. return
  28893. }
  28894. return *v, true
  28895. }
  28896. // ClearOrganizationID clears the value of the "organization_id" field.
  28897. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  28898. m.organization_id = nil
  28899. m.addorganization_id = nil
  28900. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  28901. }
  28902. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28903. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  28904. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  28905. return ok
  28906. }
  28907. // ResetOrganizationID resets all changes to the "organization_id" field.
  28908. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  28909. m.organization_id = nil
  28910. m.addorganization_id = nil
  28911. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  28912. }
  28913. // SetAiResponse sets the "ai_response" field.
  28914. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  28915. m.ai_response = &u
  28916. m.addai_response = nil
  28917. }
  28918. // AiResponse returns the value of the "ai_response" field in the mutation.
  28919. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  28920. v := m.ai_response
  28921. if v == nil {
  28922. return
  28923. }
  28924. return *v, true
  28925. }
  28926. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  28927. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28929. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28930. if !m.op.Is(OpUpdateOne) {
  28931. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28932. }
  28933. if m.id == nil || m.oldValue == nil {
  28934. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28935. }
  28936. oldValue, err := m.oldValue(ctx)
  28937. if err != nil {
  28938. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28939. }
  28940. return oldValue.AiResponse, nil
  28941. }
  28942. // AddAiResponse adds u to the "ai_response" field.
  28943. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  28944. if m.addai_response != nil {
  28945. *m.addai_response += u
  28946. } else {
  28947. m.addai_response = &u
  28948. }
  28949. }
  28950. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28951. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  28952. v := m.addai_response
  28953. if v == nil {
  28954. return
  28955. }
  28956. return *v, true
  28957. }
  28958. // ResetAiResponse resets all changes to the "ai_response" field.
  28959. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  28960. m.ai_response = nil
  28961. m.addai_response = nil
  28962. }
  28963. // SetSopRun sets the "sop_run" field.
  28964. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  28965. m.sop_run = &u
  28966. m.addsop_run = nil
  28967. }
  28968. // SopRun returns the value of the "sop_run" field in the mutation.
  28969. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  28970. v := m.sop_run
  28971. if v == nil {
  28972. return
  28973. }
  28974. return *v, true
  28975. }
  28976. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  28977. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28979. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28980. if !m.op.Is(OpUpdateOne) {
  28981. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28982. }
  28983. if m.id == nil || m.oldValue == nil {
  28984. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28985. }
  28986. oldValue, err := m.oldValue(ctx)
  28987. if err != nil {
  28988. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28989. }
  28990. return oldValue.SopRun, nil
  28991. }
  28992. // AddSopRun adds u to the "sop_run" field.
  28993. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  28994. if m.addsop_run != nil {
  28995. *m.addsop_run += u
  28996. } else {
  28997. m.addsop_run = &u
  28998. }
  28999. }
  29000. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29001. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  29002. v := m.addsop_run
  29003. if v == nil {
  29004. return
  29005. }
  29006. return *v, true
  29007. }
  29008. // ResetSopRun resets all changes to the "sop_run" field.
  29009. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  29010. m.sop_run = nil
  29011. m.addsop_run = nil
  29012. }
  29013. // SetTotalFriend sets the "total_friend" field.
  29014. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  29015. m.total_friend = &u
  29016. m.addtotal_friend = nil
  29017. }
  29018. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29019. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  29020. v := m.total_friend
  29021. if v == nil {
  29022. return
  29023. }
  29024. return *v, true
  29025. }
  29026. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  29027. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29029. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29030. if !m.op.Is(OpUpdateOne) {
  29031. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29032. }
  29033. if m.id == nil || m.oldValue == nil {
  29034. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29035. }
  29036. oldValue, err := m.oldValue(ctx)
  29037. if err != nil {
  29038. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29039. }
  29040. return oldValue.TotalFriend, nil
  29041. }
  29042. // AddTotalFriend adds u to the "total_friend" field.
  29043. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  29044. if m.addtotal_friend != nil {
  29045. *m.addtotal_friend += u
  29046. } else {
  29047. m.addtotal_friend = &u
  29048. }
  29049. }
  29050. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29051. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  29052. v := m.addtotal_friend
  29053. if v == nil {
  29054. return
  29055. }
  29056. return *v, true
  29057. }
  29058. // ResetTotalFriend resets all changes to the "total_friend" field.
  29059. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  29060. m.total_friend = nil
  29061. m.addtotal_friend = nil
  29062. }
  29063. // SetTotalGroup sets the "total_group" field.
  29064. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  29065. m.total_group = &u
  29066. m.addtotal_group = nil
  29067. }
  29068. // TotalGroup returns the value of the "total_group" field in the mutation.
  29069. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  29070. v := m.total_group
  29071. if v == nil {
  29072. return
  29073. }
  29074. return *v, true
  29075. }
  29076. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  29077. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29079. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29080. if !m.op.Is(OpUpdateOne) {
  29081. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29082. }
  29083. if m.id == nil || m.oldValue == nil {
  29084. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29085. }
  29086. oldValue, err := m.oldValue(ctx)
  29087. if err != nil {
  29088. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29089. }
  29090. return oldValue.TotalGroup, nil
  29091. }
  29092. // AddTotalGroup adds u to the "total_group" field.
  29093. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  29094. if m.addtotal_group != nil {
  29095. *m.addtotal_group += u
  29096. } else {
  29097. m.addtotal_group = &u
  29098. }
  29099. }
  29100. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29101. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  29102. v := m.addtotal_group
  29103. if v == nil {
  29104. return
  29105. }
  29106. return *v, true
  29107. }
  29108. // ResetTotalGroup resets all changes to the "total_group" field.
  29109. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  29110. m.total_group = nil
  29111. m.addtotal_group = nil
  29112. }
  29113. // SetAccountBalance sets the "account_balance" field.
  29114. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  29115. m.account_balance = &u
  29116. m.addaccount_balance = nil
  29117. }
  29118. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29119. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  29120. v := m.account_balance
  29121. if v == nil {
  29122. return
  29123. }
  29124. return *v, true
  29125. }
  29126. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  29127. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29129. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29130. if !m.op.Is(OpUpdateOne) {
  29131. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29132. }
  29133. if m.id == nil || m.oldValue == nil {
  29134. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29135. }
  29136. oldValue, err := m.oldValue(ctx)
  29137. if err != nil {
  29138. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29139. }
  29140. return oldValue.AccountBalance, nil
  29141. }
  29142. // AddAccountBalance adds u to the "account_balance" field.
  29143. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  29144. if m.addaccount_balance != nil {
  29145. *m.addaccount_balance += u
  29146. } else {
  29147. m.addaccount_balance = &u
  29148. }
  29149. }
  29150. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29151. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  29152. v := m.addaccount_balance
  29153. if v == nil {
  29154. return
  29155. }
  29156. return *v, true
  29157. }
  29158. // ResetAccountBalance resets all changes to the "account_balance" field.
  29159. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  29160. m.account_balance = nil
  29161. m.addaccount_balance = nil
  29162. }
  29163. // SetConsumeToken sets the "consume_token" field.
  29164. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  29165. m.consume_token = &u
  29166. m.addconsume_token = nil
  29167. }
  29168. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  29169. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  29170. v := m.consume_token
  29171. if v == nil {
  29172. return
  29173. }
  29174. return *v, true
  29175. }
  29176. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  29177. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29179. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  29180. if !m.op.Is(OpUpdateOne) {
  29181. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  29182. }
  29183. if m.id == nil || m.oldValue == nil {
  29184. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  29185. }
  29186. oldValue, err := m.oldValue(ctx)
  29187. if err != nil {
  29188. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  29189. }
  29190. return oldValue.ConsumeToken, nil
  29191. }
  29192. // AddConsumeToken adds u to the "consume_token" field.
  29193. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  29194. if m.addconsume_token != nil {
  29195. *m.addconsume_token += u
  29196. } else {
  29197. m.addconsume_token = &u
  29198. }
  29199. }
  29200. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  29201. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  29202. v := m.addconsume_token
  29203. if v == nil {
  29204. return
  29205. }
  29206. return *v, true
  29207. }
  29208. // ResetConsumeToken resets all changes to the "consume_token" field.
  29209. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  29210. m.consume_token = nil
  29211. m.addconsume_token = nil
  29212. }
  29213. // SetActiveUser sets the "active_user" field.
  29214. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  29215. m.active_user = &u
  29216. m.addactive_user = nil
  29217. }
  29218. // ActiveUser returns the value of the "active_user" field in the mutation.
  29219. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  29220. v := m.active_user
  29221. if v == nil {
  29222. return
  29223. }
  29224. return *v, true
  29225. }
  29226. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  29227. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29229. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  29230. if !m.op.Is(OpUpdateOne) {
  29231. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  29232. }
  29233. if m.id == nil || m.oldValue == nil {
  29234. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  29235. }
  29236. oldValue, err := m.oldValue(ctx)
  29237. if err != nil {
  29238. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  29239. }
  29240. return oldValue.ActiveUser, nil
  29241. }
  29242. // AddActiveUser adds u to the "active_user" field.
  29243. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  29244. if m.addactive_user != nil {
  29245. *m.addactive_user += u
  29246. } else {
  29247. m.addactive_user = &u
  29248. }
  29249. }
  29250. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  29251. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  29252. v := m.addactive_user
  29253. if v == nil {
  29254. return
  29255. }
  29256. return *v, true
  29257. }
  29258. // ResetActiveUser resets all changes to the "active_user" field.
  29259. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  29260. m.active_user = nil
  29261. m.addactive_user = nil
  29262. }
  29263. // SetNewUser sets the "new_user" field.
  29264. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  29265. m.new_user = &i
  29266. m.addnew_user = nil
  29267. }
  29268. // NewUser returns the value of the "new_user" field in the mutation.
  29269. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  29270. v := m.new_user
  29271. if v == nil {
  29272. return
  29273. }
  29274. return *v, true
  29275. }
  29276. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  29277. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29279. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  29280. if !m.op.Is(OpUpdateOne) {
  29281. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  29282. }
  29283. if m.id == nil || m.oldValue == nil {
  29284. return v, errors.New("OldNewUser requires an ID field in the mutation")
  29285. }
  29286. oldValue, err := m.oldValue(ctx)
  29287. if err != nil {
  29288. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  29289. }
  29290. return oldValue.NewUser, nil
  29291. }
  29292. // AddNewUser adds i to the "new_user" field.
  29293. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  29294. if m.addnew_user != nil {
  29295. *m.addnew_user += i
  29296. } else {
  29297. m.addnew_user = &i
  29298. }
  29299. }
  29300. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  29301. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  29302. v := m.addnew_user
  29303. if v == nil {
  29304. return
  29305. }
  29306. return *v, true
  29307. }
  29308. // ResetNewUser resets all changes to the "new_user" field.
  29309. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  29310. m.new_user = nil
  29311. m.addnew_user = nil
  29312. }
  29313. // SetLabelDist sets the "label_dist" field.
  29314. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  29315. m.label_dist = &ctd
  29316. m.appendlabel_dist = nil
  29317. }
  29318. // LabelDist returns the value of the "label_dist" field in the mutation.
  29319. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  29320. v := m.label_dist
  29321. if v == nil {
  29322. return
  29323. }
  29324. return *v, true
  29325. }
  29326. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  29327. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  29328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29329. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  29330. if !m.op.Is(OpUpdateOne) {
  29331. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29332. }
  29333. if m.id == nil || m.oldValue == nil {
  29334. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  29335. }
  29336. oldValue, err := m.oldValue(ctx)
  29337. if err != nil {
  29338. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  29339. }
  29340. return oldValue.LabelDist, nil
  29341. }
  29342. // AppendLabelDist adds ctd to the "label_dist" field.
  29343. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29344. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29345. }
  29346. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29347. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29348. if len(m.appendlabel_dist) == 0 {
  29349. return nil, false
  29350. }
  29351. return m.appendlabel_dist, true
  29352. }
  29353. // ResetLabelDist resets all changes to the "label_dist" field.
  29354. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  29355. m.label_dist = nil
  29356. m.appendlabel_dist = nil
  29357. }
  29358. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  29359. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  29360. m.predicates = append(m.predicates, ps...)
  29361. }
  29362. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  29363. // users can use type-assertion to append predicates that do not depend on any generated package.
  29364. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  29365. p := make([]predicate.UsageStatisticMonth, len(ps))
  29366. for i := range ps {
  29367. p[i] = ps[i]
  29368. }
  29369. m.Where(p...)
  29370. }
  29371. // Op returns the operation name.
  29372. func (m *UsageStatisticMonthMutation) Op() Op {
  29373. return m.op
  29374. }
  29375. // SetOp allows setting the mutation operation.
  29376. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  29377. m.op = op
  29378. }
  29379. // Type returns the node type of this mutation (UsageStatisticMonth).
  29380. func (m *UsageStatisticMonthMutation) Type() string {
  29381. return m.typ
  29382. }
  29383. // Fields returns all fields that were changed during this mutation. Note that in
  29384. // order to get all numeric fields that were incremented/decremented, call
  29385. // AddedFields().
  29386. func (m *UsageStatisticMonthMutation) Fields() []string {
  29387. fields := make([]string, 0, 17)
  29388. if m.created_at != nil {
  29389. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  29390. }
  29391. if m.updated_at != nil {
  29392. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  29393. }
  29394. if m.status != nil {
  29395. fields = append(fields, usagestatisticmonth.FieldStatus)
  29396. }
  29397. if m.deleted_at != nil {
  29398. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  29399. }
  29400. if m.addtime != nil {
  29401. fields = append(fields, usagestatisticmonth.FieldAddtime)
  29402. }
  29403. if m._type != nil {
  29404. fields = append(fields, usagestatisticmonth.FieldType)
  29405. }
  29406. if m.bot_id != nil {
  29407. fields = append(fields, usagestatisticmonth.FieldBotID)
  29408. }
  29409. if m.organization_id != nil {
  29410. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  29411. }
  29412. if m.ai_response != nil {
  29413. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  29414. }
  29415. if m.sop_run != nil {
  29416. fields = append(fields, usagestatisticmonth.FieldSopRun)
  29417. }
  29418. if m.total_friend != nil {
  29419. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  29420. }
  29421. if m.total_group != nil {
  29422. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  29423. }
  29424. if m.account_balance != nil {
  29425. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  29426. }
  29427. if m.consume_token != nil {
  29428. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  29429. }
  29430. if m.active_user != nil {
  29431. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  29432. }
  29433. if m.new_user != nil {
  29434. fields = append(fields, usagestatisticmonth.FieldNewUser)
  29435. }
  29436. if m.label_dist != nil {
  29437. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  29438. }
  29439. return fields
  29440. }
  29441. // Field returns the value of a field with the given name. The second boolean
  29442. // return value indicates that this field was not set, or was not defined in the
  29443. // schema.
  29444. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  29445. switch name {
  29446. case usagestatisticmonth.FieldCreatedAt:
  29447. return m.CreatedAt()
  29448. case usagestatisticmonth.FieldUpdatedAt:
  29449. return m.UpdatedAt()
  29450. case usagestatisticmonth.FieldStatus:
  29451. return m.Status()
  29452. case usagestatisticmonth.FieldDeletedAt:
  29453. return m.DeletedAt()
  29454. case usagestatisticmonth.FieldAddtime:
  29455. return m.Addtime()
  29456. case usagestatisticmonth.FieldType:
  29457. return m.GetType()
  29458. case usagestatisticmonth.FieldBotID:
  29459. return m.BotID()
  29460. case usagestatisticmonth.FieldOrganizationID:
  29461. return m.OrganizationID()
  29462. case usagestatisticmonth.FieldAiResponse:
  29463. return m.AiResponse()
  29464. case usagestatisticmonth.FieldSopRun:
  29465. return m.SopRun()
  29466. case usagestatisticmonth.FieldTotalFriend:
  29467. return m.TotalFriend()
  29468. case usagestatisticmonth.FieldTotalGroup:
  29469. return m.TotalGroup()
  29470. case usagestatisticmonth.FieldAccountBalance:
  29471. return m.AccountBalance()
  29472. case usagestatisticmonth.FieldConsumeToken:
  29473. return m.ConsumeToken()
  29474. case usagestatisticmonth.FieldActiveUser:
  29475. return m.ActiveUser()
  29476. case usagestatisticmonth.FieldNewUser:
  29477. return m.NewUser()
  29478. case usagestatisticmonth.FieldLabelDist:
  29479. return m.LabelDist()
  29480. }
  29481. return nil, false
  29482. }
  29483. // OldField returns the old value of the field from the database. An error is
  29484. // returned if the mutation operation is not UpdateOne, or the query to the
  29485. // database failed.
  29486. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29487. switch name {
  29488. case usagestatisticmonth.FieldCreatedAt:
  29489. return m.OldCreatedAt(ctx)
  29490. case usagestatisticmonth.FieldUpdatedAt:
  29491. return m.OldUpdatedAt(ctx)
  29492. case usagestatisticmonth.FieldStatus:
  29493. return m.OldStatus(ctx)
  29494. case usagestatisticmonth.FieldDeletedAt:
  29495. return m.OldDeletedAt(ctx)
  29496. case usagestatisticmonth.FieldAddtime:
  29497. return m.OldAddtime(ctx)
  29498. case usagestatisticmonth.FieldType:
  29499. return m.OldType(ctx)
  29500. case usagestatisticmonth.FieldBotID:
  29501. return m.OldBotID(ctx)
  29502. case usagestatisticmonth.FieldOrganizationID:
  29503. return m.OldOrganizationID(ctx)
  29504. case usagestatisticmonth.FieldAiResponse:
  29505. return m.OldAiResponse(ctx)
  29506. case usagestatisticmonth.FieldSopRun:
  29507. return m.OldSopRun(ctx)
  29508. case usagestatisticmonth.FieldTotalFriend:
  29509. return m.OldTotalFriend(ctx)
  29510. case usagestatisticmonth.FieldTotalGroup:
  29511. return m.OldTotalGroup(ctx)
  29512. case usagestatisticmonth.FieldAccountBalance:
  29513. return m.OldAccountBalance(ctx)
  29514. case usagestatisticmonth.FieldConsumeToken:
  29515. return m.OldConsumeToken(ctx)
  29516. case usagestatisticmonth.FieldActiveUser:
  29517. return m.OldActiveUser(ctx)
  29518. case usagestatisticmonth.FieldNewUser:
  29519. return m.OldNewUser(ctx)
  29520. case usagestatisticmonth.FieldLabelDist:
  29521. return m.OldLabelDist(ctx)
  29522. }
  29523. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29524. }
  29525. // SetField sets the value of a field with the given name. It returns an error if
  29526. // the field is not defined in the schema, or if the type mismatched the field
  29527. // type.
  29528. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  29529. switch name {
  29530. case usagestatisticmonth.FieldCreatedAt:
  29531. v, ok := value.(time.Time)
  29532. if !ok {
  29533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29534. }
  29535. m.SetCreatedAt(v)
  29536. return nil
  29537. case usagestatisticmonth.FieldUpdatedAt:
  29538. v, ok := value.(time.Time)
  29539. if !ok {
  29540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29541. }
  29542. m.SetUpdatedAt(v)
  29543. return nil
  29544. case usagestatisticmonth.FieldStatus:
  29545. v, ok := value.(uint8)
  29546. if !ok {
  29547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29548. }
  29549. m.SetStatus(v)
  29550. return nil
  29551. case usagestatisticmonth.FieldDeletedAt:
  29552. v, ok := value.(time.Time)
  29553. if !ok {
  29554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29555. }
  29556. m.SetDeletedAt(v)
  29557. return nil
  29558. case usagestatisticmonth.FieldAddtime:
  29559. v, ok := value.(uint64)
  29560. if !ok {
  29561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29562. }
  29563. m.SetAddtime(v)
  29564. return nil
  29565. case usagestatisticmonth.FieldType:
  29566. v, ok := value.(int)
  29567. if !ok {
  29568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29569. }
  29570. m.SetType(v)
  29571. return nil
  29572. case usagestatisticmonth.FieldBotID:
  29573. v, ok := value.(string)
  29574. if !ok {
  29575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29576. }
  29577. m.SetBotID(v)
  29578. return nil
  29579. case usagestatisticmonth.FieldOrganizationID:
  29580. v, ok := value.(uint64)
  29581. if !ok {
  29582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29583. }
  29584. m.SetOrganizationID(v)
  29585. return nil
  29586. case usagestatisticmonth.FieldAiResponse:
  29587. v, ok := value.(uint64)
  29588. if !ok {
  29589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29590. }
  29591. m.SetAiResponse(v)
  29592. return nil
  29593. case usagestatisticmonth.FieldSopRun:
  29594. v, ok := value.(uint64)
  29595. if !ok {
  29596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29597. }
  29598. m.SetSopRun(v)
  29599. return nil
  29600. case usagestatisticmonth.FieldTotalFriend:
  29601. v, ok := value.(uint64)
  29602. if !ok {
  29603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29604. }
  29605. m.SetTotalFriend(v)
  29606. return nil
  29607. case usagestatisticmonth.FieldTotalGroup:
  29608. v, ok := value.(uint64)
  29609. if !ok {
  29610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29611. }
  29612. m.SetTotalGroup(v)
  29613. return nil
  29614. case usagestatisticmonth.FieldAccountBalance:
  29615. v, ok := value.(uint64)
  29616. if !ok {
  29617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29618. }
  29619. m.SetAccountBalance(v)
  29620. return nil
  29621. case usagestatisticmonth.FieldConsumeToken:
  29622. v, ok := value.(uint64)
  29623. if !ok {
  29624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29625. }
  29626. m.SetConsumeToken(v)
  29627. return nil
  29628. case usagestatisticmonth.FieldActiveUser:
  29629. v, ok := value.(uint64)
  29630. if !ok {
  29631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29632. }
  29633. m.SetActiveUser(v)
  29634. return nil
  29635. case usagestatisticmonth.FieldNewUser:
  29636. v, ok := value.(int64)
  29637. if !ok {
  29638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29639. }
  29640. m.SetNewUser(v)
  29641. return nil
  29642. case usagestatisticmonth.FieldLabelDist:
  29643. v, ok := value.([]custom_types.LabelDist)
  29644. if !ok {
  29645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29646. }
  29647. m.SetLabelDist(v)
  29648. return nil
  29649. }
  29650. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29651. }
  29652. // AddedFields returns all numeric fields that were incremented/decremented during
  29653. // this mutation.
  29654. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  29655. var fields []string
  29656. if m.addstatus != nil {
  29657. fields = append(fields, usagestatisticmonth.FieldStatus)
  29658. }
  29659. if m.addaddtime != nil {
  29660. fields = append(fields, usagestatisticmonth.FieldAddtime)
  29661. }
  29662. if m.add_type != nil {
  29663. fields = append(fields, usagestatisticmonth.FieldType)
  29664. }
  29665. if m.addorganization_id != nil {
  29666. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  29667. }
  29668. if m.addai_response != nil {
  29669. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  29670. }
  29671. if m.addsop_run != nil {
  29672. fields = append(fields, usagestatisticmonth.FieldSopRun)
  29673. }
  29674. if m.addtotal_friend != nil {
  29675. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  29676. }
  29677. if m.addtotal_group != nil {
  29678. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  29679. }
  29680. if m.addaccount_balance != nil {
  29681. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  29682. }
  29683. if m.addconsume_token != nil {
  29684. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  29685. }
  29686. if m.addactive_user != nil {
  29687. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  29688. }
  29689. if m.addnew_user != nil {
  29690. fields = append(fields, usagestatisticmonth.FieldNewUser)
  29691. }
  29692. return fields
  29693. }
  29694. // AddedField returns the numeric value that was incremented/decremented on a field
  29695. // with the given name. The second boolean return value indicates that this field
  29696. // was not set, or was not defined in the schema.
  29697. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  29698. switch name {
  29699. case usagestatisticmonth.FieldStatus:
  29700. return m.AddedStatus()
  29701. case usagestatisticmonth.FieldAddtime:
  29702. return m.AddedAddtime()
  29703. case usagestatisticmonth.FieldType:
  29704. return m.AddedType()
  29705. case usagestatisticmonth.FieldOrganizationID:
  29706. return m.AddedOrganizationID()
  29707. case usagestatisticmonth.FieldAiResponse:
  29708. return m.AddedAiResponse()
  29709. case usagestatisticmonth.FieldSopRun:
  29710. return m.AddedSopRun()
  29711. case usagestatisticmonth.FieldTotalFriend:
  29712. return m.AddedTotalFriend()
  29713. case usagestatisticmonth.FieldTotalGroup:
  29714. return m.AddedTotalGroup()
  29715. case usagestatisticmonth.FieldAccountBalance:
  29716. return m.AddedAccountBalance()
  29717. case usagestatisticmonth.FieldConsumeToken:
  29718. return m.AddedConsumeToken()
  29719. case usagestatisticmonth.FieldActiveUser:
  29720. return m.AddedActiveUser()
  29721. case usagestatisticmonth.FieldNewUser:
  29722. return m.AddedNewUser()
  29723. }
  29724. return nil, false
  29725. }
  29726. // AddField adds the value to the field with the given name. It returns an error if
  29727. // the field is not defined in the schema, or if the type mismatched the field
  29728. // type.
  29729. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  29730. switch name {
  29731. case usagestatisticmonth.FieldStatus:
  29732. v, ok := value.(int8)
  29733. if !ok {
  29734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29735. }
  29736. m.AddStatus(v)
  29737. return nil
  29738. case usagestatisticmonth.FieldAddtime:
  29739. v, ok := value.(int64)
  29740. if !ok {
  29741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29742. }
  29743. m.AddAddtime(v)
  29744. return nil
  29745. case usagestatisticmonth.FieldType:
  29746. v, ok := value.(int)
  29747. if !ok {
  29748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29749. }
  29750. m.AddType(v)
  29751. return nil
  29752. case usagestatisticmonth.FieldOrganizationID:
  29753. v, ok := value.(int64)
  29754. if !ok {
  29755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29756. }
  29757. m.AddOrganizationID(v)
  29758. return nil
  29759. case usagestatisticmonth.FieldAiResponse:
  29760. v, ok := value.(int64)
  29761. if !ok {
  29762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29763. }
  29764. m.AddAiResponse(v)
  29765. return nil
  29766. case usagestatisticmonth.FieldSopRun:
  29767. v, ok := value.(int64)
  29768. if !ok {
  29769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29770. }
  29771. m.AddSopRun(v)
  29772. return nil
  29773. case usagestatisticmonth.FieldTotalFriend:
  29774. v, ok := value.(int64)
  29775. if !ok {
  29776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29777. }
  29778. m.AddTotalFriend(v)
  29779. return nil
  29780. case usagestatisticmonth.FieldTotalGroup:
  29781. v, ok := value.(int64)
  29782. if !ok {
  29783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29784. }
  29785. m.AddTotalGroup(v)
  29786. return nil
  29787. case usagestatisticmonth.FieldAccountBalance:
  29788. v, ok := value.(int64)
  29789. if !ok {
  29790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29791. }
  29792. m.AddAccountBalance(v)
  29793. return nil
  29794. case usagestatisticmonth.FieldConsumeToken:
  29795. v, ok := value.(int64)
  29796. if !ok {
  29797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29798. }
  29799. m.AddConsumeToken(v)
  29800. return nil
  29801. case usagestatisticmonth.FieldActiveUser:
  29802. v, ok := value.(int64)
  29803. if !ok {
  29804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29805. }
  29806. m.AddActiveUser(v)
  29807. return nil
  29808. case usagestatisticmonth.FieldNewUser:
  29809. v, ok := value.(int64)
  29810. if !ok {
  29811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29812. }
  29813. m.AddNewUser(v)
  29814. return nil
  29815. }
  29816. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  29817. }
  29818. // ClearedFields returns all nullable fields that were cleared during this
  29819. // mutation.
  29820. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  29821. var fields []string
  29822. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  29823. fields = append(fields, usagestatisticmonth.FieldStatus)
  29824. }
  29825. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  29826. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  29827. }
  29828. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  29829. fields = append(fields, usagestatisticmonth.FieldBotID)
  29830. }
  29831. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  29832. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  29833. }
  29834. return fields
  29835. }
  29836. // FieldCleared returns a boolean indicating if a field with the given name was
  29837. // cleared in this mutation.
  29838. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  29839. _, ok := m.clearedFields[name]
  29840. return ok
  29841. }
  29842. // ClearField clears the value of the field with the given name. It returns an
  29843. // error if the field is not defined in the schema.
  29844. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  29845. switch name {
  29846. case usagestatisticmonth.FieldStatus:
  29847. m.ClearStatus()
  29848. return nil
  29849. case usagestatisticmonth.FieldDeletedAt:
  29850. m.ClearDeletedAt()
  29851. return nil
  29852. case usagestatisticmonth.FieldBotID:
  29853. m.ClearBotID()
  29854. return nil
  29855. case usagestatisticmonth.FieldOrganizationID:
  29856. m.ClearOrganizationID()
  29857. return nil
  29858. }
  29859. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  29860. }
  29861. // ResetField resets all changes in the mutation for the field with the given name.
  29862. // It returns an error if the field is not defined in the schema.
  29863. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  29864. switch name {
  29865. case usagestatisticmonth.FieldCreatedAt:
  29866. m.ResetCreatedAt()
  29867. return nil
  29868. case usagestatisticmonth.FieldUpdatedAt:
  29869. m.ResetUpdatedAt()
  29870. return nil
  29871. case usagestatisticmonth.FieldStatus:
  29872. m.ResetStatus()
  29873. return nil
  29874. case usagestatisticmonth.FieldDeletedAt:
  29875. m.ResetDeletedAt()
  29876. return nil
  29877. case usagestatisticmonth.FieldAddtime:
  29878. m.ResetAddtime()
  29879. return nil
  29880. case usagestatisticmonth.FieldType:
  29881. m.ResetType()
  29882. return nil
  29883. case usagestatisticmonth.FieldBotID:
  29884. m.ResetBotID()
  29885. return nil
  29886. case usagestatisticmonth.FieldOrganizationID:
  29887. m.ResetOrganizationID()
  29888. return nil
  29889. case usagestatisticmonth.FieldAiResponse:
  29890. m.ResetAiResponse()
  29891. return nil
  29892. case usagestatisticmonth.FieldSopRun:
  29893. m.ResetSopRun()
  29894. return nil
  29895. case usagestatisticmonth.FieldTotalFriend:
  29896. m.ResetTotalFriend()
  29897. return nil
  29898. case usagestatisticmonth.FieldTotalGroup:
  29899. m.ResetTotalGroup()
  29900. return nil
  29901. case usagestatisticmonth.FieldAccountBalance:
  29902. m.ResetAccountBalance()
  29903. return nil
  29904. case usagestatisticmonth.FieldConsumeToken:
  29905. m.ResetConsumeToken()
  29906. return nil
  29907. case usagestatisticmonth.FieldActiveUser:
  29908. m.ResetActiveUser()
  29909. return nil
  29910. case usagestatisticmonth.FieldNewUser:
  29911. m.ResetNewUser()
  29912. return nil
  29913. case usagestatisticmonth.FieldLabelDist:
  29914. m.ResetLabelDist()
  29915. return nil
  29916. }
  29917. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29918. }
  29919. // AddedEdges returns all edge names that were set/added in this mutation.
  29920. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  29921. edges := make([]string, 0, 0)
  29922. return edges
  29923. }
  29924. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29925. // name in this mutation.
  29926. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  29927. return nil
  29928. }
  29929. // RemovedEdges returns all edge names that were removed in this mutation.
  29930. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  29931. edges := make([]string, 0, 0)
  29932. return edges
  29933. }
  29934. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29935. // the given name in this mutation.
  29936. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  29937. return nil
  29938. }
  29939. // ClearedEdges returns all edge names that were cleared in this mutation.
  29940. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  29941. edges := make([]string, 0, 0)
  29942. return edges
  29943. }
  29944. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29945. // was cleared in this mutation.
  29946. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  29947. return false
  29948. }
  29949. // ClearEdge clears the value of the edge with the given name. It returns an error
  29950. // if that edge is not defined in the schema.
  29951. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  29952. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  29953. }
  29954. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29955. // It returns an error if the edge is not defined in the schema.
  29956. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  29957. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  29958. }
  29959. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  29960. type UsageTotalMutation struct {
  29961. config
  29962. op Op
  29963. typ string
  29964. id *uint64
  29965. created_at *time.Time
  29966. updated_at *time.Time
  29967. status *uint8
  29968. addstatus *int8
  29969. _type *int
  29970. add_type *int
  29971. bot_id *string
  29972. total_tokens *uint64
  29973. addtotal_tokens *int64
  29974. start_index *uint64
  29975. addstart_index *int64
  29976. end_index *uint64
  29977. addend_index *int64
  29978. organization_id *uint64
  29979. addorganization_id *int64
  29980. clearedFields map[string]struct{}
  29981. done bool
  29982. oldValue func(context.Context) (*UsageTotal, error)
  29983. predicates []predicate.UsageTotal
  29984. }
  29985. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  29986. // usagetotalOption allows management of the mutation configuration using functional options.
  29987. type usagetotalOption func(*UsageTotalMutation)
  29988. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  29989. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  29990. m := &UsageTotalMutation{
  29991. config: c,
  29992. op: op,
  29993. typ: TypeUsageTotal,
  29994. clearedFields: make(map[string]struct{}),
  29995. }
  29996. for _, opt := range opts {
  29997. opt(m)
  29998. }
  29999. return m
  30000. }
  30001. // withUsageTotalID sets the ID field of the mutation.
  30002. func withUsageTotalID(id uint64) usagetotalOption {
  30003. return func(m *UsageTotalMutation) {
  30004. var (
  30005. err error
  30006. once sync.Once
  30007. value *UsageTotal
  30008. )
  30009. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  30010. once.Do(func() {
  30011. if m.done {
  30012. err = errors.New("querying old values post mutation is not allowed")
  30013. } else {
  30014. value, err = m.Client().UsageTotal.Get(ctx, id)
  30015. }
  30016. })
  30017. return value, err
  30018. }
  30019. m.id = &id
  30020. }
  30021. }
  30022. // withUsageTotal sets the old UsageTotal of the mutation.
  30023. func withUsageTotal(node *UsageTotal) usagetotalOption {
  30024. return func(m *UsageTotalMutation) {
  30025. m.oldValue = func(context.Context) (*UsageTotal, error) {
  30026. return node, nil
  30027. }
  30028. m.id = &node.ID
  30029. }
  30030. }
  30031. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30032. // executed in a transaction (ent.Tx), a transactional client is returned.
  30033. func (m UsageTotalMutation) Client() *Client {
  30034. client := &Client{config: m.config}
  30035. client.init()
  30036. return client
  30037. }
  30038. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30039. // it returns an error otherwise.
  30040. func (m UsageTotalMutation) Tx() (*Tx, error) {
  30041. if _, ok := m.driver.(*txDriver); !ok {
  30042. return nil, errors.New("ent: mutation is not running in a transaction")
  30043. }
  30044. tx := &Tx{config: m.config}
  30045. tx.init()
  30046. return tx, nil
  30047. }
  30048. // SetID sets the value of the id field. Note that this
  30049. // operation is only accepted on creation of UsageTotal entities.
  30050. func (m *UsageTotalMutation) SetID(id uint64) {
  30051. m.id = &id
  30052. }
  30053. // ID returns the ID value in the mutation. Note that the ID is only available
  30054. // if it was provided to the builder or after it was returned from the database.
  30055. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  30056. if m.id == nil {
  30057. return
  30058. }
  30059. return *m.id, true
  30060. }
  30061. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30062. // That means, if the mutation is applied within a transaction with an isolation level such
  30063. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30064. // or updated by the mutation.
  30065. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  30066. switch {
  30067. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30068. id, exists := m.ID()
  30069. if exists {
  30070. return []uint64{id}, nil
  30071. }
  30072. fallthrough
  30073. case m.op.Is(OpUpdate | OpDelete):
  30074. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  30075. default:
  30076. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30077. }
  30078. }
  30079. // SetCreatedAt sets the "created_at" field.
  30080. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  30081. m.created_at = &t
  30082. }
  30083. // CreatedAt returns the value of the "created_at" field in the mutation.
  30084. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  30085. v := m.created_at
  30086. if v == nil {
  30087. return
  30088. }
  30089. return *v, true
  30090. }
  30091. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  30092. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30094. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30095. if !m.op.Is(OpUpdateOne) {
  30096. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30097. }
  30098. if m.id == nil || m.oldValue == nil {
  30099. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30100. }
  30101. oldValue, err := m.oldValue(ctx)
  30102. if err != nil {
  30103. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30104. }
  30105. return oldValue.CreatedAt, nil
  30106. }
  30107. // ResetCreatedAt resets all changes to the "created_at" field.
  30108. func (m *UsageTotalMutation) ResetCreatedAt() {
  30109. m.created_at = nil
  30110. }
  30111. // SetUpdatedAt sets the "updated_at" field.
  30112. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  30113. m.updated_at = &t
  30114. }
  30115. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30116. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  30117. v := m.updated_at
  30118. if v == nil {
  30119. return
  30120. }
  30121. return *v, true
  30122. }
  30123. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  30124. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30126. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30127. if !m.op.Is(OpUpdateOne) {
  30128. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30129. }
  30130. if m.id == nil || m.oldValue == nil {
  30131. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30132. }
  30133. oldValue, err := m.oldValue(ctx)
  30134. if err != nil {
  30135. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30136. }
  30137. return oldValue.UpdatedAt, nil
  30138. }
  30139. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30140. func (m *UsageTotalMutation) ResetUpdatedAt() {
  30141. m.updated_at = nil
  30142. }
  30143. // SetStatus sets the "status" field.
  30144. func (m *UsageTotalMutation) SetStatus(u uint8) {
  30145. m.status = &u
  30146. m.addstatus = nil
  30147. }
  30148. // Status returns the value of the "status" field in the mutation.
  30149. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  30150. v := m.status
  30151. if v == nil {
  30152. return
  30153. }
  30154. return *v, true
  30155. }
  30156. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  30157. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30159. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30160. if !m.op.Is(OpUpdateOne) {
  30161. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30162. }
  30163. if m.id == nil || m.oldValue == nil {
  30164. return v, errors.New("OldStatus requires an ID field in the mutation")
  30165. }
  30166. oldValue, err := m.oldValue(ctx)
  30167. if err != nil {
  30168. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30169. }
  30170. return oldValue.Status, nil
  30171. }
  30172. // AddStatus adds u to the "status" field.
  30173. func (m *UsageTotalMutation) AddStatus(u int8) {
  30174. if m.addstatus != nil {
  30175. *m.addstatus += u
  30176. } else {
  30177. m.addstatus = &u
  30178. }
  30179. }
  30180. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30181. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  30182. v := m.addstatus
  30183. if v == nil {
  30184. return
  30185. }
  30186. return *v, true
  30187. }
  30188. // ClearStatus clears the value of the "status" field.
  30189. func (m *UsageTotalMutation) ClearStatus() {
  30190. m.status = nil
  30191. m.addstatus = nil
  30192. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  30193. }
  30194. // StatusCleared returns if the "status" field was cleared in this mutation.
  30195. func (m *UsageTotalMutation) StatusCleared() bool {
  30196. _, ok := m.clearedFields[usagetotal.FieldStatus]
  30197. return ok
  30198. }
  30199. // ResetStatus resets all changes to the "status" field.
  30200. func (m *UsageTotalMutation) ResetStatus() {
  30201. m.status = nil
  30202. m.addstatus = nil
  30203. delete(m.clearedFields, usagetotal.FieldStatus)
  30204. }
  30205. // SetType sets the "type" field.
  30206. func (m *UsageTotalMutation) SetType(i int) {
  30207. m._type = &i
  30208. m.add_type = nil
  30209. }
  30210. // GetType returns the value of the "type" field in the mutation.
  30211. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  30212. v := m._type
  30213. if v == nil {
  30214. return
  30215. }
  30216. return *v, true
  30217. }
  30218. // OldType returns the old "type" field's value of the UsageTotal entity.
  30219. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30221. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  30222. if !m.op.Is(OpUpdateOne) {
  30223. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30224. }
  30225. if m.id == nil || m.oldValue == nil {
  30226. return v, errors.New("OldType requires an ID field in the mutation")
  30227. }
  30228. oldValue, err := m.oldValue(ctx)
  30229. if err != nil {
  30230. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30231. }
  30232. return oldValue.Type, nil
  30233. }
  30234. // AddType adds i to the "type" field.
  30235. func (m *UsageTotalMutation) AddType(i int) {
  30236. if m.add_type != nil {
  30237. *m.add_type += i
  30238. } else {
  30239. m.add_type = &i
  30240. }
  30241. }
  30242. // AddedType returns the value that was added to the "type" field in this mutation.
  30243. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  30244. v := m.add_type
  30245. if v == nil {
  30246. return
  30247. }
  30248. return *v, true
  30249. }
  30250. // ClearType clears the value of the "type" field.
  30251. func (m *UsageTotalMutation) ClearType() {
  30252. m._type = nil
  30253. m.add_type = nil
  30254. m.clearedFields[usagetotal.FieldType] = struct{}{}
  30255. }
  30256. // TypeCleared returns if the "type" field was cleared in this mutation.
  30257. func (m *UsageTotalMutation) TypeCleared() bool {
  30258. _, ok := m.clearedFields[usagetotal.FieldType]
  30259. return ok
  30260. }
  30261. // ResetType resets all changes to the "type" field.
  30262. func (m *UsageTotalMutation) ResetType() {
  30263. m._type = nil
  30264. m.add_type = nil
  30265. delete(m.clearedFields, usagetotal.FieldType)
  30266. }
  30267. // SetBotID sets the "bot_id" field.
  30268. func (m *UsageTotalMutation) SetBotID(s string) {
  30269. m.bot_id = &s
  30270. }
  30271. // BotID returns the value of the "bot_id" field in the mutation.
  30272. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  30273. v := m.bot_id
  30274. if v == nil {
  30275. return
  30276. }
  30277. return *v, true
  30278. }
  30279. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  30280. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30282. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  30283. if !m.op.Is(OpUpdateOne) {
  30284. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30285. }
  30286. if m.id == nil || m.oldValue == nil {
  30287. return v, errors.New("OldBotID requires an ID field in the mutation")
  30288. }
  30289. oldValue, err := m.oldValue(ctx)
  30290. if err != nil {
  30291. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30292. }
  30293. return oldValue.BotID, nil
  30294. }
  30295. // ResetBotID resets all changes to the "bot_id" field.
  30296. func (m *UsageTotalMutation) ResetBotID() {
  30297. m.bot_id = nil
  30298. }
  30299. // SetTotalTokens sets the "total_tokens" field.
  30300. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  30301. m.total_tokens = &u
  30302. m.addtotal_tokens = nil
  30303. }
  30304. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  30305. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  30306. v := m.total_tokens
  30307. if v == nil {
  30308. return
  30309. }
  30310. return *v, true
  30311. }
  30312. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  30313. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30315. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  30316. if !m.op.Is(OpUpdateOne) {
  30317. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  30318. }
  30319. if m.id == nil || m.oldValue == nil {
  30320. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  30321. }
  30322. oldValue, err := m.oldValue(ctx)
  30323. if err != nil {
  30324. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  30325. }
  30326. return oldValue.TotalTokens, nil
  30327. }
  30328. // AddTotalTokens adds u to the "total_tokens" field.
  30329. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  30330. if m.addtotal_tokens != nil {
  30331. *m.addtotal_tokens += u
  30332. } else {
  30333. m.addtotal_tokens = &u
  30334. }
  30335. }
  30336. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  30337. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  30338. v := m.addtotal_tokens
  30339. if v == nil {
  30340. return
  30341. }
  30342. return *v, true
  30343. }
  30344. // ClearTotalTokens clears the value of the "total_tokens" field.
  30345. func (m *UsageTotalMutation) ClearTotalTokens() {
  30346. m.total_tokens = nil
  30347. m.addtotal_tokens = nil
  30348. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  30349. }
  30350. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  30351. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  30352. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  30353. return ok
  30354. }
  30355. // ResetTotalTokens resets all changes to the "total_tokens" field.
  30356. func (m *UsageTotalMutation) ResetTotalTokens() {
  30357. m.total_tokens = nil
  30358. m.addtotal_tokens = nil
  30359. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  30360. }
  30361. // SetStartIndex sets the "start_index" field.
  30362. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  30363. m.start_index = &u
  30364. m.addstart_index = nil
  30365. }
  30366. // StartIndex returns the value of the "start_index" field in the mutation.
  30367. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  30368. v := m.start_index
  30369. if v == nil {
  30370. return
  30371. }
  30372. return *v, true
  30373. }
  30374. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  30375. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30377. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  30378. if !m.op.Is(OpUpdateOne) {
  30379. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  30380. }
  30381. if m.id == nil || m.oldValue == nil {
  30382. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  30383. }
  30384. oldValue, err := m.oldValue(ctx)
  30385. if err != nil {
  30386. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  30387. }
  30388. return oldValue.StartIndex, nil
  30389. }
  30390. // AddStartIndex adds u to the "start_index" field.
  30391. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  30392. if m.addstart_index != nil {
  30393. *m.addstart_index += u
  30394. } else {
  30395. m.addstart_index = &u
  30396. }
  30397. }
  30398. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  30399. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  30400. v := m.addstart_index
  30401. if v == nil {
  30402. return
  30403. }
  30404. return *v, true
  30405. }
  30406. // ClearStartIndex clears the value of the "start_index" field.
  30407. func (m *UsageTotalMutation) ClearStartIndex() {
  30408. m.start_index = nil
  30409. m.addstart_index = nil
  30410. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  30411. }
  30412. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  30413. func (m *UsageTotalMutation) StartIndexCleared() bool {
  30414. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  30415. return ok
  30416. }
  30417. // ResetStartIndex resets all changes to the "start_index" field.
  30418. func (m *UsageTotalMutation) ResetStartIndex() {
  30419. m.start_index = nil
  30420. m.addstart_index = nil
  30421. delete(m.clearedFields, usagetotal.FieldStartIndex)
  30422. }
  30423. // SetEndIndex sets the "end_index" field.
  30424. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  30425. m.end_index = &u
  30426. m.addend_index = nil
  30427. }
  30428. // EndIndex returns the value of the "end_index" field in the mutation.
  30429. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  30430. v := m.end_index
  30431. if v == nil {
  30432. return
  30433. }
  30434. return *v, true
  30435. }
  30436. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  30437. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30439. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  30440. if !m.op.Is(OpUpdateOne) {
  30441. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  30442. }
  30443. if m.id == nil || m.oldValue == nil {
  30444. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  30445. }
  30446. oldValue, err := m.oldValue(ctx)
  30447. if err != nil {
  30448. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  30449. }
  30450. return oldValue.EndIndex, nil
  30451. }
  30452. // AddEndIndex adds u to the "end_index" field.
  30453. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  30454. if m.addend_index != nil {
  30455. *m.addend_index += u
  30456. } else {
  30457. m.addend_index = &u
  30458. }
  30459. }
  30460. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  30461. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  30462. v := m.addend_index
  30463. if v == nil {
  30464. return
  30465. }
  30466. return *v, true
  30467. }
  30468. // ClearEndIndex clears the value of the "end_index" field.
  30469. func (m *UsageTotalMutation) ClearEndIndex() {
  30470. m.end_index = nil
  30471. m.addend_index = nil
  30472. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  30473. }
  30474. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  30475. func (m *UsageTotalMutation) EndIndexCleared() bool {
  30476. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  30477. return ok
  30478. }
  30479. // ResetEndIndex resets all changes to the "end_index" field.
  30480. func (m *UsageTotalMutation) ResetEndIndex() {
  30481. m.end_index = nil
  30482. m.addend_index = nil
  30483. delete(m.clearedFields, usagetotal.FieldEndIndex)
  30484. }
  30485. // SetOrganizationID sets the "organization_id" field.
  30486. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  30487. m.organization_id = &u
  30488. m.addorganization_id = nil
  30489. }
  30490. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30491. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  30492. v := m.organization_id
  30493. if v == nil {
  30494. return
  30495. }
  30496. return *v, true
  30497. }
  30498. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  30499. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  30500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30501. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30502. if !m.op.Is(OpUpdateOne) {
  30503. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30504. }
  30505. if m.id == nil || m.oldValue == nil {
  30506. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30507. }
  30508. oldValue, err := m.oldValue(ctx)
  30509. if err != nil {
  30510. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30511. }
  30512. return oldValue.OrganizationID, nil
  30513. }
  30514. // AddOrganizationID adds u to the "organization_id" field.
  30515. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  30516. if m.addorganization_id != nil {
  30517. *m.addorganization_id += u
  30518. } else {
  30519. m.addorganization_id = &u
  30520. }
  30521. }
  30522. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30523. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  30524. v := m.addorganization_id
  30525. if v == nil {
  30526. return
  30527. }
  30528. return *v, true
  30529. }
  30530. // ClearOrganizationID clears the value of the "organization_id" field.
  30531. func (m *UsageTotalMutation) ClearOrganizationID() {
  30532. m.organization_id = nil
  30533. m.addorganization_id = nil
  30534. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  30535. }
  30536. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30537. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  30538. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  30539. return ok
  30540. }
  30541. // ResetOrganizationID resets all changes to the "organization_id" field.
  30542. func (m *UsageTotalMutation) ResetOrganizationID() {
  30543. m.organization_id = nil
  30544. m.addorganization_id = nil
  30545. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  30546. }
  30547. // Where appends a list predicates to the UsageTotalMutation builder.
  30548. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  30549. m.predicates = append(m.predicates, ps...)
  30550. }
  30551. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  30552. // users can use type-assertion to append predicates that do not depend on any generated package.
  30553. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  30554. p := make([]predicate.UsageTotal, len(ps))
  30555. for i := range ps {
  30556. p[i] = ps[i]
  30557. }
  30558. m.Where(p...)
  30559. }
  30560. // Op returns the operation name.
  30561. func (m *UsageTotalMutation) Op() Op {
  30562. return m.op
  30563. }
  30564. // SetOp allows setting the mutation operation.
  30565. func (m *UsageTotalMutation) SetOp(op Op) {
  30566. m.op = op
  30567. }
  30568. // Type returns the node type of this mutation (UsageTotal).
  30569. func (m *UsageTotalMutation) Type() string {
  30570. return m.typ
  30571. }
  30572. // Fields returns all fields that were changed during this mutation. Note that in
  30573. // order to get all numeric fields that were incremented/decremented, call
  30574. // AddedFields().
  30575. func (m *UsageTotalMutation) Fields() []string {
  30576. fields := make([]string, 0, 9)
  30577. if m.created_at != nil {
  30578. fields = append(fields, usagetotal.FieldCreatedAt)
  30579. }
  30580. if m.updated_at != nil {
  30581. fields = append(fields, usagetotal.FieldUpdatedAt)
  30582. }
  30583. if m.status != nil {
  30584. fields = append(fields, usagetotal.FieldStatus)
  30585. }
  30586. if m._type != nil {
  30587. fields = append(fields, usagetotal.FieldType)
  30588. }
  30589. if m.bot_id != nil {
  30590. fields = append(fields, usagetotal.FieldBotID)
  30591. }
  30592. if m.total_tokens != nil {
  30593. fields = append(fields, usagetotal.FieldTotalTokens)
  30594. }
  30595. if m.start_index != nil {
  30596. fields = append(fields, usagetotal.FieldStartIndex)
  30597. }
  30598. if m.end_index != nil {
  30599. fields = append(fields, usagetotal.FieldEndIndex)
  30600. }
  30601. if m.organization_id != nil {
  30602. fields = append(fields, usagetotal.FieldOrganizationID)
  30603. }
  30604. return fields
  30605. }
  30606. // Field returns the value of a field with the given name. The second boolean
  30607. // return value indicates that this field was not set, or was not defined in the
  30608. // schema.
  30609. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  30610. switch name {
  30611. case usagetotal.FieldCreatedAt:
  30612. return m.CreatedAt()
  30613. case usagetotal.FieldUpdatedAt:
  30614. return m.UpdatedAt()
  30615. case usagetotal.FieldStatus:
  30616. return m.Status()
  30617. case usagetotal.FieldType:
  30618. return m.GetType()
  30619. case usagetotal.FieldBotID:
  30620. return m.BotID()
  30621. case usagetotal.FieldTotalTokens:
  30622. return m.TotalTokens()
  30623. case usagetotal.FieldStartIndex:
  30624. return m.StartIndex()
  30625. case usagetotal.FieldEndIndex:
  30626. return m.EndIndex()
  30627. case usagetotal.FieldOrganizationID:
  30628. return m.OrganizationID()
  30629. }
  30630. return nil, false
  30631. }
  30632. // OldField returns the old value of the field from the database. An error is
  30633. // returned if the mutation operation is not UpdateOne, or the query to the
  30634. // database failed.
  30635. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30636. switch name {
  30637. case usagetotal.FieldCreatedAt:
  30638. return m.OldCreatedAt(ctx)
  30639. case usagetotal.FieldUpdatedAt:
  30640. return m.OldUpdatedAt(ctx)
  30641. case usagetotal.FieldStatus:
  30642. return m.OldStatus(ctx)
  30643. case usagetotal.FieldType:
  30644. return m.OldType(ctx)
  30645. case usagetotal.FieldBotID:
  30646. return m.OldBotID(ctx)
  30647. case usagetotal.FieldTotalTokens:
  30648. return m.OldTotalTokens(ctx)
  30649. case usagetotal.FieldStartIndex:
  30650. return m.OldStartIndex(ctx)
  30651. case usagetotal.FieldEndIndex:
  30652. return m.OldEndIndex(ctx)
  30653. case usagetotal.FieldOrganizationID:
  30654. return m.OldOrganizationID(ctx)
  30655. }
  30656. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  30657. }
  30658. // SetField sets the value of a field with the given name. It returns an error if
  30659. // the field is not defined in the schema, or if the type mismatched the field
  30660. // type.
  30661. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  30662. switch name {
  30663. case usagetotal.FieldCreatedAt:
  30664. v, ok := value.(time.Time)
  30665. if !ok {
  30666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30667. }
  30668. m.SetCreatedAt(v)
  30669. return nil
  30670. case usagetotal.FieldUpdatedAt:
  30671. v, ok := value.(time.Time)
  30672. if !ok {
  30673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30674. }
  30675. m.SetUpdatedAt(v)
  30676. return nil
  30677. case usagetotal.FieldStatus:
  30678. v, ok := value.(uint8)
  30679. if !ok {
  30680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30681. }
  30682. m.SetStatus(v)
  30683. return nil
  30684. case usagetotal.FieldType:
  30685. v, ok := value.(int)
  30686. if !ok {
  30687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30688. }
  30689. m.SetType(v)
  30690. return nil
  30691. case usagetotal.FieldBotID:
  30692. v, ok := value.(string)
  30693. if !ok {
  30694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30695. }
  30696. m.SetBotID(v)
  30697. return nil
  30698. case usagetotal.FieldTotalTokens:
  30699. v, ok := value.(uint64)
  30700. if !ok {
  30701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30702. }
  30703. m.SetTotalTokens(v)
  30704. return nil
  30705. case usagetotal.FieldStartIndex:
  30706. v, ok := value.(uint64)
  30707. if !ok {
  30708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30709. }
  30710. m.SetStartIndex(v)
  30711. return nil
  30712. case usagetotal.FieldEndIndex:
  30713. v, ok := value.(uint64)
  30714. if !ok {
  30715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30716. }
  30717. m.SetEndIndex(v)
  30718. return nil
  30719. case usagetotal.FieldOrganizationID:
  30720. v, ok := value.(uint64)
  30721. if !ok {
  30722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30723. }
  30724. m.SetOrganizationID(v)
  30725. return nil
  30726. }
  30727. return fmt.Errorf("unknown UsageTotal field %s", name)
  30728. }
  30729. // AddedFields returns all numeric fields that were incremented/decremented during
  30730. // this mutation.
  30731. func (m *UsageTotalMutation) AddedFields() []string {
  30732. var fields []string
  30733. if m.addstatus != nil {
  30734. fields = append(fields, usagetotal.FieldStatus)
  30735. }
  30736. if m.add_type != nil {
  30737. fields = append(fields, usagetotal.FieldType)
  30738. }
  30739. if m.addtotal_tokens != nil {
  30740. fields = append(fields, usagetotal.FieldTotalTokens)
  30741. }
  30742. if m.addstart_index != nil {
  30743. fields = append(fields, usagetotal.FieldStartIndex)
  30744. }
  30745. if m.addend_index != nil {
  30746. fields = append(fields, usagetotal.FieldEndIndex)
  30747. }
  30748. if m.addorganization_id != nil {
  30749. fields = append(fields, usagetotal.FieldOrganizationID)
  30750. }
  30751. return fields
  30752. }
  30753. // AddedField returns the numeric value that was incremented/decremented on a field
  30754. // with the given name. The second boolean return value indicates that this field
  30755. // was not set, or was not defined in the schema.
  30756. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  30757. switch name {
  30758. case usagetotal.FieldStatus:
  30759. return m.AddedStatus()
  30760. case usagetotal.FieldType:
  30761. return m.AddedType()
  30762. case usagetotal.FieldTotalTokens:
  30763. return m.AddedTotalTokens()
  30764. case usagetotal.FieldStartIndex:
  30765. return m.AddedStartIndex()
  30766. case usagetotal.FieldEndIndex:
  30767. return m.AddedEndIndex()
  30768. case usagetotal.FieldOrganizationID:
  30769. return m.AddedOrganizationID()
  30770. }
  30771. return nil, false
  30772. }
  30773. // AddField adds the value to the field with the given name. It returns an error if
  30774. // the field is not defined in the schema, or if the type mismatched the field
  30775. // type.
  30776. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  30777. switch name {
  30778. case usagetotal.FieldStatus:
  30779. v, ok := value.(int8)
  30780. if !ok {
  30781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30782. }
  30783. m.AddStatus(v)
  30784. return nil
  30785. case usagetotal.FieldType:
  30786. v, ok := value.(int)
  30787. if !ok {
  30788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30789. }
  30790. m.AddType(v)
  30791. return nil
  30792. case usagetotal.FieldTotalTokens:
  30793. v, ok := value.(int64)
  30794. if !ok {
  30795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30796. }
  30797. m.AddTotalTokens(v)
  30798. return nil
  30799. case usagetotal.FieldStartIndex:
  30800. v, ok := value.(int64)
  30801. if !ok {
  30802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30803. }
  30804. m.AddStartIndex(v)
  30805. return nil
  30806. case usagetotal.FieldEndIndex:
  30807. v, ok := value.(int64)
  30808. if !ok {
  30809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30810. }
  30811. m.AddEndIndex(v)
  30812. return nil
  30813. case usagetotal.FieldOrganizationID:
  30814. v, ok := value.(int64)
  30815. if !ok {
  30816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30817. }
  30818. m.AddOrganizationID(v)
  30819. return nil
  30820. }
  30821. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  30822. }
  30823. // ClearedFields returns all nullable fields that were cleared during this
  30824. // mutation.
  30825. func (m *UsageTotalMutation) ClearedFields() []string {
  30826. var fields []string
  30827. if m.FieldCleared(usagetotal.FieldStatus) {
  30828. fields = append(fields, usagetotal.FieldStatus)
  30829. }
  30830. if m.FieldCleared(usagetotal.FieldType) {
  30831. fields = append(fields, usagetotal.FieldType)
  30832. }
  30833. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  30834. fields = append(fields, usagetotal.FieldTotalTokens)
  30835. }
  30836. if m.FieldCleared(usagetotal.FieldStartIndex) {
  30837. fields = append(fields, usagetotal.FieldStartIndex)
  30838. }
  30839. if m.FieldCleared(usagetotal.FieldEndIndex) {
  30840. fields = append(fields, usagetotal.FieldEndIndex)
  30841. }
  30842. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  30843. fields = append(fields, usagetotal.FieldOrganizationID)
  30844. }
  30845. return fields
  30846. }
  30847. // FieldCleared returns a boolean indicating if a field with the given name was
  30848. // cleared in this mutation.
  30849. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  30850. _, ok := m.clearedFields[name]
  30851. return ok
  30852. }
  30853. // ClearField clears the value of the field with the given name. It returns an
  30854. // error if the field is not defined in the schema.
  30855. func (m *UsageTotalMutation) ClearField(name string) error {
  30856. switch name {
  30857. case usagetotal.FieldStatus:
  30858. m.ClearStatus()
  30859. return nil
  30860. case usagetotal.FieldType:
  30861. m.ClearType()
  30862. return nil
  30863. case usagetotal.FieldTotalTokens:
  30864. m.ClearTotalTokens()
  30865. return nil
  30866. case usagetotal.FieldStartIndex:
  30867. m.ClearStartIndex()
  30868. return nil
  30869. case usagetotal.FieldEndIndex:
  30870. m.ClearEndIndex()
  30871. return nil
  30872. case usagetotal.FieldOrganizationID:
  30873. m.ClearOrganizationID()
  30874. return nil
  30875. }
  30876. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  30877. }
  30878. // ResetField resets all changes in the mutation for the field with the given name.
  30879. // It returns an error if the field is not defined in the schema.
  30880. func (m *UsageTotalMutation) ResetField(name string) error {
  30881. switch name {
  30882. case usagetotal.FieldCreatedAt:
  30883. m.ResetCreatedAt()
  30884. return nil
  30885. case usagetotal.FieldUpdatedAt:
  30886. m.ResetUpdatedAt()
  30887. return nil
  30888. case usagetotal.FieldStatus:
  30889. m.ResetStatus()
  30890. return nil
  30891. case usagetotal.FieldType:
  30892. m.ResetType()
  30893. return nil
  30894. case usagetotal.FieldBotID:
  30895. m.ResetBotID()
  30896. return nil
  30897. case usagetotal.FieldTotalTokens:
  30898. m.ResetTotalTokens()
  30899. return nil
  30900. case usagetotal.FieldStartIndex:
  30901. m.ResetStartIndex()
  30902. return nil
  30903. case usagetotal.FieldEndIndex:
  30904. m.ResetEndIndex()
  30905. return nil
  30906. case usagetotal.FieldOrganizationID:
  30907. m.ResetOrganizationID()
  30908. return nil
  30909. }
  30910. return fmt.Errorf("unknown UsageTotal field %s", name)
  30911. }
  30912. // AddedEdges returns all edge names that were set/added in this mutation.
  30913. func (m *UsageTotalMutation) AddedEdges() []string {
  30914. edges := make([]string, 0, 0)
  30915. return edges
  30916. }
  30917. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30918. // name in this mutation.
  30919. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  30920. return nil
  30921. }
  30922. // RemovedEdges returns all edge names that were removed in this mutation.
  30923. func (m *UsageTotalMutation) RemovedEdges() []string {
  30924. edges := make([]string, 0, 0)
  30925. return edges
  30926. }
  30927. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30928. // the given name in this mutation.
  30929. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  30930. return nil
  30931. }
  30932. // ClearedEdges returns all edge names that were cleared in this mutation.
  30933. func (m *UsageTotalMutation) ClearedEdges() []string {
  30934. edges := make([]string, 0, 0)
  30935. return edges
  30936. }
  30937. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30938. // was cleared in this mutation.
  30939. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  30940. return false
  30941. }
  30942. // ClearEdge clears the value of the edge with the given name. It returns an error
  30943. // if that edge is not defined in the schema.
  30944. func (m *UsageTotalMutation) ClearEdge(name string) error {
  30945. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  30946. }
  30947. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30948. // It returns an error if the edge is not defined in the schema.
  30949. func (m *UsageTotalMutation) ResetEdge(name string) error {
  30950. return fmt.Errorf("unknown UsageTotal edge %s", name)
  30951. }
  30952. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  30953. type WorkExperienceMutation struct {
  30954. config
  30955. op Op
  30956. typ string
  30957. id *uint64
  30958. created_at *time.Time
  30959. updated_at *time.Time
  30960. deleted_at *time.Time
  30961. start_date *time.Time
  30962. end_date *time.Time
  30963. company *string
  30964. experience *string
  30965. organization_id *uint64
  30966. addorganization_id *int64
  30967. clearedFields map[string]struct{}
  30968. employee *uint64
  30969. clearedemployee bool
  30970. done bool
  30971. oldValue func(context.Context) (*WorkExperience, error)
  30972. predicates []predicate.WorkExperience
  30973. }
  30974. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  30975. // workexperienceOption allows management of the mutation configuration using functional options.
  30976. type workexperienceOption func(*WorkExperienceMutation)
  30977. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  30978. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  30979. m := &WorkExperienceMutation{
  30980. config: c,
  30981. op: op,
  30982. typ: TypeWorkExperience,
  30983. clearedFields: make(map[string]struct{}),
  30984. }
  30985. for _, opt := range opts {
  30986. opt(m)
  30987. }
  30988. return m
  30989. }
  30990. // withWorkExperienceID sets the ID field of the mutation.
  30991. func withWorkExperienceID(id uint64) workexperienceOption {
  30992. return func(m *WorkExperienceMutation) {
  30993. var (
  30994. err error
  30995. once sync.Once
  30996. value *WorkExperience
  30997. )
  30998. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  30999. once.Do(func() {
  31000. if m.done {
  31001. err = errors.New("querying old values post mutation is not allowed")
  31002. } else {
  31003. value, err = m.Client().WorkExperience.Get(ctx, id)
  31004. }
  31005. })
  31006. return value, err
  31007. }
  31008. m.id = &id
  31009. }
  31010. }
  31011. // withWorkExperience sets the old WorkExperience of the mutation.
  31012. func withWorkExperience(node *WorkExperience) workexperienceOption {
  31013. return func(m *WorkExperienceMutation) {
  31014. m.oldValue = func(context.Context) (*WorkExperience, error) {
  31015. return node, nil
  31016. }
  31017. m.id = &node.ID
  31018. }
  31019. }
  31020. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31021. // executed in a transaction (ent.Tx), a transactional client is returned.
  31022. func (m WorkExperienceMutation) Client() *Client {
  31023. client := &Client{config: m.config}
  31024. client.init()
  31025. return client
  31026. }
  31027. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31028. // it returns an error otherwise.
  31029. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  31030. if _, ok := m.driver.(*txDriver); !ok {
  31031. return nil, errors.New("ent: mutation is not running in a transaction")
  31032. }
  31033. tx := &Tx{config: m.config}
  31034. tx.init()
  31035. return tx, nil
  31036. }
  31037. // SetID sets the value of the id field. Note that this
  31038. // operation is only accepted on creation of WorkExperience entities.
  31039. func (m *WorkExperienceMutation) SetID(id uint64) {
  31040. m.id = &id
  31041. }
  31042. // ID returns the ID value in the mutation. Note that the ID is only available
  31043. // if it was provided to the builder or after it was returned from the database.
  31044. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  31045. if m.id == nil {
  31046. return
  31047. }
  31048. return *m.id, true
  31049. }
  31050. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31051. // That means, if the mutation is applied within a transaction with an isolation level such
  31052. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31053. // or updated by the mutation.
  31054. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  31055. switch {
  31056. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31057. id, exists := m.ID()
  31058. if exists {
  31059. return []uint64{id}, nil
  31060. }
  31061. fallthrough
  31062. case m.op.Is(OpUpdate | OpDelete):
  31063. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  31064. default:
  31065. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31066. }
  31067. }
  31068. // SetCreatedAt sets the "created_at" field.
  31069. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  31070. m.created_at = &t
  31071. }
  31072. // CreatedAt returns the value of the "created_at" field in the mutation.
  31073. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  31074. v := m.created_at
  31075. if v == nil {
  31076. return
  31077. }
  31078. return *v, true
  31079. }
  31080. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  31081. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31083. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31084. if !m.op.Is(OpUpdateOne) {
  31085. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31086. }
  31087. if m.id == nil || m.oldValue == nil {
  31088. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31089. }
  31090. oldValue, err := m.oldValue(ctx)
  31091. if err != nil {
  31092. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31093. }
  31094. return oldValue.CreatedAt, nil
  31095. }
  31096. // ResetCreatedAt resets all changes to the "created_at" field.
  31097. func (m *WorkExperienceMutation) ResetCreatedAt() {
  31098. m.created_at = nil
  31099. }
  31100. // SetUpdatedAt sets the "updated_at" field.
  31101. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  31102. m.updated_at = &t
  31103. }
  31104. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31105. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  31106. v := m.updated_at
  31107. if v == nil {
  31108. return
  31109. }
  31110. return *v, true
  31111. }
  31112. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  31113. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31115. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31116. if !m.op.Is(OpUpdateOne) {
  31117. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31118. }
  31119. if m.id == nil || m.oldValue == nil {
  31120. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31121. }
  31122. oldValue, err := m.oldValue(ctx)
  31123. if err != nil {
  31124. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31125. }
  31126. return oldValue.UpdatedAt, nil
  31127. }
  31128. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31129. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  31130. m.updated_at = nil
  31131. }
  31132. // SetDeletedAt sets the "deleted_at" field.
  31133. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  31134. m.deleted_at = &t
  31135. }
  31136. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31137. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  31138. v := m.deleted_at
  31139. if v == nil {
  31140. return
  31141. }
  31142. return *v, true
  31143. }
  31144. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  31145. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31147. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31148. if !m.op.Is(OpUpdateOne) {
  31149. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31150. }
  31151. if m.id == nil || m.oldValue == nil {
  31152. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31153. }
  31154. oldValue, err := m.oldValue(ctx)
  31155. if err != nil {
  31156. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31157. }
  31158. return oldValue.DeletedAt, nil
  31159. }
  31160. // ClearDeletedAt clears the value of the "deleted_at" field.
  31161. func (m *WorkExperienceMutation) ClearDeletedAt() {
  31162. m.deleted_at = nil
  31163. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  31164. }
  31165. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31166. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  31167. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  31168. return ok
  31169. }
  31170. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31171. func (m *WorkExperienceMutation) ResetDeletedAt() {
  31172. m.deleted_at = nil
  31173. delete(m.clearedFields, workexperience.FieldDeletedAt)
  31174. }
  31175. // SetEmployeeID sets the "employee_id" field.
  31176. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  31177. m.employee = &u
  31178. }
  31179. // EmployeeID returns the value of the "employee_id" field in the mutation.
  31180. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  31181. v := m.employee
  31182. if v == nil {
  31183. return
  31184. }
  31185. return *v, true
  31186. }
  31187. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  31188. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31190. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  31191. if !m.op.Is(OpUpdateOne) {
  31192. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  31193. }
  31194. if m.id == nil || m.oldValue == nil {
  31195. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  31196. }
  31197. oldValue, err := m.oldValue(ctx)
  31198. if err != nil {
  31199. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  31200. }
  31201. return oldValue.EmployeeID, nil
  31202. }
  31203. // ResetEmployeeID resets all changes to the "employee_id" field.
  31204. func (m *WorkExperienceMutation) ResetEmployeeID() {
  31205. m.employee = nil
  31206. }
  31207. // SetStartDate sets the "start_date" field.
  31208. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  31209. m.start_date = &t
  31210. }
  31211. // StartDate returns the value of the "start_date" field in the mutation.
  31212. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  31213. v := m.start_date
  31214. if v == nil {
  31215. return
  31216. }
  31217. return *v, true
  31218. }
  31219. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  31220. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31222. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  31223. if !m.op.Is(OpUpdateOne) {
  31224. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  31225. }
  31226. if m.id == nil || m.oldValue == nil {
  31227. return v, errors.New("OldStartDate requires an ID field in the mutation")
  31228. }
  31229. oldValue, err := m.oldValue(ctx)
  31230. if err != nil {
  31231. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  31232. }
  31233. return oldValue.StartDate, nil
  31234. }
  31235. // ResetStartDate resets all changes to the "start_date" field.
  31236. func (m *WorkExperienceMutation) ResetStartDate() {
  31237. m.start_date = nil
  31238. }
  31239. // SetEndDate sets the "end_date" field.
  31240. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  31241. m.end_date = &t
  31242. }
  31243. // EndDate returns the value of the "end_date" field in the mutation.
  31244. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  31245. v := m.end_date
  31246. if v == nil {
  31247. return
  31248. }
  31249. return *v, true
  31250. }
  31251. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  31252. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31254. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  31255. if !m.op.Is(OpUpdateOne) {
  31256. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  31257. }
  31258. if m.id == nil || m.oldValue == nil {
  31259. return v, errors.New("OldEndDate requires an ID field in the mutation")
  31260. }
  31261. oldValue, err := m.oldValue(ctx)
  31262. if err != nil {
  31263. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  31264. }
  31265. return oldValue.EndDate, nil
  31266. }
  31267. // ResetEndDate resets all changes to the "end_date" field.
  31268. func (m *WorkExperienceMutation) ResetEndDate() {
  31269. m.end_date = nil
  31270. }
  31271. // SetCompany sets the "company" field.
  31272. func (m *WorkExperienceMutation) SetCompany(s string) {
  31273. m.company = &s
  31274. }
  31275. // Company returns the value of the "company" field in the mutation.
  31276. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  31277. v := m.company
  31278. if v == nil {
  31279. return
  31280. }
  31281. return *v, true
  31282. }
  31283. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  31284. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31286. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  31287. if !m.op.Is(OpUpdateOne) {
  31288. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  31289. }
  31290. if m.id == nil || m.oldValue == nil {
  31291. return v, errors.New("OldCompany requires an ID field in the mutation")
  31292. }
  31293. oldValue, err := m.oldValue(ctx)
  31294. if err != nil {
  31295. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  31296. }
  31297. return oldValue.Company, nil
  31298. }
  31299. // ResetCompany resets all changes to the "company" field.
  31300. func (m *WorkExperienceMutation) ResetCompany() {
  31301. m.company = nil
  31302. }
  31303. // SetExperience sets the "experience" field.
  31304. func (m *WorkExperienceMutation) SetExperience(s string) {
  31305. m.experience = &s
  31306. }
  31307. // Experience returns the value of the "experience" field in the mutation.
  31308. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  31309. v := m.experience
  31310. if v == nil {
  31311. return
  31312. }
  31313. return *v, true
  31314. }
  31315. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  31316. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31318. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  31319. if !m.op.Is(OpUpdateOne) {
  31320. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  31321. }
  31322. if m.id == nil || m.oldValue == nil {
  31323. return v, errors.New("OldExperience requires an ID field in the mutation")
  31324. }
  31325. oldValue, err := m.oldValue(ctx)
  31326. if err != nil {
  31327. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  31328. }
  31329. return oldValue.Experience, nil
  31330. }
  31331. // ResetExperience resets all changes to the "experience" field.
  31332. func (m *WorkExperienceMutation) ResetExperience() {
  31333. m.experience = nil
  31334. }
  31335. // SetOrganizationID sets the "organization_id" field.
  31336. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  31337. m.organization_id = &u
  31338. m.addorganization_id = nil
  31339. }
  31340. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31341. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  31342. v := m.organization_id
  31343. if v == nil {
  31344. return
  31345. }
  31346. return *v, true
  31347. }
  31348. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  31349. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  31350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31351. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31352. if !m.op.Is(OpUpdateOne) {
  31353. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31354. }
  31355. if m.id == nil || m.oldValue == nil {
  31356. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31357. }
  31358. oldValue, err := m.oldValue(ctx)
  31359. if err != nil {
  31360. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31361. }
  31362. return oldValue.OrganizationID, nil
  31363. }
  31364. // AddOrganizationID adds u to the "organization_id" field.
  31365. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  31366. if m.addorganization_id != nil {
  31367. *m.addorganization_id += u
  31368. } else {
  31369. m.addorganization_id = &u
  31370. }
  31371. }
  31372. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31373. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  31374. v := m.addorganization_id
  31375. if v == nil {
  31376. return
  31377. }
  31378. return *v, true
  31379. }
  31380. // ResetOrganizationID resets all changes to the "organization_id" field.
  31381. func (m *WorkExperienceMutation) ResetOrganizationID() {
  31382. m.organization_id = nil
  31383. m.addorganization_id = nil
  31384. }
  31385. // ClearEmployee clears the "employee" edge to the Employee entity.
  31386. func (m *WorkExperienceMutation) ClearEmployee() {
  31387. m.clearedemployee = true
  31388. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  31389. }
  31390. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  31391. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  31392. return m.clearedemployee
  31393. }
  31394. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  31395. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  31396. // EmployeeID instead. It exists only for internal usage by the builders.
  31397. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  31398. if id := m.employee; id != nil {
  31399. ids = append(ids, *id)
  31400. }
  31401. return
  31402. }
  31403. // ResetEmployee resets all changes to the "employee" edge.
  31404. func (m *WorkExperienceMutation) ResetEmployee() {
  31405. m.employee = nil
  31406. m.clearedemployee = false
  31407. }
  31408. // Where appends a list predicates to the WorkExperienceMutation builder.
  31409. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  31410. m.predicates = append(m.predicates, ps...)
  31411. }
  31412. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  31413. // users can use type-assertion to append predicates that do not depend on any generated package.
  31414. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  31415. p := make([]predicate.WorkExperience, len(ps))
  31416. for i := range ps {
  31417. p[i] = ps[i]
  31418. }
  31419. m.Where(p...)
  31420. }
  31421. // Op returns the operation name.
  31422. func (m *WorkExperienceMutation) Op() Op {
  31423. return m.op
  31424. }
  31425. // SetOp allows setting the mutation operation.
  31426. func (m *WorkExperienceMutation) SetOp(op Op) {
  31427. m.op = op
  31428. }
  31429. // Type returns the node type of this mutation (WorkExperience).
  31430. func (m *WorkExperienceMutation) Type() string {
  31431. return m.typ
  31432. }
  31433. // Fields returns all fields that were changed during this mutation. Note that in
  31434. // order to get all numeric fields that were incremented/decremented, call
  31435. // AddedFields().
  31436. func (m *WorkExperienceMutation) Fields() []string {
  31437. fields := make([]string, 0, 9)
  31438. if m.created_at != nil {
  31439. fields = append(fields, workexperience.FieldCreatedAt)
  31440. }
  31441. if m.updated_at != nil {
  31442. fields = append(fields, workexperience.FieldUpdatedAt)
  31443. }
  31444. if m.deleted_at != nil {
  31445. fields = append(fields, workexperience.FieldDeletedAt)
  31446. }
  31447. if m.employee != nil {
  31448. fields = append(fields, workexperience.FieldEmployeeID)
  31449. }
  31450. if m.start_date != nil {
  31451. fields = append(fields, workexperience.FieldStartDate)
  31452. }
  31453. if m.end_date != nil {
  31454. fields = append(fields, workexperience.FieldEndDate)
  31455. }
  31456. if m.company != nil {
  31457. fields = append(fields, workexperience.FieldCompany)
  31458. }
  31459. if m.experience != nil {
  31460. fields = append(fields, workexperience.FieldExperience)
  31461. }
  31462. if m.organization_id != nil {
  31463. fields = append(fields, workexperience.FieldOrganizationID)
  31464. }
  31465. return fields
  31466. }
  31467. // Field returns the value of a field with the given name. The second boolean
  31468. // return value indicates that this field was not set, or was not defined in the
  31469. // schema.
  31470. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  31471. switch name {
  31472. case workexperience.FieldCreatedAt:
  31473. return m.CreatedAt()
  31474. case workexperience.FieldUpdatedAt:
  31475. return m.UpdatedAt()
  31476. case workexperience.FieldDeletedAt:
  31477. return m.DeletedAt()
  31478. case workexperience.FieldEmployeeID:
  31479. return m.EmployeeID()
  31480. case workexperience.FieldStartDate:
  31481. return m.StartDate()
  31482. case workexperience.FieldEndDate:
  31483. return m.EndDate()
  31484. case workexperience.FieldCompany:
  31485. return m.Company()
  31486. case workexperience.FieldExperience:
  31487. return m.Experience()
  31488. case workexperience.FieldOrganizationID:
  31489. return m.OrganizationID()
  31490. }
  31491. return nil, false
  31492. }
  31493. // OldField returns the old value of the field from the database. An error is
  31494. // returned if the mutation operation is not UpdateOne, or the query to the
  31495. // database failed.
  31496. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31497. switch name {
  31498. case workexperience.FieldCreatedAt:
  31499. return m.OldCreatedAt(ctx)
  31500. case workexperience.FieldUpdatedAt:
  31501. return m.OldUpdatedAt(ctx)
  31502. case workexperience.FieldDeletedAt:
  31503. return m.OldDeletedAt(ctx)
  31504. case workexperience.FieldEmployeeID:
  31505. return m.OldEmployeeID(ctx)
  31506. case workexperience.FieldStartDate:
  31507. return m.OldStartDate(ctx)
  31508. case workexperience.FieldEndDate:
  31509. return m.OldEndDate(ctx)
  31510. case workexperience.FieldCompany:
  31511. return m.OldCompany(ctx)
  31512. case workexperience.FieldExperience:
  31513. return m.OldExperience(ctx)
  31514. case workexperience.FieldOrganizationID:
  31515. return m.OldOrganizationID(ctx)
  31516. }
  31517. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  31518. }
  31519. // SetField sets the value of a field with the given name. It returns an error if
  31520. // the field is not defined in the schema, or if the type mismatched the field
  31521. // type.
  31522. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  31523. switch name {
  31524. case workexperience.FieldCreatedAt:
  31525. v, ok := value.(time.Time)
  31526. if !ok {
  31527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31528. }
  31529. m.SetCreatedAt(v)
  31530. return nil
  31531. case workexperience.FieldUpdatedAt:
  31532. v, ok := value.(time.Time)
  31533. if !ok {
  31534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31535. }
  31536. m.SetUpdatedAt(v)
  31537. return nil
  31538. case workexperience.FieldDeletedAt:
  31539. v, ok := value.(time.Time)
  31540. if !ok {
  31541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31542. }
  31543. m.SetDeletedAt(v)
  31544. return nil
  31545. case workexperience.FieldEmployeeID:
  31546. v, ok := value.(uint64)
  31547. if !ok {
  31548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31549. }
  31550. m.SetEmployeeID(v)
  31551. return nil
  31552. case workexperience.FieldStartDate:
  31553. v, ok := value.(time.Time)
  31554. if !ok {
  31555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31556. }
  31557. m.SetStartDate(v)
  31558. return nil
  31559. case workexperience.FieldEndDate:
  31560. v, ok := value.(time.Time)
  31561. if !ok {
  31562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31563. }
  31564. m.SetEndDate(v)
  31565. return nil
  31566. case workexperience.FieldCompany:
  31567. v, ok := value.(string)
  31568. if !ok {
  31569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31570. }
  31571. m.SetCompany(v)
  31572. return nil
  31573. case workexperience.FieldExperience:
  31574. v, ok := value.(string)
  31575. if !ok {
  31576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31577. }
  31578. m.SetExperience(v)
  31579. return nil
  31580. case workexperience.FieldOrganizationID:
  31581. v, ok := value.(uint64)
  31582. if !ok {
  31583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31584. }
  31585. m.SetOrganizationID(v)
  31586. return nil
  31587. }
  31588. return fmt.Errorf("unknown WorkExperience field %s", name)
  31589. }
  31590. // AddedFields returns all numeric fields that were incremented/decremented during
  31591. // this mutation.
  31592. func (m *WorkExperienceMutation) AddedFields() []string {
  31593. var fields []string
  31594. if m.addorganization_id != nil {
  31595. fields = append(fields, workexperience.FieldOrganizationID)
  31596. }
  31597. return fields
  31598. }
  31599. // AddedField returns the numeric value that was incremented/decremented on a field
  31600. // with the given name. The second boolean return value indicates that this field
  31601. // was not set, or was not defined in the schema.
  31602. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  31603. switch name {
  31604. case workexperience.FieldOrganizationID:
  31605. return m.AddedOrganizationID()
  31606. }
  31607. return nil, false
  31608. }
  31609. // AddField adds the value to the field with the given name. It returns an error if
  31610. // the field is not defined in the schema, or if the type mismatched the field
  31611. // type.
  31612. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  31613. switch name {
  31614. case workexperience.FieldOrganizationID:
  31615. v, ok := value.(int64)
  31616. if !ok {
  31617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31618. }
  31619. m.AddOrganizationID(v)
  31620. return nil
  31621. }
  31622. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  31623. }
  31624. // ClearedFields returns all nullable fields that were cleared during this
  31625. // mutation.
  31626. func (m *WorkExperienceMutation) ClearedFields() []string {
  31627. var fields []string
  31628. if m.FieldCleared(workexperience.FieldDeletedAt) {
  31629. fields = append(fields, workexperience.FieldDeletedAt)
  31630. }
  31631. return fields
  31632. }
  31633. // FieldCleared returns a boolean indicating if a field with the given name was
  31634. // cleared in this mutation.
  31635. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  31636. _, ok := m.clearedFields[name]
  31637. return ok
  31638. }
  31639. // ClearField clears the value of the field with the given name. It returns an
  31640. // error if the field is not defined in the schema.
  31641. func (m *WorkExperienceMutation) ClearField(name string) error {
  31642. switch name {
  31643. case workexperience.FieldDeletedAt:
  31644. m.ClearDeletedAt()
  31645. return nil
  31646. }
  31647. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  31648. }
  31649. // ResetField resets all changes in the mutation for the field with the given name.
  31650. // It returns an error if the field is not defined in the schema.
  31651. func (m *WorkExperienceMutation) ResetField(name string) error {
  31652. switch name {
  31653. case workexperience.FieldCreatedAt:
  31654. m.ResetCreatedAt()
  31655. return nil
  31656. case workexperience.FieldUpdatedAt:
  31657. m.ResetUpdatedAt()
  31658. return nil
  31659. case workexperience.FieldDeletedAt:
  31660. m.ResetDeletedAt()
  31661. return nil
  31662. case workexperience.FieldEmployeeID:
  31663. m.ResetEmployeeID()
  31664. return nil
  31665. case workexperience.FieldStartDate:
  31666. m.ResetStartDate()
  31667. return nil
  31668. case workexperience.FieldEndDate:
  31669. m.ResetEndDate()
  31670. return nil
  31671. case workexperience.FieldCompany:
  31672. m.ResetCompany()
  31673. return nil
  31674. case workexperience.FieldExperience:
  31675. m.ResetExperience()
  31676. return nil
  31677. case workexperience.FieldOrganizationID:
  31678. m.ResetOrganizationID()
  31679. return nil
  31680. }
  31681. return fmt.Errorf("unknown WorkExperience field %s", name)
  31682. }
  31683. // AddedEdges returns all edge names that were set/added in this mutation.
  31684. func (m *WorkExperienceMutation) AddedEdges() []string {
  31685. edges := make([]string, 0, 1)
  31686. if m.employee != nil {
  31687. edges = append(edges, workexperience.EdgeEmployee)
  31688. }
  31689. return edges
  31690. }
  31691. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31692. // name in this mutation.
  31693. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  31694. switch name {
  31695. case workexperience.EdgeEmployee:
  31696. if id := m.employee; id != nil {
  31697. return []ent.Value{*id}
  31698. }
  31699. }
  31700. return nil
  31701. }
  31702. // RemovedEdges returns all edge names that were removed in this mutation.
  31703. func (m *WorkExperienceMutation) RemovedEdges() []string {
  31704. edges := make([]string, 0, 1)
  31705. return edges
  31706. }
  31707. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31708. // the given name in this mutation.
  31709. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  31710. return nil
  31711. }
  31712. // ClearedEdges returns all edge names that were cleared in this mutation.
  31713. func (m *WorkExperienceMutation) ClearedEdges() []string {
  31714. edges := make([]string, 0, 1)
  31715. if m.clearedemployee {
  31716. edges = append(edges, workexperience.EdgeEmployee)
  31717. }
  31718. return edges
  31719. }
  31720. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31721. // was cleared in this mutation.
  31722. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  31723. switch name {
  31724. case workexperience.EdgeEmployee:
  31725. return m.clearedemployee
  31726. }
  31727. return false
  31728. }
  31729. // ClearEdge clears the value of the edge with the given name. It returns an error
  31730. // if that edge is not defined in the schema.
  31731. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  31732. switch name {
  31733. case workexperience.EdgeEmployee:
  31734. m.ClearEmployee()
  31735. return nil
  31736. }
  31737. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  31738. }
  31739. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31740. // It returns an error if the edge is not defined in the schema.
  31741. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  31742. switch name {
  31743. case workexperience.EdgeEmployee:
  31744. m.ResetEmployee()
  31745. return nil
  31746. }
  31747. return fmt.Errorf("unknown WorkExperience edge %s", name)
  31748. }
  31749. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  31750. type WpChatroomMutation struct {
  31751. config
  31752. op Op
  31753. typ string
  31754. id *uint64
  31755. created_at *time.Time
  31756. updated_at *time.Time
  31757. status *uint8
  31758. addstatus *int8
  31759. wx_wxid *string
  31760. chatroom_id *string
  31761. nickname *string
  31762. owner *string
  31763. avatar *string
  31764. member_list *[]string
  31765. appendmember_list []string
  31766. clearedFields map[string]struct{}
  31767. done bool
  31768. oldValue func(context.Context) (*WpChatroom, error)
  31769. predicates []predicate.WpChatroom
  31770. }
  31771. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  31772. // wpchatroomOption allows management of the mutation configuration using functional options.
  31773. type wpchatroomOption func(*WpChatroomMutation)
  31774. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  31775. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  31776. m := &WpChatroomMutation{
  31777. config: c,
  31778. op: op,
  31779. typ: TypeWpChatroom,
  31780. clearedFields: make(map[string]struct{}),
  31781. }
  31782. for _, opt := range opts {
  31783. opt(m)
  31784. }
  31785. return m
  31786. }
  31787. // withWpChatroomID sets the ID field of the mutation.
  31788. func withWpChatroomID(id uint64) wpchatroomOption {
  31789. return func(m *WpChatroomMutation) {
  31790. var (
  31791. err error
  31792. once sync.Once
  31793. value *WpChatroom
  31794. )
  31795. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  31796. once.Do(func() {
  31797. if m.done {
  31798. err = errors.New("querying old values post mutation is not allowed")
  31799. } else {
  31800. value, err = m.Client().WpChatroom.Get(ctx, id)
  31801. }
  31802. })
  31803. return value, err
  31804. }
  31805. m.id = &id
  31806. }
  31807. }
  31808. // withWpChatroom sets the old WpChatroom of the mutation.
  31809. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  31810. return func(m *WpChatroomMutation) {
  31811. m.oldValue = func(context.Context) (*WpChatroom, error) {
  31812. return node, nil
  31813. }
  31814. m.id = &node.ID
  31815. }
  31816. }
  31817. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31818. // executed in a transaction (ent.Tx), a transactional client is returned.
  31819. func (m WpChatroomMutation) Client() *Client {
  31820. client := &Client{config: m.config}
  31821. client.init()
  31822. return client
  31823. }
  31824. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31825. // it returns an error otherwise.
  31826. func (m WpChatroomMutation) Tx() (*Tx, error) {
  31827. if _, ok := m.driver.(*txDriver); !ok {
  31828. return nil, errors.New("ent: mutation is not running in a transaction")
  31829. }
  31830. tx := &Tx{config: m.config}
  31831. tx.init()
  31832. return tx, nil
  31833. }
  31834. // SetID sets the value of the id field. Note that this
  31835. // operation is only accepted on creation of WpChatroom entities.
  31836. func (m *WpChatroomMutation) SetID(id uint64) {
  31837. m.id = &id
  31838. }
  31839. // ID returns the ID value in the mutation. Note that the ID is only available
  31840. // if it was provided to the builder or after it was returned from the database.
  31841. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  31842. if m.id == nil {
  31843. return
  31844. }
  31845. return *m.id, true
  31846. }
  31847. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31848. // That means, if the mutation is applied within a transaction with an isolation level such
  31849. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31850. // or updated by the mutation.
  31851. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  31852. switch {
  31853. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31854. id, exists := m.ID()
  31855. if exists {
  31856. return []uint64{id}, nil
  31857. }
  31858. fallthrough
  31859. case m.op.Is(OpUpdate | OpDelete):
  31860. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  31861. default:
  31862. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31863. }
  31864. }
  31865. // SetCreatedAt sets the "created_at" field.
  31866. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  31867. m.created_at = &t
  31868. }
  31869. // CreatedAt returns the value of the "created_at" field in the mutation.
  31870. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  31871. v := m.created_at
  31872. if v == nil {
  31873. return
  31874. }
  31875. return *v, true
  31876. }
  31877. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  31878. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31880. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31881. if !m.op.Is(OpUpdateOne) {
  31882. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31883. }
  31884. if m.id == nil || m.oldValue == nil {
  31885. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31886. }
  31887. oldValue, err := m.oldValue(ctx)
  31888. if err != nil {
  31889. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31890. }
  31891. return oldValue.CreatedAt, nil
  31892. }
  31893. // ResetCreatedAt resets all changes to the "created_at" field.
  31894. func (m *WpChatroomMutation) ResetCreatedAt() {
  31895. m.created_at = nil
  31896. }
  31897. // SetUpdatedAt sets the "updated_at" field.
  31898. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  31899. m.updated_at = &t
  31900. }
  31901. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31902. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  31903. v := m.updated_at
  31904. if v == nil {
  31905. return
  31906. }
  31907. return *v, true
  31908. }
  31909. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  31910. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31912. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31913. if !m.op.Is(OpUpdateOne) {
  31914. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31915. }
  31916. if m.id == nil || m.oldValue == nil {
  31917. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31918. }
  31919. oldValue, err := m.oldValue(ctx)
  31920. if err != nil {
  31921. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31922. }
  31923. return oldValue.UpdatedAt, nil
  31924. }
  31925. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31926. func (m *WpChatroomMutation) ResetUpdatedAt() {
  31927. m.updated_at = nil
  31928. }
  31929. // SetStatus sets the "status" field.
  31930. func (m *WpChatroomMutation) SetStatus(u uint8) {
  31931. m.status = &u
  31932. m.addstatus = nil
  31933. }
  31934. // Status returns the value of the "status" field in the mutation.
  31935. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  31936. v := m.status
  31937. if v == nil {
  31938. return
  31939. }
  31940. return *v, true
  31941. }
  31942. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  31943. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31945. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31946. if !m.op.Is(OpUpdateOne) {
  31947. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31948. }
  31949. if m.id == nil || m.oldValue == nil {
  31950. return v, errors.New("OldStatus requires an ID field in the mutation")
  31951. }
  31952. oldValue, err := m.oldValue(ctx)
  31953. if err != nil {
  31954. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31955. }
  31956. return oldValue.Status, nil
  31957. }
  31958. // AddStatus adds u to the "status" field.
  31959. func (m *WpChatroomMutation) AddStatus(u int8) {
  31960. if m.addstatus != nil {
  31961. *m.addstatus += u
  31962. } else {
  31963. m.addstatus = &u
  31964. }
  31965. }
  31966. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31967. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  31968. v := m.addstatus
  31969. if v == nil {
  31970. return
  31971. }
  31972. return *v, true
  31973. }
  31974. // ClearStatus clears the value of the "status" field.
  31975. func (m *WpChatroomMutation) ClearStatus() {
  31976. m.status = nil
  31977. m.addstatus = nil
  31978. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  31979. }
  31980. // StatusCleared returns if the "status" field was cleared in this mutation.
  31981. func (m *WpChatroomMutation) StatusCleared() bool {
  31982. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  31983. return ok
  31984. }
  31985. // ResetStatus resets all changes to the "status" field.
  31986. func (m *WpChatroomMutation) ResetStatus() {
  31987. m.status = nil
  31988. m.addstatus = nil
  31989. delete(m.clearedFields, wpchatroom.FieldStatus)
  31990. }
  31991. // SetWxWxid sets the "wx_wxid" field.
  31992. func (m *WpChatroomMutation) SetWxWxid(s string) {
  31993. m.wx_wxid = &s
  31994. }
  31995. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  31996. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  31997. v := m.wx_wxid
  31998. if v == nil {
  31999. return
  32000. }
  32001. return *v, true
  32002. }
  32003. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  32004. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32006. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  32007. if !m.op.Is(OpUpdateOne) {
  32008. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  32009. }
  32010. if m.id == nil || m.oldValue == nil {
  32011. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  32012. }
  32013. oldValue, err := m.oldValue(ctx)
  32014. if err != nil {
  32015. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  32016. }
  32017. return oldValue.WxWxid, nil
  32018. }
  32019. // ResetWxWxid resets all changes to the "wx_wxid" field.
  32020. func (m *WpChatroomMutation) ResetWxWxid() {
  32021. m.wx_wxid = nil
  32022. }
  32023. // SetChatroomID sets the "chatroom_id" field.
  32024. func (m *WpChatroomMutation) SetChatroomID(s string) {
  32025. m.chatroom_id = &s
  32026. }
  32027. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  32028. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  32029. v := m.chatroom_id
  32030. if v == nil {
  32031. return
  32032. }
  32033. return *v, true
  32034. }
  32035. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  32036. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32038. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  32039. if !m.op.Is(OpUpdateOne) {
  32040. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  32041. }
  32042. if m.id == nil || m.oldValue == nil {
  32043. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  32044. }
  32045. oldValue, err := m.oldValue(ctx)
  32046. if err != nil {
  32047. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  32048. }
  32049. return oldValue.ChatroomID, nil
  32050. }
  32051. // ResetChatroomID resets all changes to the "chatroom_id" field.
  32052. func (m *WpChatroomMutation) ResetChatroomID() {
  32053. m.chatroom_id = nil
  32054. }
  32055. // SetNickname sets the "nickname" field.
  32056. func (m *WpChatroomMutation) SetNickname(s string) {
  32057. m.nickname = &s
  32058. }
  32059. // Nickname returns the value of the "nickname" field in the mutation.
  32060. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  32061. v := m.nickname
  32062. if v == nil {
  32063. return
  32064. }
  32065. return *v, true
  32066. }
  32067. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  32068. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32070. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  32071. if !m.op.Is(OpUpdateOne) {
  32072. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32073. }
  32074. if m.id == nil || m.oldValue == nil {
  32075. return v, errors.New("OldNickname requires an ID field in the mutation")
  32076. }
  32077. oldValue, err := m.oldValue(ctx)
  32078. if err != nil {
  32079. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32080. }
  32081. return oldValue.Nickname, nil
  32082. }
  32083. // ResetNickname resets all changes to the "nickname" field.
  32084. func (m *WpChatroomMutation) ResetNickname() {
  32085. m.nickname = nil
  32086. }
  32087. // SetOwner sets the "owner" field.
  32088. func (m *WpChatroomMutation) SetOwner(s string) {
  32089. m.owner = &s
  32090. }
  32091. // Owner returns the value of the "owner" field in the mutation.
  32092. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  32093. v := m.owner
  32094. if v == nil {
  32095. return
  32096. }
  32097. return *v, true
  32098. }
  32099. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  32100. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32102. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  32103. if !m.op.Is(OpUpdateOne) {
  32104. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  32105. }
  32106. if m.id == nil || m.oldValue == nil {
  32107. return v, errors.New("OldOwner requires an ID field in the mutation")
  32108. }
  32109. oldValue, err := m.oldValue(ctx)
  32110. if err != nil {
  32111. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  32112. }
  32113. return oldValue.Owner, nil
  32114. }
  32115. // ResetOwner resets all changes to the "owner" field.
  32116. func (m *WpChatroomMutation) ResetOwner() {
  32117. m.owner = nil
  32118. }
  32119. // SetAvatar sets the "avatar" field.
  32120. func (m *WpChatroomMutation) SetAvatar(s string) {
  32121. m.avatar = &s
  32122. }
  32123. // Avatar returns the value of the "avatar" field in the mutation.
  32124. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  32125. v := m.avatar
  32126. if v == nil {
  32127. return
  32128. }
  32129. return *v, true
  32130. }
  32131. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  32132. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32134. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  32135. if !m.op.Is(OpUpdateOne) {
  32136. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  32137. }
  32138. if m.id == nil || m.oldValue == nil {
  32139. return v, errors.New("OldAvatar requires an ID field in the mutation")
  32140. }
  32141. oldValue, err := m.oldValue(ctx)
  32142. if err != nil {
  32143. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  32144. }
  32145. return oldValue.Avatar, nil
  32146. }
  32147. // ResetAvatar resets all changes to the "avatar" field.
  32148. func (m *WpChatroomMutation) ResetAvatar() {
  32149. m.avatar = nil
  32150. }
  32151. // SetMemberList sets the "member_list" field.
  32152. func (m *WpChatroomMutation) SetMemberList(s []string) {
  32153. m.member_list = &s
  32154. m.appendmember_list = nil
  32155. }
  32156. // MemberList returns the value of the "member_list" field in the mutation.
  32157. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  32158. v := m.member_list
  32159. if v == nil {
  32160. return
  32161. }
  32162. return *v, true
  32163. }
  32164. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  32165. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  32166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32167. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  32168. if !m.op.Is(OpUpdateOne) {
  32169. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  32170. }
  32171. if m.id == nil || m.oldValue == nil {
  32172. return v, errors.New("OldMemberList requires an ID field in the mutation")
  32173. }
  32174. oldValue, err := m.oldValue(ctx)
  32175. if err != nil {
  32176. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  32177. }
  32178. return oldValue.MemberList, nil
  32179. }
  32180. // AppendMemberList adds s to the "member_list" field.
  32181. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  32182. m.appendmember_list = append(m.appendmember_list, s...)
  32183. }
  32184. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  32185. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  32186. if len(m.appendmember_list) == 0 {
  32187. return nil, false
  32188. }
  32189. return m.appendmember_list, true
  32190. }
  32191. // ResetMemberList resets all changes to the "member_list" field.
  32192. func (m *WpChatroomMutation) ResetMemberList() {
  32193. m.member_list = nil
  32194. m.appendmember_list = nil
  32195. }
  32196. // Where appends a list predicates to the WpChatroomMutation builder.
  32197. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  32198. m.predicates = append(m.predicates, ps...)
  32199. }
  32200. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  32201. // users can use type-assertion to append predicates that do not depend on any generated package.
  32202. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  32203. p := make([]predicate.WpChatroom, len(ps))
  32204. for i := range ps {
  32205. p[i] = ps[i]
  32206. }
  32207. m.Where(p...)
  32208. }
  32209. // Op returns the operation name.
  32210. func (m *WpChatroomMutation) Op() Op {
  32211. return m.op
  32212. }
  32213. // SetOp allows setting the mutation operation.
  32214. func (m *WpChatroomMutation) SetOp(op Op) {
  32215. m.op = op
  32216. }
  32217. // Type returns the node type of this mutation (WpChatroom).
  32218. func (m *WpChatroomMutation) Type() string {
  32219. return m.typ
  32220. }
  32221. // Fields returns all fields that were changed during this mutation. Note that in
  32222. // order to get all numeric fields that were incremented/decremented, call
  32223. // AddedFields().
  32224. func (m *WpChatroomMutation) Fields() []string {
  32225. fields := make([]string, 0, 9)
  32226. if m.created_at != nil {
  32227. fields = append(fields, wpchatroom.FieldCreatedAt)
  32228. }
  32229. if m.updated_at != nil {
  32230. fields = append(fields, wpchatroom.FieldUpdatedAt)
  32231. }
  32232. if m.status != nil {
  32233. fields = append(fields, wpchatroom.FieldStatus)
  32234. }
  32235. if m.wx_wxid != nil {
  32236. fields = append(fields, wpchatroom.FieldWxWxid)
  32237. }
  32238. if m.chatroom_id != nil {
  32239. fields = append(fields, wpchatroom.FieldChatroomID)
  32240. }
  32241. if m.nickname != nil {
  32242. fields = append(fields, wpchatroom.FieldNickname)
  32243. }
  32244. if m.owner != nil {
  32245. fields = append(fields, wpchatroom.FieldOwner)
  32246. }
  32247. if m.avatar != nil {
  32248. fields = append(fields, wpchatroom.FieldAvatar)
  32249. }
  32250. if m.member_list != nil {
  32251. fields = append(fields, wpchatroom.FieldMemberList)
  32252. }
  32253. return fields
  32254. }
  32255. // Field returns the value of a field with the given name. The second boolean
  32256. // return value indicates that this field was not set, or was not defined in the
  32257. // schema.
  32258. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  32259. switch name {
  32260. case wpchatroom.FieldCreatedAt:
  32261. return m.CreatedAt()
  32262. case wpchatroom.FieldUpdatedAt:
  32263. return m.UpdatedAt()
  32264. case wpchatroom.FieldStatus:
  32265. return m.Status()
  32266. case wpchatroom.FieldWxWxid:
  32267. return m.WxWxid()
  32268. case wpchatroom.FieldChatroomID:
  32269. return m.ChatroomID()
  32270. case wpchatroom.FieldNickname:
  32271. return m.Nickname()
  32272. case wpchatroom.FieldOwner:
  32273. return m.Owner()
  32274. case wpchatroom.FieldAvatar:
  32275. return m.Avatar()
  32276. case wpchatroom.FieldMemberList:
  32277. return m.MemberList()
  32278. }
  32279. return nil, false
  32280. }
  32281. // OldField returns the old value of the field from the database. An error is
  32282. // returned if the mutation operation is not UpdateOne, or the query to the
  32283. // database failed.
  32284. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32285. switch name {
  32286. case wpchatroom.FieldCreatedAt:
  32287. return m.OldCreatedAt(ctx)
  32288. case wpchatroom.FieldUpdatedAt:
  32289. return m.OldUpdatedAt(ctx)
  32290. case wpchatroom.FieldStatus:
  32291. return m.OldStatus(ctx)
  32292. case wpchatroom.FieldWxWxid:
  32293. return m.OldWxWxid(ctx)
  32294. case wpchatroom.FieldChatroomID:
  32295. return m.OldChatroomID(ctx)
  32296. case wpchatroom.FieldNickname:
  32297. return m.OldNickname(ctx)
  32298. case wpchatroom.FieldOwner:
  32299. return m.OldOwner(ctx)
  32300. case wpchatroom.FieldAvatar:
  32301. return m.OldAvatar(ctx)
  32302. case wpchatroom.FieldMemberList:
  32303. return m.OldMemberList(ctx)
  32304. }
  32305. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  32306. }
  32307. // SetField sets the value of a field with the given name. It returns an error if
  32308. // the field is not defined in the schema, or if the type mismatched the field
  32309. // type.
  32310. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  32311. switch name {
  32312. case wpchatroom.FieldCreatedAt:
  32313. v, ok := value.(time.Time)
  32314. if !ok {
  32315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32316. }
  32317. m.SetCreatedAt(v)
  32318. return nil
  32319. case wpchatroom.FieldUpdatedAt:
  32320. v, ok := value.(time.Time)
  32321. if !ok {
  32322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32323. }
  32324. m.SetUpdatedAt(v)
  32325. return nil
  32326. case wpchatroom.FieldStatus:
  32327. v, ok := value.(uint8)
  32328. if !ok {
  32329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32330. }
  32331. m.SetStatus(v)
  32332. return nil
  32333. case wpchatroom.FieldWxWxid:
  32334. v, ok := value.(string)
  32335. if !ok {
  32336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32337. }
  32338. m.SetWxWxid(v)
  32339. return nil
  32340. case wpchatroom.FieldChatroomID:
  32341. v, ok := value.(string)
  32342. if !ok {
  32343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32344. }
  32345. m.SetChatroomID(v)
  32346. return nil
  32347. case wpchatroom.FieldNickname:
  32348. v, ok := value.(string)
  32349. if !ok {
  32350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32351. }
  32352. m.SetNickname(v)
  32353. return nil
  32354. case wpchatroom.FieldOwner:
  32355. v, ok := value.(string)
  32356. if !ok {
  32357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32358. }
  32359. m.SetOwner(v)
  32360. return nil
  32361. case wpchatroom.FieldAvatar:
  32362. v, ok := value.(string)
  32363. if !ok {
  32364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32365. }
  32366. m.SetAvatar(v)
  32367. return nil
  32368. case wpchatroom.FieldMemberList:
  32369. v, ok := value.([]string)
  32370. if !ok {
  32371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32372. }
  32373. m.SetMemberList(v)
  32374. return nil
  32375. }
  32376. return fmt.Errorf("unknown WpChatroom field %s", name)
  32377. }
  32378. // AddedFields returns all numeric fields that were incremented/decremented during
  32379. // this mutation.
  32380. func (m *WpChatroomMutation) AddedFields() []string {
  32381. var fields []string
  32382. if m.addstatus != nil {
  32383. fields = append(fields, wpchatroom.FieldStatus)
  32384. }
  32385. return fields
  32386. }
  32387. // AddedField returns the numeric value that was incremented/decremented on a field
  32388. // with the given name. The second boolean return value indicates that this field
  32389. // was not set, or was not defined in the schema.
  32390. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  32391. switch name {
  32392. case wpchatroom.FieldStatus:
  32393. return m.AddedStatus()
  32394. }
  32395. return nil, false
  32396. }
  32397. // AddField adds the value to the field with the given name. It returns an error if
  32398. // the field is not defined in the schema, or if the type mismatched the field
  32399. // type.
  32400. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  32401. switch name {
  32402. case wpchatroom.FieldStatus:
  32403. v, ok := value.(int8)
  32404. if !ok {
  32405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32406. }
  32407. m.AddStatus(v)
  32408. return nil
  32409. }
  32410. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  32411. }
  32412. // ClearedFields returns all nullable fields that were cleared during this
  32413. // mutation.
  32414. func (m *WpChatroomMutation) ClearedFields() []string {
  32415. var fields []string
  32416. if m.FieldCleared(wpchatroom.FieldStatus) {
  32417. fields = append(fields, wpchatroom.FieldStatus)
  32418. }
  32419. return fields
  32420. }
  32421. // FieldCleared returns a boolean indicating if a field with the given name was
  32422. // cleared in this mutation.
  32423. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  32424. _, ok := m.clearedFields[name]
  32425. return ok
  32426. }
  32427. // ClearField clears the value of the field with the given name. It returns an
  32428. // error if the field is not defined in the schema.
  32429. func (m *WpChatroomMutation) ClearField(name string) error {
  32430. switch name {
  32431. case wpchatroom.FieldStatus:
  32432. m.ClearStatus()
  32433. return nil
  32434. }
  32435. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  32436. }
  32437. // ResetField resets all changes in the mutation for the field with the given name.
  32438. // It returns an error if the field is not defined in the schema.
  32439. func (m *WpChatroomMutation) ResetField(name string) error {
  32440. switch name {
  32441. case wpchatroom.FieldCreatedAt:
  32442. m.ResetCreatedAt()
  32443. return nil
  32444. case wpchatroom.FieldUpdatedAt:
  32445. m.ResetUpdatedAt()
  32446. return nil
  32447. case wpchatroom.FieldStatus:
  32448. m.ResetStatus()
  32449. return nil
  32450. case wpchatroom.FieldWxWxid:
  32451. m.ResetWxWxid()
  32452. return nil
  32453. case wpchatroom.FieldChatroomID:
  32454. m.ResetChatroomID()
  32455. return nil
  32456. case wpchatroom.FieldNickname:
  32457. m.ResetNickname()
  32458. return nil
  32459. case wpchatroom.FieldOwner:
  32460. m.ResetOwner()
  32461. return nil
  32462. case wpchatroom.FieldAvatar:
  32463. m.ResetAvatar()
  32464. return nil
  32465. case wpchatroom.FieldMemberList:
  32466. m.ResetMemberList()
  32467. return nil
  32468. }
  32469. return fmt.Errorf("unknown WpChatroom field %s", name)
  32470. }
  32471. // AddedEdges returns all edge names that were set/added in this mutation.
  32472. func (m *WpChatroomMutation) AddedEdges() []string {
  32473. edges := make([]string, 0, 0)
  32474. return edges
  32475. }
  32476. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32477. // name in this mutation.
  32478. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  32479. return nil
  32480. }
  32481. // RemovedEdges returns all edge names that were removed in this mutation.
  32482. func (m *WpChatroomMutation) RemovedEdges() []string {
  32483. edges := make([]string, 0, 0)
  32484. return edges
  32485. }
  32486. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32487. // the given name in this mutation.
  32488. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  32489. return nil
  32490. }
  32491. // ClearedEdges returns all edge names that were cleared in this mutation.
  32492. func (m *WpChatroomMutation) ClearedEdges() []string {
  32493. edges := make([]string, 0, 0)
  32494. return edges
  32495. }
  32496. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32497. // was cleared in this mutation.
  32498. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  32499. return false
  32500. }
  32501. // ClearEdge clears the value of the edge with the given name. It returns an error
  32502. // if that edge is not defined in the schema.
  32503. func (m *WpChatroomMutation) ClearEdge(name string) error {
  32504. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  32505. }
  32506. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32507. // It returns an error if the edge is not defined in the schema.
  32508. func (m *WpChatroomMutation) ResetEdge(name string) error {
  32509. return fmt.Errorf("unknown WpChatroom edge %s", name)
  32510. }
  32511. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  32512. type WpChatroomMemberMutation struct {
  32513. config
  32514. op Op
  32515. typ string
  32516. id *uint64
  32517. created_at *time.Time
  32518. updated_at *time.Time
  32519. status *uint8
  32520. addstatus *int8
  32521. wx_wxid *string
  32522. wxid *string
  32523. nickname *string
  32524. avatar *string
  32525. clearedFields map[string]struct{}
  32526. done bool
  32527. oldValue func(context.Context) (*WpChatroomMember, error)
  32528. predicates []predicate.WpChatroomMember
  32529. }
  32530. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  32531. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  32532. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  32533. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  32534. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  32535. m := &WpChatroomMemberMutation{
  32536. config: c,
  32537. op: op,
  32538. typ: TypeWpChatroomMember,
  32539. clearedFields: make(map[string]struct{}),
  32540. }
  32541. for _, opt := range opts {
  32542. opt(m)
  32543. }
  32544. return m
  32545. }
  32546. // withWpChatroomMemberID sets the ID field of the mutation.
  32547. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  32548. return func(m *WpChatroomMemberMutation) {
  32549. var (
  32550. err error
  32551. once sync.Once
  32552. value *WpChatroomMember
  32553. )
  32554. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  32555. once.Do(func() {
  32556. if m.done {
  32557. err = errors.New("querying old values post mutation is not allowed")
  32558. } else {
  32559. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  32560. }
  32561. })
  32562. return value, err
  32563. }
  32564. m.id = &id
  32565. }
  32566. }
  32567. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  32568. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  32569. return func(m *WpChatroomMemberMutation) {
  32570. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  32571. return node, nil
  32572. }
  32573. m.id = &node.ID
  32574. }
  32575. }
  32576. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32577. // executed in a transaction (ent.Tx), a transactional client is returned.
  32578. func (m WpChatroomMemberMutation) Client() *Client {
  32579. client := &Client{config: m.config}
  32580. client.init()
  32581. return client
  32582. }
  32583. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32584. // it returns an error otherwise.
  32585. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  32586. if _, ok := m.driver.(*txDriver); !ok {
  32587. return nil, errors.New("ent: mutation is not running in a transaction")
  32588. }
  32589. tx := &Tx{config: m.config}
  32590. tx.init()
  32591. return tx, nil
  32592. }
  32593. // SetID sets the value of the id field. Note that this
  32594. // operation is only accepted on creation of WpChatroomMember entities.
  32595. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  32596. m.id = &id
  32597. }
  32598. // ID returns the ID value in the mutation. Note that the ID is only available
  32599. // if it was provided to the builder or after it was returned from the database.
  32600. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  32601. if m.id == nil {
  32602. return
  32603. }
  32604. return *m.id, true
  32605. }
  32606. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32607. // That means, if the mutation is applied within a transaction with an isolation level such
  32608. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32609. // or updated by the mutation.
  32610. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  32611. switch {
  32612. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32613. id, exists := m.ID()
  32614. if exists {
  32615. return []uint64{id}, nil
  32616. }
  32617. fallthrough
  32618. case m.op.Is(OpUpdate | OpDelete):
  32619. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  32620. default:
  32621. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32622. }
  32623. }
  32624. // SetCreatedAt sets the "created_at" field.
  32625. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  32626. m.created_at = &t
  32627. }
  32628. // CreatedAt returns the value of the "created_at" field in the mutation.
  32629. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  32630. v := m.created_at
  32631. if v == nil {
  32632. return
  32633. }
  32634. return *v, true
  32635. }
  32636. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  32637. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32639. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32640. if !m.op.Is(OpUpdateOne) {
  32641. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32642. }
  32643. if m.id == nil || m.oldValue == nil {
  32644. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32645. }
  32646. oldValue, err := m.oldValue(ctx)
  32647. if err != nil {
  32648. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32649. }
  32650. return oldValue.CreatedAt, nil
  32651. }
  32652. // ResetCreatedAt resets all changes to the "created_at" field.
  32653. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  32654. m.created_at = nil
  32655. }
  32656. // SetUpdatedAt sets the "updated_at" field.
  32657. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  32658. m.updated_at = &t
  32659. }
  32660. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32661. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  32662. v := m.updated_at
  32663. if v == nil {
  32664. return
  32665. }
  32666. return *v, true
  32667. }
  32668. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  32669. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32671. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32672. if !m.op.Is(OpUpdateOne) {
  32673. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32674. }
  32675. if m.id == nil || m.oldValue == nil {
  32676. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32677. }
  32678. oldValue, err := m.oldValue(ctx)
  32679. if err != nil {
  32680. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32681. }
  32682. return oldValue.UpdatedAt, nil
  32683. }
  32684. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32685. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  32686. m.updated_at = nil
  32687. }
  32688. // SetStatus sets the "status" field.
  32689. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  32690. m.status = &u
  32691. m.addstatus = nil
  32692. }
  32693. // Status returns the value of the "status" field in the mutation.
  32694. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  32695. v := m.status
  32696. if v == nil {
  32697. return
  32698. }
  32699. return *v, true
  32700. }
  32701. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  32702. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32704. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32705. if !m.op.Is(OpUpdateOne) {
  32706. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32707. }
  32708. if m.id == nil || m.oldValue == nil {
  32709. return v, errors.New("OldStatus requires an ID field in the mutation")
  32710. }
  32711. oldValue, err := m.oldValue(ctx)
  32712. if err != nil {
  32713. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32714. }
  32715. return oldValue.Status, nil
  32716. }
  32717. // AddStatus adds u to the "status" field.
  32718. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  32719. if m.addstatus != nil {
  32720. *m.addstatus += u
  32721. } else {
  32722. m.addstatus = &u
  32723. }
  32724. }
  32725. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32726. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  32727. v := m.addstatus
  32728. if v == nil {
  32729. return
  32730. }
  32731. return *v, true
  32732. }
  32733. // ClearStatus clears the value of the "status" field.
  32734. func (m *WpChatroomMemberMutation) ClearStatus() {
  32735. m.status = nil
  32736. m.addstatus = nil
  32737. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  32738. }
  32739. // StatusCleared returns if the "status" field was cleared in this mutation.
  32740. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  32741. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  32742. return ok
  32743. }
  32744. // ResetStatus resets all changes to the "status" field.
  32745. func (m *WpChatroomMemberMutation) ResetStatus() {
  32746. m.status = nil
  32747. m.addstatus = nil
  32748. delete(m.clearedFields, wpchatroommember.FieldStatus)
  32749. }
  32750. // SetWxWxid sets the "wx_wxid" field.
  32751. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  32752. m.wx_wxid = &s
  32753. }
  32754. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  32755. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  32756. v := m.wx_wxid
  32757. if v == nil {
  32758. return
  32759. }
  32760. return *v, true
  32761. }
  32762. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  32763. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32765. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  32766. if !m.op.Is(OpUpdateOne) {
  32767. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  32768. }
  32769. if m.id == nil || m.oldValue == nil {
  32770. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  32771. }
  32772. oldValue, err := m.oldValue(ctx)
  32773. if err != nil {
  32774. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  32775. }
  32776. return oldValue.WxWxid, nil
  32777. }
  32778. // ResetWxWxid resets all changes to the "wx_wxid" field.
  32779. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  32780. m.wx_wxid = nil
  32781. }
  32782. // SetWxid sets the "wxid" field.
  32783. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  32784. m.wxid = &s
  32785. }
  32786. // Wxid returns the value of the "wxid" field in the mutation.
  32787. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  32788. v := m.wxid
  32789. if v == nil {
  32790. return
  32791. }
  32792. return *v, true
  32793. }
  32794. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  32795. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32797. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  32798. if !m.op.Is(OpUpdateOne) {
  32799. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  32800. }
  32801. if m.id == nil || m.oldValue == nil {
  32802. return v, errors.New("OldWxid requires an ID field in the mutation")
  32803. }
  32804. oldValue, err := m.oldValue(ctx)
  32805. if err != nil {
  32806. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  32807. }
  32808. return oldValue.Wxid, nil
  32809. }
  32810. // ResetWxid resets all changes to the "wxid" field.
  32811. func (m *WpChatroomMemberMutation) ResetWxid() {
  32812. m.wxid = nil
  32813. }
  32814. // SetNickname sets the "nickname" field.
  32815. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  32816. m.nickname = &s
  32817. }
  32818. // Nickname returns the value of the "nickname" field in the mutation.
  32819. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  32820. v := m.nickname
  32821. if v == nil {
  32822. return
  32823. }
  32824. return *v, true
  32825. }
  32826. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  32827. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32829. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  32830. if !m.op.Is(OpUpdateOne) {
  32831. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32832. }
  32833. if m.id == nil || m.oldValue == nil {
  32834. return v, errors.New("OldNickname requires an ID field in the mutation")
  32835. }
  32836. oldValue, err := m.oldValue(ctx)
  32837. if err != nil {
  32838. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32839. }
  32840. return oldValue.Nickname, nil
  32841. }
  32842. // ResetNickname resets all changes to the "nickname" field.
  32843. func (m *WpChatroomMemberMutation) ResetNickname() {
  32844. m.nickname = nil
  32845. }
  32846. // SetAvatar sets the "avatar" field.
  32847. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  32848. m.avatar = &s
  32849. }
  32850. // Avatar returns the value of the "avatar" field in the mutation.
  32851. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  32852. v := m.avatar
  32853. if v == nil {
  32854. return
  32855. }
  32856. return *v, true
  32857. }
  32858. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  32859. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32861. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  32862. if !m.op.Is(OpUpdateOne) {
  32863. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  32864. }
  32865. if m.id == nil || m.oldValue == nil {
  32866. return v, errors.New("OldAvatar requires an ID field in the mutation")
  32867. }
  32868. oldValue, err := m.oldValue(ctx)
  32869. if err != nil {
  32870. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  32871. }
  32872. return oldValue.Avatar, nil
  32873. }
  32874. // ResetAvatar resets all changes to the "avatar" field.
  32875. func (m *WpChatroomMemberMutation) ResetAvatar() {
  32876. m.avatar = nil
  32877. }
  32878. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  32879. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  32880. m.predicates = append(m.predicates, ps...)
  32881. }
  32882. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  32883. // users can use type-assertion to append predicates that do not depend on any generated package.
  32884. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  32885. p := make([]predicate.WpChatroomMember, len(ps))
  32886. for i := range ps {
  32887. p[i] = ps[i]
  32888. }
  32889. m.Where(p...)
  32890. }
  32891. // Op returns the operation name.
  32892. func (m *WpChatroomMemberMutation) Op() Op {
  32893. return m.op
  32894. }
  32895. // SetOp allows setting the mutation operation.
  32896. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  32897. m.op = op
  32898. }
  32899. // Type returns the node type of this mutation (WpChatroomMember).
  32900. func (m *WpChatroomMemberMutation) Type() string {
  32901. return m.typ
  32902. }
  32903. // Fields returns all fields that were changed during this mutation. Note that in
  32904. // order to get all numeric fields that were incremented/decremented, call
  32905. // AddedFields().
  32906. func (m *WpChatroomMemberMutation) Fields() []string {
  32907. fields := make([]string, 0, 7)
  32908. if m.created_at != nil {
  32909. fields = append(fields, wpchatroommember.FieldCreatedAt)
  32910. }
  32911. if m.updated_at != nil {
  32912. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  32913. }
  32914. if m.status != nil {
  32915. fields = append(fields, wpchatroommember.FieldStatus)
  32916. }
  32917. if m.wx_wxid != nil {
  32918. fields = append(fields, wpchatroommember.FieldWxWxid)
  32919. }
  32920. if m.wxid != nil {
  32921. fields = append(fields, wpchatroommember.FieldWxid)
  32922. }
  32923. if m.nickname != nil {
  32924. fields = append(fields, wpchatroommember.FieldNickname)
  32925. }
  32926. if m.avatar != nil {
  32927. fields = append(fields, wpchatroommember.FieldAvatar)
  32928. }
  32929. return fields
  32930. }
  32931. // Field returns the value of a field with the given name. The second boolean
  32932. // return value indicates that this field was not set, or was not defined in the
  32933. // schema.
  32934. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  32935. switch name {
  32936. case wpchatroommember.FieldCreatedAt:
  32937. return m.CreatedAt()
  32938. case wpchatroommember.FieldUpdatedAt:
  32939. return m.UpdatedAt()
  32940. case wpchatroommember.FieldStatus:
  32941. return m.Status()
  32942. case wpchatroommember.FieldWxWxid:
  32943. return m.WxWxid()
  32944. case wpchatroommember.FieldWxid:
  32945. return m.Wxid()
  32946. case wpchatroommember.FieldNickname:
  32947. return m.Nickname()
  32948. case wpchatroommember.FieldAvatar:
  32949. return m.Avatar()
  32950. }
  32951. return nil, false
  32952. }
  32953. // OldField returns the old value of the field from the database. An error is
  32954. // returned if the mutation operation is not UpdateOne, or the query to the
  32955. // database failed.
  32956. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32957. switch name {
  32958. case wpchatroommember.FieldCreatedAt:
  32959. return m.OldCreatedAt(ctx)
  32960. case wpchatroommember.FieldUpdatedAt:
  32961. return m.OldUpdatedAt(ctx)
  32962. case wpchatroommember.FieldStatus:
  32963. return m.OldStatus(ctx)
  32964. case wpchatroommember.FieldWxWxid:
  32965. return m.OldWxWxid(ctx)
  32966. case wpchatroommember.FieldWxid:
  32967. return m.OldWxid(ctx)
  32968. case wpchatroommember.FieldNickname:
  32969. return m.OldNickname(ctx)
  32970. case wpchatroommember.FieldAvatar:
  32971. return m.OldAvatar(ctx)
  32972. }
  32973. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  32974. }
  32975. // SetField sets the value of a field with the given name. It returns an error if
  32976. // the field is not defined in the schema, or if the type mismatched the field
  32977. // type.
  32978. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  32979. switch name {
  32980. case wpchatroommember.FieldCreatedAt:
  32981. v, ok := value.(time.Time)
  32982. if !ok {
  32983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32984. }
  32985. m.SetCreatedAt(v)
  32986. return nil
  32987. case wpchatroommember.FieldUpdatedAt:
  32988. v, ok := value.(time.Time)
  32989. if !ok {
  32990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32991. }
  32992. m.SetUpdatedAt(v)
  32993. return nil
  32994. case wpchatroommember.FieldStatus:
  32995. v, ok := value.(uint8)
  32996. if !ok {
  32997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32998. }
  32999. m.SetStatus(v)
  33000. return nil
  33001. case wpchatroommember.FieldWxWxid:
  33002. v, ok := value.(string)
  33003. if !ok {
  33004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33005. }
  33006. m.SetWxWxid(v)
  33007. return nil
  33008. case wpchatroommember.FieldWxid:
  33009. v, ok := value.(string)
  33010. if !ok {
  33011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33012. }
  33013. m.SetWxid(v)
  33014. return nil
  33015. case wpchatroommember.FieldNickname:
  33016. v, ok := value.(string)
  33017. if !ok {
  33018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33019. }
  33020. m.SetNickname(v)
  33021. return nil
  33022. case wpchatroommember.FieldAvatar:
  33023. v, ok := value.(string)
  33024. if !ok {
  33025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33026. }
  33027. m.SetAvatar(v)
  33028. return nil
  33029. }
  33030. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  33031. }
  33032. // AddedFields returns all numeric fields that were incremented/decremented during
  33033. // this mutation.
  33034. func (m *WpChatroomMemberMutation) AddedFields() []string {
  33035. var fields []string
  33036. if m.addstatus != nil {
  33037. fields = append(fields, wpchatroommember.FieldStatus)
  33038. }
  33039. return fields
  33040. }
  33041. // AddedField returns the numeric value that was incremented/decremented on a field
  33042. // with the given name. The second boolean return value indicates that this field
  33043. // was not set, or was not defined in the schema.
  33044. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  33045. switch name {
  33046. case wpchatroommember.FieldStatus:
  33047. return m.AddedStatus()
  33048. }
  33049. return nil, false
  33050. }
  33051. // AddField adds the value to the field with the given name. It returns an error if
  33052. // the field is not defined in the schema, or if the type mismatched the field
  33053. // type.
  33054. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  33055. switch name {
  33056. case wpchatroommember.FieldStatus:
  33057. v, ok := value.(int8)
  33058. if !ok {
  33059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33060. }
  33061. m.AddStatus(v)
  33062. return nil
  33063. }
  33064. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  33065. }
  33066. // ClearedFields returns all nullable fields that were cleared during this
  33067. // mutation.
  33068. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  33069. var fields []string
  33070. if m.FieldCleared(wpchatroommember.FieldStatus) {
  33071. fields = append(fields, wpchatroommember.FieldStatus)
  33072. }
  33073. return fields
  33074. }
  33075. // FieldCleared returns a boolean indicating if a field with the given name was
  33076. // cleared in this mutation.
  33077. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  33078. _, ok := m.clearedFields[name]
  33079. return ok
  33080. }
  33081. // ClearField clears the value of the field with the given name. It returns an
  33082. // error if the field is not defined in the schema.
  33083. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  33084. switch name {
  33085. case wpchatroommember.FieldStatus:
  33086. m.ClearStatus()
  33087. return nil
  33088. }
  33089. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  33090. }
  33091. // ResetField resets all changes in the mutation for the field with the given name.
  33092. // It returns an error if the field is not defined in the schema.
  33093. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  33094. switch name {
  33095. case wpchatroommember.FieldCreatedAt:
  33096. m.ResetCreatedAt()
  33097. return nil
  33098. case wpchatroommember.FieldUpdatedAt:
  33099. m.ResetUpdatedAt()
  33100. return nil
  33101. case wpchatroommember.FieldStatus:
  33102. m.ResetStatus()
  33103. return nil
  33104. case wpchatroommember.FieldWxWxid:
  33105. m.ResetWxWxid()
  33106. return nil
  33107. case wpchatroommember.FieldWxid:
  33108. m.ResetWxid()
  33109. return nil
  33110. case wpchatroommember.FieldNickname:
  33111. m.ResetNickname()
  33112. return nil
  33113. case wpchatroommember.FieldAvatar:
  33114. m.ResetAvatar()
  33115. return nil
  33116. }
  33117. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  33118. }
  33119. // AddedEdges returns all edge names that were set/added in this mutation.
  33120. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  33121. edges := make([]string, 0, 0)
  33122. return edges
  33123. }
  33124. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33125. // name in this mutation.
  33126. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  33127. return nil
  33128. }
  33129. // RemovedEdges returns all edge names that were removed in this mutation.
  33130. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  33131. edges := make([]string, 0, 0)
  33132. return edges
  33133. }
  33134. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33135. // the given name in this mutation.
  33136. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  33137. return nil
  33138. }
  33139. // ClearedEdges returns all edge names that were cleared in this mutation.
  33140. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  33141. edges := make([]string, 0, 0)
  33142. return edges
  33143. }
  33144. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33145. // was cleared in this mutation.
  33146. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  33147. return false
  33148. }
  33149. // ClearEdge clears the value of the edge with the given name. It returns an error
  33150. // if that edge is not defined in the schema.
  33151. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  33152. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  33153. }
  33154. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33155. // It returns an error if the edge is not defined in the schema.
  33156. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  33157. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  33158. }
  33159. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  33160. type WxMutation struct {
  33161. config
  33162. op Op
  33163. typ string
  33164. id *uint64
  33165. created_at *time.Time
  33166. updated_at *time.Time
  33167. status *uint8
  33168. addstatus *int8
  33169. deleted_at *time.Time
  33170. port *string
  33171. process_id *string
  33172. callback *string
  33173. wxid *string
  33174. account *string
  33175. nickname *string
  33176. tel *string
  33177. head_big *string
  33178. organization_id *uint64
  33179. addorganization_id *int64
  33180. api_base *string
  33181. api_key *string
  33182. allow_list *[]string
  33183. appendallow_list []string
  33184. group_allow_list *[]string
  33185. appendgroup_allow_list []string
  33186. block_list *[]string
  33187. appendblock_list []string
  33188. group_block_list *[]string
  33189. appendgroup_block_list []string
  33190. clearedFields map[string]struct{}
  33191. server *uint64
  33192. clearedserver bool
  33193. agent *uint64
  33194. clearedagent bool
  33195. done bool
  33196. oldValue func(context.Context) (*Wx, error)
  33197. predicates []predicate.Wx
  33198. }
  33199. var _ ent.Mutation = (*WxMutation)(nil)
  33200. // wxOption allows management of the mutation configuration using functional options.
  33201. type wxOption func(*WxMutation)
  33202. // newWxMutation creates new mutation for the Wx entity.
  33203. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  33204. m := &WxMutation{
  33205. config: c,
  33206. op: op,
  33207. typ: TypeWx,
  33208. clearedFields: make(map[string]struct{}),
  33209. }
  33210. for _, opt := range opts {
  33211. opt(m)
  33212. }
  33213. return m
  33214. }
  33215. // withWxID sets the ID field of the mutation.
  33216. func withWxID(id uint64) wxOption {
  33217. return func(m *WxMutation) {
  33218. var (
  33219. err error
  33220. once sync.Once
  33221. value *Wx
  33222. )
  33223. m.oldValue = func(ctx context.Context) (*Wx, error) {
  33224. once.Do(func() {
  33225. if m.done {
  33226. err = errors.New("querying old values post mutation is not allowed")
  33227. } else {
  33228. value, err = m.Client().Wx.Get(ctx, id)
  33229. }
  33230. })
  33231. return value, err
  33232. }
  33233. m.id = &id
  33234. }
  33235. }
  33236. // withWx sets the old Wx of the mutation.
  33237. func withWx(node *Wx) wxOption {
  33238. return func(m *WxMutation) {
  33239. m.oldValue = func(context.Context) (*Wx, error) {
  33240. return node, nil
  33241. }
  33242. m.id = &node.ID
  33243. }
  33244. }
  33245. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33246. // executed in a transaction (ent.Tx), a transactional client is returned.
  33247. func (m WxMutation) Client() *Client {
  33248. client := &Client{config: m.config}
  33249. client.init()
  33250. return client
  33251. }
  33252. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33253. // it returns an error otherwise.
  33254. func (m WxMutation) Tx() (*Tx, error) {
  33255. if _, ok := m.driver.(*txDriver); !ok {
  33256. return nil, errors.New("ent: mutation is not running in a transaction")
  33257. }
  33258. tx := &Tx{config: m.config}
  33259. tx.init()
  33260. return tx, nil
  33261. }
  33262. // SetID sets the value of the id field. Note that this
  33263. // operation is only accepted on creation of Wx entities.
  33264. func (m *WxMutation) SetID(id uint64) {
  33265. m.id = &id
  33266. }
  33267. // ID returns the ID value in the mutation. Note that the ID is only available
  33268. // if it was provided to the builder or after it was returned from the database.
  33269. func (m *WxMutation) ID() (id uint64, exists bool) {
  33270. if m.id == nil {
  33271. return
  33272. }
  33273. return *m.id, true
  33274. }
  33275. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33276. // That means, if the mutation is applied within a transaction with an isolation level such
  33277. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33278. // or updated by the mutation.
  33279. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  33280. switch {
  33281. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33282. id, exists := m.ID()
  33283. if exists {
  33284. return []uint64{id}, nil
  33285. }
  33286. fallthrough
  33287. case m.op.Is(OpUpdate | OpDelete):
  33288. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  33289. default:
  33290. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33291. }
  33292. }
  33293. // SetCreatedAt sets the "created_at" field.
  33294. func (m *WxMutation) SetCreatedAt(t time.Time) {
  33295. m.created_at = &t
  33296. }
  33297. // CreatedAt returns the value of the "created_at" field in the mutation.
  33298. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  33299. v := m.created_at
  33300. if v == nil {
  33301. return
  33302. }
  33303. return *v, true
  33304. }
  33305. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  33306. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33308. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33309. if !m.op.Is(OpUpdateOne) {
  33310. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33311. }
  33312. if m.id == nil || m.oldValue == nil {
  33313. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33314. }
  33315. oldValue, err := m.oldValue(ctx)
  33316. if err != nil {
  33317. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33318. }
  33319. return oldValue.CreatedAt, nil
  33320. }
  33321. // ResetCreatedAt resets all changes to the "created_at" field.
  33322. func (m *WxMutation) ResetCreatedAt() {
  33323. m.created_at = nil
  33324. }
  33325. // SetUpdatedAt sets the "updated_at" field.
  33326. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  33327. m.updated_at = &t
  33328. }
  33329. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33330. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  33331. v := m.updated_at
  33332. if v == nil {
  33333. return
  33334. }
  33335. return *v, true
  33336. }
  33337. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  33338. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33340. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33341. if !m.op.Is(OpUpdateOne) {
  33342. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33343. }
  33344. if m.id == nil || m.oldValue == nil {
  33345. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33346. }
  33347. oldValue, err := m.oldValue(ctx)
  33348. if err != nil {
  33349. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33350. }
  33351. return oldValue.UpdatedAt, nil
  33352. }
  33353. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33354. func (m *WxMutation) ResetUpdatedAt() {
  33355. m.updated_at = nil
  33356. }
  33357. // SetStatus sets the "status" field.
  33358. func (m *WxMutation) SetStatus(u uint8) {
  33359. m.status = &u
  33360. m.addstatus = nil
  33361. }
  33362. // Status returns the value of the "status" field in the mutation.
  33363. func (m *WxMutation) Status() (r uint8, exists bool) {
  33364. v := m.status
  33365. if v == nil {
  33366. return
  33367. }
  33368. return *v, true
  33369. }
  33370. // OldStatus returns the old "status" field's value of the Wx entity.
  33371. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33373. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33374. if !m.op.Is(OpUpdateOne) {
  33375. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33376. }
  33377. if m.id == nil || m.oldValue == nil {
  33378. return v, errors.New("OldStatus requires an ID field in the mutation")
  33379. }
  33380. oldValue, err := m.oldValue(ctx)
  33381. if err != nil {
  33382. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33383. }
  33384. return oldValue.Status, nil
  33385. }
  33386. // AddStatus adds u to the "status" field.
  33387. func (m *WxMutation) AddStatus(u int8) {
  33388. if m.addstatus != nil {
  33389. *m.addstatus += u
  33390. } else {
  33391. m.addstatus = &u
  33392. }
  33393. }
  33394. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33395. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  33396. v := m.addstatus
  33397. if v == nil {
  33398. return
  33399. }
  33400. return *v, true
  33401. }
  33402. // ClearStatus clears the value of the "status" field.
  33403. func (m *WxMutation) ClearStatus() {
  33404. m.status = nil
  33405. m.addstatus = nil
  33406. m.clearedFields[wx.FieldStatus] = struct{}{}
  33407. }
  33408. // StatusCleared returns if the "status" field was cleared in this mutation.
  33409. func (m *WxMutation) StatusCleared() bool {
  33410. _, ok := m.clearedFields[wx.FieldStatus]
  33411. return ok
  33412. }
  33413. // ResetStatus resets all changes to the "status" field.
  33414. func (m *WxMutation) ResetStatus() {
  33415. m.status = nil
  33416. m.addstatus = nil
  33417. delete(m.clearedFields, wx.FieldStatus)
  33418. }
  33419. // SetDeletedAt sets the "deleted_at" field.
  33420. func (m *WxMutation) SetDeletedAt(t time.Time) {
  33421. m.deleted_at = &t
  33422. }
  33423. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33424. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  33425. v := m.deleted_at
  33426. if v == nil {
  33427. return
  33428. }
  33429. return *v, true
  33430. }
  33431. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  33432. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33434. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33435. if !m.op.Is(OpUpdateOne) {
  33436. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33437. }
  33438. if m.id == nil || m.oldValue == nil {
  33439. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33440. }
  33441. oldValue, err := m.oldValue(ctx)
  33442. if err != nil {
  33443. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33444. }
  33445. return oldValue.DeletedAt, nil
  33446. }
  33447. // ClearDeletedAt clears the value of the "deleted_at" field.
  33448. func (m *WxMutation) ClearDeletedAt() {
  33449. m.deleted_at = nil
  33450. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  33451. }
  33452. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33453. func (m *WxMutation) DeletedAtCleared() bool {
  33454. _, ok := m.clearedFields[wx.FieldDeletedAt]
  33455. return ok
  33456. }
  33457. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33458. func (m *WxMutation) ResetDeletedAt() {
  33459. m.deleted_at = nil
  33460. delete(m.clearedFields, wx.FieldDeletedAt)
  33461. }
  33462. // SetServerID sets the "server_id" field.
  33463. func (m *WxMutation) SetServerID(u uint64) {
  33464. m.server = &u
  33465. }
  33466. // ServerID returns the value of the "server_id" field in the mutation.
  33467. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  33468. v := m.server
  33469. if v == nil {
  33470. return
  33471. }
  33472. return *v, true
  33473. }
  33474. // OldServerID returns the old "server_id" field's value of the Wx entity.
  33475. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33477. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  33478. if !m.op.Is(OpUpdateOne) {
  33479. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  33480. }
  33481. if m.id == nil || m.oldValue == nil {
  33482. return v, errors.New("OldServerID requires an ID field in the mutation")
  33483. }
  33484. oldValue, err := m.oldValue(ctx)
  33485. if err != nil {
  33486. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  33487. }
  33488. return oldValue.ServerID, nil
  33489. }
  33490. // ClearServerID clears the value of the "server_id" field.
  33491. func (m *WxMutation) ClearServerID() {
  33492. m.server = nil
  33493. m.clearedFields[wx.FieldServerID] = struct{}{}
  33494. }
  33495. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  33496. func (m *WxMutation) ServerIDCleared() bool {
  33497. _, ok := m.clearedFields[wx.FieldServerID]
  33498. return ok
  33499. }
  33500. // ResetServerID resets all changes to the "server_id" field.
  33501. func (m *WxMutation) ResetServerID() {
  33502. m.server = nil
  33503. delete(m.clearedFields, wx.FieldServerID)
  33504. }
  33505. // SetPort sets the "port" field.
  33506. func (m *WxMutation) SetPort(s string) {
  33507. m.port = &s
  33508. }
  33509. // Port returns the value of the "port" field in the mutation.
  33510. func (m *WxMutation) Port() (r string, exists bool) {
  33511. v := m.port
  33512. if v == nil {
  33513. return
  33514. }
  33515. return *v, true
  33516. }
  33517. // OldPort returns the old "port" field's value of the Wx entity.
  33518. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33520. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  33521. if !m.op.Is(OpUpdateOne) {
  33522. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  33523. }
  33524. if m.id == nil || m.oldValue == nil {
  33525. return v, errors.New("OldPort requires an ID field in the mutation")
  33526. }
  33527. oldValue, err := m.oldValue(ctx)
  33528. if err != nil {
  33529. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  33530. }
  33531. return oldValue.Port, nil
  33532. }
  33533. // ResetPort resets all changes to the "port" field.
  33534. func (m *WxMutation) ResetPort() {
  33535. m.port = nil
  33536. }
  33537. // SetProcessID sets the "process_id" field.
  33538. func (m *WxMutation) SetProcessID(s string) {
  33539. m.process_id = &s
  33540. }
  33541. // ProcessID returns the value of the "process_id" field in the mutation.
  33542. func (m *WxMutation) ProcessID() (r string, exists bool) {
  33543. v := m.process_id
  33544. if v == nil {
  33545. return
  33546. }
  33547. return *v, true
  33548. }
  33549. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  33550. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33552. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  33553. if !m.op.Is(OpUpdateOne) {
  33554. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  33555. }
  33556. if m.id == nil || m.oldValue == nil {
  33557. return v, errors.New("OldProcessID requires an ID field in the mutation")
  33558. }
  33559. oldValue, err := m.oldValue(ctx)
  33560. if err != nil {
  33561. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  33562. }
  33563. return oldValue.ProcessID, nil
  33564. }
  33565. // ResetProcessID resets all changes to the "process_id" field.
  33566. func (m *WxMutation) ResetProcessID() {
  33567. m.process_id = nil
  33568. }
  33569. // SetCallback sets the "callback" field.
  33570. func (m *WxMutation) SetCallback(s string) {
  33571. m.callback = &s
  33572. }
  33573. // Callback returns the value of the "callback" field in the mutation.
  33574. func (m *WxMutation) Callback() (r string, exists bool) {
  33575. v := m.callback
  33576. if v == nil {
  33577. return
  33578. }
  33579. return *v, true
  33580. }
  33581. // OldCallback returns the old "callback" field's value of the Wx entity.
  33582. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33584. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  33585. if !m.op.Is(OpUpdateOne) {
  33586. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  33587. }
  33588. if m.id == nil || m.oldValue == nil {
  33589. return v, errors.New("OldCallback requires an ID field in the mutation")
  33590. }
  33591. oldValue, err := m.oldValue(ctx)
  33592. if err != nil {
  33593. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  33594. }
  33595. return oldValue.Callback, nil
  33596. }
  33597. // ResetCallback resets all changes to the "callback" field.
  33598. func (m *WxMutation) ResetCallback() {
  33599. m.callback = nil
  33600. }
  33601. // SetWxid sets the "wxid" field.
  33602. func (m *WxMutation) SetWxid(s string) {
  33603. m.wxid = &s
  33604. }
  33605. // Wxid returns the value of the "wxid" field in the mutation.
  33606. func (m *WxMutation) Wxid() (r string, exists bool) {
  33607. v := m.wxid
  33608. if v == nil {
  33609. return
  33610. }
  33611. return *v, true
  33612. }
  33613. // OldWxid returns the old "wxid" field's value of the Wx entity.
  33614. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33616. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  33617. if !m.op.Is(OpUpdateOne) {
  33618. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  33619. }
  33620. if m.id == nil || m.oldValue == nil {
  33621. return v, errors.New("OldWxid requires an ID field in the mutation")
  33622. }
  33623. oldValue, err := m.oldValue(ctx)
  33624. if err != nil {
  33625. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  33626. }
  33627. return oldValue.Wxid, nil
  33628. }
  33629. // ResetWxid resets all changes to the "wxid" field.
  33630. func (m *WxMutation) ResetWxid() {
  33631. m.wxid = nil
  33632. }
  33633. // SetAccount sets the "account" field.
  33634. func (m *WxMutation) SetAccount(s string) {
  33635. m.account = &s
  33636. }
  33637. // Account returns the value of the "account" field in the mutation.
  33638. func (m *WxMutation) Account() (r string, exists bool) {
  33639. v := m.account
  33640. if v == nil {
  33641. return
  33642. }
  33643. return *v, true
  33644. }
  33645. // OldAccount returns the old "account" field's value of the Wx entity.
  33646. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33648. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  33649. if !m.op.Is(OpUpdateOne) {
  33650. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  33651. }
  33652. if m.id == nil || m.oldValue == nil {
  33653. return v, errors.New("OldAccount requires an ID field in the mutation")
  33654. }
  33655. oldValue, err := m.oldValue(ctx)
  33656. if err != nil {
  33657. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  33658. }
  33659. return oldValue.Account, nil
  33660. }
  33661. // ResetAccount resets all changes to the "account" field.
  33662. func (m *WxMutation) ResetAccount() {
  33663. m.account = nil
  33664. }
  33665. // SetNickname sets the "nickname" field.
  33666. func (m *WxMutation) SetNickname(s string) {
  33667. m.nickname = &s
  33668. }
  33669. // Nickname returns the value of the "nickname" field in the mutation.
  33670. func (m *WxMutation) Nickname() (r string, exists bool) {
  33671. v := m.nickname
  33672. if v == nil {
  33673. return
  33674. }
  33675. return *v, true
  33676. }
  33677. // OldNickname returns the old "nickname" field's value of the Wx entity.
  33678. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33680. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  33681. if !m.op.Is(OpUpdateOne) {
  33682. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  33683. }
  33684. if m.id == nil || m.oldValue == nil {
  33685. return v, errors.New("OldNickname requires an ID field in the mutation")
  33686. }
  33687. oldValue, err := m.oldValue(ctx)
  33688. if err != nil {
  33689. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  33690. }
  33691. return oldValue.Nickname, nil
  33692. }
  33693. // ResetNickname resets all changes to the "nickname" field.
  33694. func (m *WxMutation) ResetNickname() {
  33695. m.nickname = nil
  33696. }
  33697. // SetTel sets the "tel" field.
  33698. func (m *WxMutation) SetTel(s string) {
  33699. m.tel = &s
  33700. }
  33701. // Tel returns the value of the "tel" field in the mutation.
  33702. func (m *WxMutation) Tel() (r string, exists bool) {
  33703. v := m.tel
  33704. if v == nil {
  33705. return
  33706. }
  33707. return *v, true
  33708. }
  33709. // OldTel returns the old "tel" field's value of the Wx entity.
  33710. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33712. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  33713. if !m.op.Is(OpUpdateOne) {
  33714. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  33715. }
  33716. if m.id == nil || m.oldValue == nil {
  33717. return v, errors.New("OldTel requires an ID field in the mutation")
  33718. }
  33719. oldValue, err := m.oldValue(ctx)
  33720. if err != nil {
  33721. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  33722. }
  33723. return oldValue.Tel, nil
  33724. }
  33725. // ResetTel resets all changes to the "tel" field.
  33726. func (m *WxMutation) ResetTel() {
  33727. m.tel = nil
  33728. }
  33729. // SetHeadBig sets the "head_big" field.
  33730. func (m *WxMutation) SetHeadBig(s string) {
  33731. m.head_big = &s
  33732. }
  33733. // HeadBig returns the value of the "head_big" field in the mutation.
  33734. func (m *WxMutation) HeadBig() (r string, exists bool) {
  33735. v := m.head_big
  33736. if v == nil {
  33737. return
  33738. }
  33739. return *v, true
  33740. }
  33741. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  33742. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33744. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  33745. if !m.op.Is(OpUpdateOne) {
  33746. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  33747. }
  33748. if m.id == nil || m.oldValue == nil {
  33749. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  33750. }
  33751. oldValue, err := m.oldValue(ctx)
  33752. if err != nil {
  33753. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  33754. }
  33755. return oldValue.HeadBig, nil
  33756. }
  33757. // ResetHeadBig resets all changes to the "head_big" field.
  33758. func (m *WxMutation) ResetHeadBig() {
  33759. m.head_big = nil
  33760. }
  33761. // SetOrganizationID sets the "organization_id" field.
  33762. func (m *WxMutation) SetOrganizationID(u uint64) {
  33763. m.organization_id = &u
  33764. m.addorganization_id = nil
  33765. }
  33766. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33767. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  33768. v := m.organization_id
  33769. if v == nil {
  33770. return
  33771. }
  33772. return *v, true
  33773. }
  33774. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  33775. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33777. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33778. if !m.op.Is(OpUpdateOne) {
  33779. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33780. }
  33781. if m.id == nil || m.oldValue == nil {
  33782. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33783. }
  33784. oldValue, err := m.oldValue(ctx)
  33785. if err != nil {
  33786. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33787. }
  33788. return oldValue.OrganizationID, nil
  33789. }
  33790. // AddOrganizationID adds u to the "organization_id" field.
  33791. func (m *WxMutation) AddOrganizationID(u int64) {
  33792. if m.addorganization_id != nil {
  33793. *m.addorganization_id += u
  33794. } else {
  33795. m.addorganization_id = &u
  33796. }
  33797. }
  33798. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33799. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  33800. v := m.addorganization_id
  33801. if v == nil {
  33802. return
  33803. }
  33804. return *v, true
  33805. }
  33806. // ClearOrganizationID clears the value of the "organization_id" field.
  33807. func (m *WxMutation) ClearOrganizationID() {
  33808. m.organization_id = nil
  33809. m.addorganization_id = nil
  33810. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  33811. }
  33812. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33813. func (m *WxMutation) OrganizationIDCleared() bool {
  33814. _, ok := m.clearedFields[wx.FieldOrganizationID]
  33815. return ok
  33816. }
  33817. // ResetOrganizationID resets all changes to the "organization_id" field.
  33818. func (m *WxMutation) ResetOrganizationID() {
  33819. m.organization_id = nil
  33820. m.addorganization_id = nil
  33821. delete(m.clearedFields, wx.FieldOrganizationID)
  33822. }
  33823. // SetAgentID sets the "agent_id" field.
  33824. func (m *WxMutation) SetAgentID(u uint64) {
  33825. m.agent = &u
  33826. }
  33827. // AgentID returns the value of the "agent_id" field in the mutation.
  33828. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  33829. v := m.agent
  33830. if v == nil {
  33831. return
  33832. }
  33833. return *v, true
  33834. }
  33835. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  33836. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33838. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  33839. if !m.op.Is(OpUpdateOne) {
  33840. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  33841. }
  33842. if m.id == nil || m.oldValue == nil {
  33843. return v, errors.New("OldAgentID requires an ID field in the mutation")
  33844. }
  33845. oldValue, err := m.oldValue(ctx)
  33846. if err != nil {
  33847. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  33848. }
  33849. return oldValue.AgentID, nil
  33850. }
  33851. // ResetAgentID resets all changes to the "agent_id" field.
  33852. func (m *WxMutation) ResetAgentID() {
  33853. m.agent = nil
  33854. }
  33855. // SetAPIBase sets the "api_base" field.
  33856. func (m *WxMutation) SetAPIBase(s string) {
  33857. m.api_base = &s
  33858. }
  33859. // APIBase returns the value of the "api_base" field in the mutation.
  33860. func (m *WxMutation) APIBase() (r string, exists bool) {
  33861. v := m.api_base
  33862. if v == nil {
  33863. return
  33864. }
  33865. return *v, true
  33866. }
  33867. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  33868. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33870. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  33871. if !m.op.Is(OpUpdateOne) {
  33872. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  33873. }
  33874. if m.id == nil || m.oldValue == nil {
  33875. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  33876. }
  33877. oldValue, err := m.oldValue(ctx)
  33878. if err != nil {
  33879. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  33880. }
  33881. return oldValue.APIBase, nil
  33882. }
  33883. // ClearAPIBase clears the value of the "api_base" field.
  33884. func (m *WxMutation) ClearAPIBase() {
  33885. m.api_base = nil
  33886. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  33887. }
  33888. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  33889. func (m *WxMutation) APIBaseCleared() bool {
  33890. _, ok := m.clearedFields[wx.FieldAPIBase]
  33891. return ok
  33892. }
  33893. // ResetAPIBase resets all changes to the "api_base" field.
  33894. func (m *WxMutation) ResetAPIBase() {
  33895. m.api_base = nil
  33896. delete(m.clearedFields, wx.FieldAPIBase)
  33897. }
  33898. // SetAPIKey sets the "api_key" field.
  33899. func (m *WxMutation) SetAPIKey(s string) {
  33900. m.api_key = &s
  33901. }
  33902. // APIKey returns the value of the "api_key" field in the mutation.
  33903. func (m *WxMutation) APIKey() (r string, exists bool) {
  33904. v := m.api_key
  33905. if v == nil {
  33906. return
  33907. }
  33908. return *v, true
  33909. }
  33910. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  33911. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33913. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  33914. if !m.op.Is(OpUpdateOne) {
  33915. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  33916. }
  33917. if m.id == nil || m.oldValue == nil {
  33918. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  33919. }
  33920. oldValue, err := m.oldValue(ctx)
  33921. if err != nil {
  33922. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  33923. }
  33924. return oldValue.APIKey, nil
  33925. }
  33926. // ClearAPIKey clears the value of the "api_key" field.
  33927. func (m *WxMutation) ClearAPIKey() {
  33928. m.api_key = nil
  33929. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  33930. }
  33931. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  33932. func (m *WxMutation) APIKeyCleared() bool {
  33933. _, ok := m.clearedFields[wx.FieldAPIKey]
  33934. return ok
  33935. }
  33936. // ResetAPIKey resets all changes to the "api_key" field.
  33937. func (m *WxMutation) ResetAPIKey() {
  33938. m.api_key = nil
  33939. delete(m.clearedFields, wx.FieldAPIKey)
  33940. }
  33941. // SetAllowList sets the "allow_list" field.
  33942. func (m *WxMutation) SetAllowList(s []string) {
  33943. m.allow_list = &s
  33944. m.appendallow_list = nil
  33945. }
  33946. // AllowList returns the value of the "allow_list" field in the mutation.
  33947. func (m *WxMutation) AllowList() (r []string, exists bool) {
  33948. v := m.allow_list
  33949. if v == nil {
  33950. return
  33951. }
  33952. return *v, true
  33953. }
  33954. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  33955. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33957. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  33958. if !m.op.Is(OpUpdateOne) {
  33959. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  33960. }
  33961. if m.id == nil || m.oldValue == nil {
  33962. return v, errors.New("OldAllowList requires an ID field in the mutation")
  33963. }
  33964. oldValue, err := m.oldValue(ctx)
  33965. if err != nil {
  33966. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  33967. }
  33968. return oldValue.AllowList, nil
  33969. }
  33970. // AppendAllowList adds s to the "allow_list" field.
  33971. func (m *WxMutation) AppendAllowList(s []string) {
  33972. m.appendallow_list = append(m.appendallow_list, s...)
  33973. }
  33974. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  33975. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  33976. if len(m.appendallow_list) == 0 {
  33977. return nil, false
  33978. }
  33979. return m.appendallow_list, true
  33980. }
  33981. // ResetAllowList resets all changes to the "allow_list" field.
  33982. func (m *WxMutation) ResetAllowList() {
  33983. m.allow_list = nil
  33984. m.appendallow_list = nil
  33985. }
  33986. // SetGroupAllowList sets the "group_allow_list" field.
  33987. func (m *WxMutation) SetGroupAllowList(s []string) {
  33988. m.group_allow_list = &s
  33989. m.appendgroup_allow_list = nil
  33990. }
  33991. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  33992. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  33993. v := m.group_allow_list
  33994. if v == nil {
  33995. return
  33996. }
  33997. return *v, true
  33998. }
  33999. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  34000. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  34001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34002. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34003. if !m.op.Is(OpUpdateOne) {
  34004. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34005. }
  34006. if m.id == nil || m.oldValue == nil {
  34007. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34008. }
  34009. oldValue, err := m.oldValue(ctx)
  34010. if err != nil {
  34011. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34012. }
  34013. return oldValue.GroupAllowList, nil
  34014. }
  34015. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34016. func (m *WxMutation) AppendGroupAllowList(s []string) {
  34017. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34018. }
  34019. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34020. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  34021. if len(m.appendgroup_allow_list) == 0 {
  34022. return nil, false
  34023. }
  34024. return m.appendgroup_allow_list, true
  34025. }
  34026. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34027. func (m *WxMutation) ResetGroupAllowList() {
  34028. m.group_allow_list = nil
  34029. m.appendgroup_allow_list = nil
  34030. }
  34031. // SetBlockList sets the "block_list" field.
  34032. func (m *WxMutation) SetBlockList(s []string) {
  34033. m.block_list = &s
  34034. m.appendblock_list = nil
  34035. }
  34036. // BlockList returns the value of the "block_list" field in the mutation.
  34037. func (m *WxMutation) BlockList() (r []string, exists bool) {
  34038. v := m.block_list
  34039. if v == nil {
  34040. return
  34041. }
  34042. return *v, true
  34043. }
  34044. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  34045. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  34046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34047. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34048. if !m.op.Is(OpUpdateOne) {
  34049. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34050. }
  34051. if m.id == nil || m.oldValue == nil {
  34052. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34053. }
  34054. oldValue, err := m.oldValue(ctx)
  34055. if err != nil {
  34056. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34057. }
  34058. return oldValue.BlockList, nil
  34059. }
  34060. // AppendBlockList adds s to the "block_list" field.
  34061. func (m *WxMutation) AppendBlockList(s []string) {
  34062. m.appendblock_list = append(m.appendblock_list, s...)
  34063. }
  34064. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34065. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  34066. if len(m.appendblock_list) == 0 {
  34067. return nil, false
  34068. }
  34069. return m.appendblock_list, true
  34070. }
  34071. // ResetBlockList resets all changes to the "block_list" field.
  34072. func (m *WxMutation) ResetBlockList() {
  34073. m.block_list = nil
  34074. m.appendblock_list = nil
  34075. }
  34076. // SetGroupBlockList sets the "group_block_list" field.
  34077. func (m *WxMutation) SetGroupBlockList(s []string) {
  34078. m.group_block_list = &s
  34079. m.appendgroup_block_list = nil
  34080. }
  34081. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34082. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  34083. v := m.group_block_list
  34084. if v == nil {
  34085. return
  34086. }
  34087. return *v, true
  34088. }
  34089. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  34090. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  34091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34092. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34093. if !m.op.Is(OpUpdateOne) {
  34094. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34095. }
  34096. if m.id == nil || m.oldValue == nil {
  34097. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34098. }
  34099. oldValue, err := m.oldValue(ctx)
  34100. if err != nil {
  34101. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34102. }
  34103. return oldValue.GroupBlockList, nil
  34104. }
  34105. // AppendGroupBlockList adds s to the "group_block_list" field.
  34106. func (m *WxMutation) AppendGroupBlockList(s []string) {
  34107. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34108. }
  34109. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34110. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  34111. if len(m.appendgroup_block_list) == 0 {
  34112. return nil, false
  34113. }
  34114. return m.appendgroup_block_list, true
  34115. }
  34116. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34117. func (m *WxMutation) ResetGroupBlockList() {
  34118. m.group_block_list = nil
  34119. m.appendgroup_block_list = nil
  34120. }
  34121. // ClearServer clears the "server" edge to the Server entity.
  34122. func (m *WxMutation) ClearServer() {
  34123. m.clearedserver = true
  34124. m.clearedFields[wx.FieldServerID] = struct{}{}
  34125. }
  34126. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  34127. func (m *WxMutation) ServerCleared() bool {
  34128. return m.ServerIDCleared() || m.clearedserver
  34129. }
  34130. // ServerIDs returns the "server" edge IDs in the mutation.
  34131. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34132. // ServerID instead. It exists only for internal usage by the builders.
  34133. func (m *WxMutation) ServerIDs() (ids []uint64) {
  34134. if id := m.server; id != nil {
  34135. ids = append(ids, *id)
  34136. }
  34137. return
  34138. }
  34139. // ResetServer resets all changes to the "server" edge.
  34140. func (m *WxMutation) ResetServer() {
  34141. m.server = nil
  34142. m.clearedserver = false
  34143. }
  34144. // ClearAgent clears the "agent" edge to the Agent entity.
  34145. func (m *WxMutation) ClearAgent() {
  34146. m.clearedagent = true
  34147. m.clearedFields[wx.FieldAgentID] = struct{}{}
  34148. }
  34149. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34150. func (m *WxMutation) AgentCleared() bool {
  34151. return m.clearedagent
  34152. }
  34153. // AgentIDs returns the "agent" edge IDs in the mutation.
  34154. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34155. // AgentID instead. It exists only for internal usage by the builders.
  34156. func (m *WxMutation) AgentIDs() (ids []uint64) {
  34157. if id := m.agent; id != nil {
  34158. ids = append(ids, *id)
  34159. }
  34160. return
  34161. }
  34162. // ResetAgent resets all changes to the "agent" edge.
  34163. func (m *WxMutation) ResetAgent() {
  34164. m.agent = nil
  34165. m.clearedagent = false
  34166. }
  34167. // Where appends a list predicates to the WxMutation builder.
  34168. func (m *WxMutation) Where(ps ...predicate.Wx) {
  34169. m.predicates = append(m.predicates, ps...)
  34170. }
  34171. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  34172. // users can use type-assertion to append predicates that do not depend on any generated package.
  34173. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  34174. p := make([]predicate.Wx, len(ps))
  34175. for i := range ps {
  34176. p[i] = ps[i]
  34177. }
  34178. m.Where(p...)
  34179. }
  34180. // Op returns the operation name.
  34181. func (m *WxMutation) Op() Op {
  34182. return m.op
  34183. }
  34184. // SetOp allows setting the mutation operation.
  34185. func (m *WxMutation) SetOp(op Op) {
  34186. m.op = op
  34187. }
  34188. // Type returns the node type of this mutation (Wx).
  34189. func (m *WxMutation) Type() string {
  34190. return m.typ
  34191. }
  34192. // Fields returns all fields that were changed during this mutation. Note that in
  34193. // order to get all numeric fields that were incremented/decremented, call
  34194. // AddedFields().
  34195. func (m *WxMutation) Fields() []string {
  34196. fields := make([]string, 0, 21)
  34197. if m.created_at != nil {
  34198. fields = append(fields, wx.FieldCreatedAt)
  34199. }
  34200. if m.updated_at != nil {
  34201. fields = append(fields, wx.FieldUpdatedAt)
  34202. }
  34203. if m.status != nil {
  34204. fields = append(fields, wx.FieldStatus)
  34205. }
  34206. if m.deleted_at != nil {
  34207. fields = append(fields, wx.FieldDeletedAt)
  34208. }
  34209. if m.server != nil {
  34210. fields = append(fields, wx.FieldServerID)
  34211. }
  34212. if m.port != nil {
  34213. fields = append(fields, wx.FieldPort)
  34214. }
  34215. if m.process_id != nil {
  34216. fields = append(fields, wx.FieldProcessID)
  34217. }
  34218. if m.callback != nil {
  34219. fields = append(fields, wx.FieldCallback)
  34220. }
  34221. if m.wxid != nil {
  34222. fields = append(fields, wx.FieldWxid)
  34223. }
  34224. if m.account != nil {
  34225. fields = append(fields, wx.FieldAccount)
  34226. }
  34227. if m.nickname != nil {
  34228. fields = append(fields, wx.FieldNickname)
  34229. }
  34230. if m.tel != nil {
  34231. fields = append(fields, wx.FieldTel)
  34232. }
  34233. if m.head_big != nil {
  34234. fields = append(fields, wx.FieldHeadBig)
  34235. }
  34236. if m.organization_id != nil {
  34237. fields = append(fields, wx.FieldOrganizationID)
  34238. }
  34239. if m.agent != nil {
  34240. fields = append(fields, wx.FieldAgentID)
  34241. }
  34242. if m.api_base != nil {
  34243. fields = append(fields, wx.FieldAPIBase)
  34244. }
  34245. if m.api_key != nil {
  34246. fields = append(fields, wx.FieldAPIKey)
  34247. }
  34248. if m.allow_list != nil {
  34249. fields = append(fields, wx.FieldAllowList)
  34250. }
  34251. if m.group_allow_list != nil {
  34252. fields = append(fields, wx.FieldGroupAllowList)
  34253. }
  34254. if m.block_list != nil {
  34255. fields = append(fields, wx.FieldBlockList)
  34256. }
  34257. if m.group_block_list != nil {
  34258. fields = append(fields, wx.FieldGroupBlockList)
  34259. }
  34260. return fields
  34261. }
  34262. // Field returns the value of a field with the given name. The second boolean
  34263. // return value indicates that this field was not set, or was not defined in the
  34264. // schema.
  34265. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  34266. switch name {
  34267. case wx.FieldCreatedAt:
  34268. return m.CreatedAt()
  34269. case wx.FieldUpdatedAt:
  34270. return m.UpdatedAt()
  34271. case wx.FieldStatus:
  34272. return m.Status()
  34273. case wx.FieldDeletedAt:
  34274. return m.DeletedAt()
  34275. case wx.FieldServerID:
  34276. return m.ServerID()
  34277. case wx.FieldPort:
  34278. return m.Port()
  34279. case wx.FieldProcessID:
  34280. return m.ProcessID()
  34281. case wx.FieldCallback:
  34282. return m.Callback()
  34283. case wx.FieldWxid:
  34284. return m.Wxid()
  34285. case wx.FieldAccount:
  34286. return m.Account()
  34287. case wx.FieldNickname:
  34288. return m.Nickname()
  34289. case wx.FieldTel:
  34290. return m.Tel()
  34291. case wx.FieldHeadBig:
  34292. return m.HeadBig()
  34293. case wx.FieldOrganizationID:
  34294. return m.OrganizationID()
  34295. case wx.FieldAgentID:
  34296. return m.AgentID()
  34297. case wx.FieldAPIBase:
  34298. return m.APIBase()
  34299. case wx.FieldAPIKey:
  34300. return m.APIKey()
  34301. case wx.FieldAllowList:
  34302. return m.AllowList()
  34303. case wx.FieldGroupAllowList:
  34304. return m.GroupAllowList()
  34305. case wx.FieldBlockList:
  34306. return m.BlockList()
  34307. case wx.FieldGroupBlockList:
  34308. return m.GroupBlockList()
  34309. }
  34310. return nil, false
  34311. }
  34312. // OldField returns the old value of the field from the database. An error is
  34313. // returned if the mutation operation is not UpdateOne, or the query to the
  34314. // database failed.
  34315. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34316. switch name {
  34317. case wx.FieldCreatedAt:
  34318. return m.OldCreatedAt(ctx)
  34319. case wx.FieldUpdatedAt:
  34320. return m.OldUpdatedAt(ctx)
  34321. case wx.FieldStatus:
  34322. return m.OldStatus(ctx)
  34323. case wx.FieldDeletedAt:
  34324. return m.OldDeletedAt(ctx)
  34325. case wx.FieldServerID:
  34326. return m.OldServerID(ctx)
  34327. case wx.FieldPort:
  34328. return m.OldPort(ctx)
  34329. case wx.FieldProcessID:
  34330. return m.OldProcessID(ctx)
  34331. case wx.FieldCallback:
  34332. return m.OldCallback(ctx)
  34333. case wx.FieldWxid:
  34334. return m.OldWxid(ctx)
  34335. case wx.FieldAccount:
  34336. return m.OldAccount(ctx)
  34337. case wx.FieldNickname:
  34338. return m.OldNickname(ctx)
  34339. case wx.FieldTel:
  34340. return m.OldTel(ctx)
  34341. case wx.FieldHeadBig:
  34342. return m.OldHeadBig(ctx)
  34343. case wx.FieldOrganizationID:
  34344. return m.OldOrganizationID(ctx)
  34345. case wx.FieldAgentID:
  34346. return m.OldAgentID(ctx)
  34347. case wx.FieldAPIBase:
  34348. return m.OldAPIBase(ctx)
  34349. case wx.FieldAPIKey:
  34350. return m.OldAPIKey(ctx)
  34351. case wx.FieldAllowList:
  34352. return m.OldAllowList(ctx)
  34353. case wx.FieldGroupAllowList:
  34354. return m.OldGroupAllowList(ctx)
  34355. case wx.FieldBlockList:
  34356. return m.OldBlockList(ctx)
  34357. case wx.FieldGroupBlockList:
  34358. return m.OldGroupBlockList(ctx)
  34359. }
  34360. return nil, fmt.Errorf("unknown Wx field %s", name)
  34361. }
  34362. // SetField sets the value of a field with the given name. It returns an error if
  34363. // the field is not defined in the schema, or if the type mismatched the field
  34364. // type.
  34365. func (m *WxMutation) SetField(name string, value ent.Value) error {
  34366. switch name {
  34367. case wx.FieldCreatedAt:
  34368. v, ok := value.(time.Time)
  34369. if !ok {
  34370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34371. }
  34372. m.SetCreatedAt(v)
  34373. return nil
  34374. case wx.FieldUpdatedAt:
  34375. v, ok := value.(time.Time)
  34376. if !ok {
  34377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34378. }
  34379. m.SetUpdatedAt(v)
  34380. return nil
  34381. case wx.FieldStatus:
  34382. v, ok := value.(uint8)
  34383. if !ok {
  34384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34385. }
  34386. m.SetStatus(v)
  34387. return nil
  34388. case wx.FieldDeletedAt:
  34389. v, ok := value.(time.Time)
  34390. if !ok {
  34391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34392. }
  34393. m.SetDeletedAt(v)
  34394. return nil
  34395. case wx.FieldServerID:
  34396. v, ok := value.(uint64)
  34397. if !ok {
  34398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34399. }
  34400. m.SetServerID(v)
  34401. return nil
  34402. case wx.FieldPort:
  34403. v, ok := value.(string)
  34404. if !ok {
  34405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34406. }
  34407. m.SetPort(v)
  34408. return nil
  34409. case wx.FieldProcessID:
  34410. v, ok := value.(string)
  34411. if !ok {
  34412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34413. }
  34414. m.SetProcessID(v)
  34415. return nil
  34416. case wx.FieldCallback:
  34417. v, ok := value.(string)
  34418. if !ok {
  34419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34420. }
  34421. m.SetCallback(v)
  34422. return nil
  34423. case wx.FieldWxid:
  34424. v, ok := value.(string)
  34425. if !ok {
  34426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34427. }
  34428. m.SetWxid(v)
  34429. return nil
  34430. case wx.FieldAccount:
  34431. v, ok := value.(string)
  34432. if !ok {
  34433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34434. }
  34435. m.SetAccount(v)
  34436. return nil
  34437. case wx.FieldNickname:
  34438. v, ok := value.(string)
  34439. if !ok {
  34440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34441. }
  34442. m.SetNickname(v)
  34443. return nil
  34444. case wx.FieldTel:
  34445. v, ok := value.(string)
  34446. if !ok {
  34447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34448. }
  34449. m.SetTel(v)
  34450. return nil
  34451. case wx.FieldHeadBig:
  34452. v, ok := value.(string)
  34453. if !ok {
  34454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34455. }
  34456. m.SetHeadBig(v)
  34457. return nil
  34458. case wx.FieldOrganizationID:
  34459. v, ok := value.(uint64)
  34460. if !ok {
  34461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34462. }
  34463. m.SetOrganizationID(v)
  34464. return nil
  34465. case wx.FieldAgentID:
  34466. v, ok := value.(uint64)
  34467. if !ok {
  34468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34469. }
  34470. m.SetAgentID(v)
  34471. return nil
  34472. case wx.FieldAPIBase:
  34473. v, ok := value.(string)
  34474. if !ok {
  34475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34476. }
  34477. m.SetAPIBase(v)
  34478. return nil
  34479. case wx.FieldAPIKey:
  34480. v, ok := value.(string)
  34481. if !ok {
  34482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34483. }
  34484. m.SetAPIKey(v)
  34485. return nil
  34486. case wx.FieldAllowList:
  34487. v, ok := value.([]string)
  34488. if !ok {
  34489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34490. }
  34491. m.SetAllowList(v)
  34492. return nil
  34493. case wx.FieldGroupAllowList:
  34494. v, ok := value.([]string)
  34495. if !ok {
  34496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34497. }
  34498. m.SetGroupAllowList(v)
  34499. return nil
  34500. case wx.FieldBlockList:
  34501. v, ok := value.([]string)
  34502. if !ok {
  34503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34504. }
  34505. m.SetBlockList(v)
  34506. return nil
  34507. case wx.FieldGroupBlockList:
  34508. v, ok := value.([]string)
  34509. if !ok {
  34510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34511. }
  34512. m.SetGroupBlockList(v)
  34513. return nil
  34514. }
  34515. return fmt.Errorf("unknown Wx field %s", name)
  34516. }
  34517. // AddedFields returns all numeric fields that were incremented/decremented during
  34518. // this mutation.
  34519. func (m *WxMutation) AddedFields() []string {
  34520. var fields []string
  34521. if m.addstatus != nil {
  34522. fields = append(fields, wx.FieldStatus)
  34523. }
  34524. if m.addorganization_id != nil {
  34525. fields = append(fields, wx.FieldOrganizationID)
  34526. }
  34527. return fields
  34528. }
  34529. // AddedField returns the numeric value that was incremented/decremented on a field
  34530. // with the given name. The second boolean return value indicates that this field
  34531. // was not set, or was not defined in the schema.
  34532. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  34533. switch name {
  34534. case wx.FieldStatus:
  34535. return m.AddedStatus()
  34536. case wx.FieldOrganizationID:
  34537. return m.AddedOrganizationID()
  34538. }
  34539. return nil, false
  34540. }
  34541. // AddField adds the value to the field with the given name. It returns an error if
  34542. // the field is not defined in the schema, or if the type mismatched the field
  34543. // type.
  34544. func (m *WxMutation) AddField(name string, value ent.Value) error {
  34545. switch name {
  34546. case wx.FieldStatus:
  34547. v, ok := value.(int8)
  34548. if !ok {
  34549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34550. }
  34551. m.AddStatus(v)
  34552. return nil
  34553. case wx.FieldOrganizationID:
  34554. v, ok := value.(int64)
  34555. if !ok {
  34556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34557. }
  34558. m.AddOrganizationID(v)
  34559. return nil
  34560. }
  34561. return fmt.Errorf("unknown Wx numeric field %s", name)
  34562. }
  34563. // ClearedFields returns all nullable fields that were cleared during this
  34564. // mutation.
  34565. func (m *WxMutation) ClearedFields() []string {
  34566. var fields []string
  34567. if m.FieldCleared(wx.FieldStatus) {
  34568. fields = append(fields, wx.FieldStatus)
  34569. }
  34570. if m.FieldCleared(wx.FieldDeletedAt) {
  34571. fields = append(fields, wx.FieldDeletedAt)
  34572. }
  34573. if m.FieldCleared(wx.FieldServerID) {
  34574. fields = append(fields, wx.FieldServerID)
  34575. }
  34576. if m.FieldCleared(wx.FieldOrganizationID) {
  34577. fields = append(fields, wx.FieldOrganizationID)
  34578. }
  34579. if m.FieldCleared(wx.FieldAPIBase) {
  34580. fields = append(fields, wx.FieldAPIBase)
  34581. }
  34582. if m.FieldCleared(wx.FieldAPIKey) {
  34583. fields = append(fields, wx.FieldAPIKey)
  34584. }
  34585. return fields
  34586. }
  34587. // FieldCleared returns a boolean indicating if a field with the given name was
  34588. // cleared in this mutation.
  34589. func (m *WxMutation) FieldCleared(name string) bool {
  34590. _, ok := m.clearedFields[name]
  34591. return ok
  34592. }
  34593. // ClearField clears the value of the field with the given name. It returns an
  34594. // error if the field is not defined in the schema.
  34595. func (m *WxMutation) ClearField(name string) error {
  34596. switch name {
  34597. case wx.FieldStatus:
  34598. m.ClearStatus()
  34599. return nil
  34600. case wx.FieldDeletedAt:
  34601. m.ClearDeletedAt()
  34602. return nil
  34603. case wx.FieldServerID:
  34604. m.ClearServerID()
  34605. return nil
  34606. case wx.FieldOrganizationID:
  34607. m.ClearOrganizationID()
  34608. return nil
  34609. case wx.FieldAPIBase:
  34610. m.ClearAPIBase()
  34611. return nil
  34612. case wx.FieldAPIKey:
  34613. m.ClearAPIKey()
  34614. return nil
  34615. }
  34616. return fmt.Errorf("unknown Wx nullable field %s", name)
  34617. }
  34618. // ResetField resets all changes in the mutation for the field with the given name.
  34619. // It returns an error if the field is not defined in the schema.
  34620. func (m *WxMutation) ResetField(name string) error {
  34621. switch name {
  34622. case wx.FieldCreatedAt:
  34623. m.ResetCreatedAt()
  34624. return nil
  34625. case wx.FieldUpdatedAt:
  34626. m.ResetUpdatedAt()
  34627. return nil
  34628. case wx.FieldStatus:
  34629. m.ResetStatus()
  34630. return nil
  34631. case wx.FieldDeletedAt:
  34632. m.ResetDeletedAt()
  34633. return nil
  34634. case wx.FieldServerID:
  34635. m.ResetServerID()
  34636. return nil
  34637. case wx.FieldPort:
  34638. m.ResetPort()
  34639. return nil
  34640. case wx.FieldProcessID:
  34641. m.ResetProcessID()
  34642. return nil
  34643. case wx.FieldCallback:
  34644. m.ResetCallback()
  34645. return nil
  34646. case wx.FieldWxid:
  34647. m.ResetWxid()
  34648. return nil
  34649. case wx.FieldAccount:
  34650. m.ResetAccount()
  34651. return nil
  34652. case wx.FieldNickname:
  34653. m.ResetNickname()
  34654. return nil
  34655. case wx.FieldTel:
  34656. m.ResetTel()
  34657. return nil
  34658. case wx.FieldHeadBig:
  34659. m.ResetHeadBig()
  34660. return nil
  34661. case wx.FieldOrganizationID:
  34662. m.ResetOrganizationID()
  34663. return nil
  34664. case wx.FieldAgentID:
  34665. m.ResetAgentID()
  34666. return nil
  34667. case wx.FieldAPIBase:
  34668. m.ResetAPIBase()
  34669. return nil
  34670. case wx.FieldAPIKey:
  34671. m.ResetAPIKey()
  34672. return nil
  34673. case wx.FieldAllowList:
  34674. m.ResetAllowList()
  34675. return nil
  34676. case wx.FieldGroupAllowList:
  34677. m.ResetGroupAllowList()
  34678. return nil
  34679. case wx.FieldBlockList:
  34680. m.ResetBlockList()
  34681. return nil
  34682. case wx.FieldGroupBlockList:
  34683. m.ResetGroupBlockList()
  34684. return nil
  34685. }
  34686. return fmt.Errorf("unknown Wx field %s", name)
  34687. }
  34688. // AddedEdges returns all edge names that were set/added in this mutation.
  34689. func (m *WxMutation) AddedEdges() []string {
  34690. edges := make([]string, 0, 2)
  34691. if m.server != nil {
  34692. edges = append(edges, wx.EdgeServer)
  34693. }
  34694. if m.agent != nil {
  34695. edges = append(edges, wx.EdgeAgent)
  34696. }
  34697. return edges
  34698. }
  34699. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34700. // name in this mutation.
  34701. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  34702. switch name {
  34703. case wx.EdgeServer:
  34704. if id := m.server; id != nil {
  34705. return []ent.Value{*id}
  34706. }
  34707. case wx.EdgeAgent:
  34708. if id := m.agent; id != nil {
  34709. return []ent.Value{*id}
  34710. }
  34711. }
  34712. return nil
  34713. }
  34714. // RemovedEdges returns all edge names that were removed in this mutation.
  34715. func (m *WxMutation) RemovedEdges() []string {
  34716. edges := make([]string, 0, 2)
  34717. return edges
  34718. }
  34719. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34720. // the given name in this mutation.
  34721. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  34722. return nil
  34723. }
  34724. // ClearedEdges returns all edge names that were cleared in this mutation.
  34725. func (m *WxMutation) ClearedEdges() []string {
  34726. edges := make([]string, 0, 2)
  34727. if m.clearedserver {
  34728. edges = append(edges, wx.EdgeServer)
  34729. }
  34730. if m.clearedagent {
  34731. edges = append(edges, wx.EdgeAgent)
  34732. }
  34733. return edges
  34734. }
  34735. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34736. // was cleared in this mutation.
  34737. func (m *WxMutation) EdgeCleared(name string) bool {
  34738. switch name {
  34739. case wx.EdgeServer:
  34740. return m.clearedserver
  34741. case wx.EdgeAgent:
  34742. return m.clearedagent
  34743. }
  34744. return false
  34745. }
  34746. // ClearEdge clears the value of the edge with the given name. It returns an error
  34747. // if that edge is not defined in the schema.
  34748. func (m *WxMutation) ClearEdge(name string) error {
  34749. switch name {
  34750. case wx.EdgeServer:
  34751. m.ClearServer()
  34752. return nil
  34753. case wx.EdgeAgent:
  34754. m.ClearAgent()
  34755. return nil
  34756. }
  34757. return fmt.Errorf("unknown Wx unique edge %s", name)
  34758. }
  34759. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34760. // It returns an error if the edge is not defined in the schema.
  34761. func (m *WxMutation) ResetEdge(name string) error {
  34762. switch name {
  34763. case wx.EdgeServer:
  34764. m.ResetServer()
  34765. return nil
  34766. case wx.EdgeAgent:
  34767. m.ResetAgent()
  34768. return nil
  34769. }
  34770. return fmt.Errorf("unknown Wx edge %s", name)
  34771. }
  34772. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  34773. type WxCardMutation struct {
  34774. config
  34775. op Op
  34776. typ string
  34777. id *uint64
  34778. created_at *time.Time
  34779. updated_at *time.Time
  34780. deleted_at *time.Time
  34781. user_id *uint64
  34782. adduser_id *int64
  34783. wx_user_id *uint64
  34784. addwx_user_id *int64
  34785. avatar *string
  34786. logo *string
  34787. name *string
  34788. company *string
  34789. address *string
  34790. phone *string
  34791. official_account *string
  34792. wechat_account *string
  34793. email *string
  34794. api_base *string
  34795. api_key *string
  34796. ai_info *string
  34797. intro *string
  34798. clearedFields map[string]struct{}
  34799. done bool
  34800. oldValue func(context.Context) (*WxCard, error)
  34801. predicates []predicate.WxCard
  34802. }
  34803. var _ ent.Mutation = (*WxCardMutation)(nil)
  34804. // wxcardOption allows management of the mutation configuration using functional options.
  34805. type wxcardOption func(*WxCardMutation)
  34806. // newWxCardMutation creates new mutation for the WxCard entity.
  34807. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  34808. m := &WxCardMutation{
  34809. config: c,
  34810. op: op,
  34811. typ: TypeWxCard,
  34812. clearedFields: make(map[string]struct{}),
  34813. }
  34814. for _, opt := range opts {
  34815. opt(m)
  34816. }
  34817. return m
  34818. }
  34819. // withWxCardID sets the ID field of the mutation.
  34820. func withWxCardID(id uint64) wxcardOption {
  34821. return func(m *WxCardMutation) {
  34822. var (
  34823. err error
  34824. once sync.Once
  34825. value *WxCard
  34826. )
  34827. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  34828. once.Do(func() {
  34829. if m.done {
  34830. err = errors.New("querying old values post mutation is not allowed")
  34831. } else {
  34832. value, err = m.Client().WxCard.Get(ctx, id)
  34833. }
  34834. })
  34835. return value, err
  34836. }
  34837. m.id = &id
  34838. }
  34839. }
  34840. // withWxCard sets the old WxCard of the mutation.
  34841. func withWxCard(node *WxCard) wxcardOption {
  34842. return func(m *WxCardMutation) {
  34843. m.oldValue = func(context.Context) (*WxCard, error) {
  34844. return node, nil
  34845. }
  34846. m.id = &node.ID
  34847. }
  34848. }
  34849. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34850. // executed in a transaction (ent.Tx), a transactional client is returned.
  34851. func (m WxCardMutation) Client() *Client {
  34852. client := &Client{config: m.config}
  34853. client.init()
  34854. return client
  34855. }
  34856. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34857. // it returns an error otherwise.
  34858. func (m WxCardMutation) Tx() (*Tx, error) {
  34859. if _, ok := m.driver.(*txDriver); !ok {
  34860. return nil, errors.New("ent: mutation is not running in a transaction")
  34861. }
  34862. tx := &Tx{config: m.config}
  34863. tx.init()
  34864. return tx, nil
  34865. }
  34866. // SetID sets the value of the id field. Note that this
  34867. // operation is only accepted on creation of WxCard entities.
  34868. func (m *WxCardMutation) SetID(id uint64) {
  34869. m.id = &id
  34870. }
  34871. // ID returns the ID value in the mutation. Note that the ID is only available
  34872. // if it was provided to the builder or after it was returned from the database.
  34873. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  34874. if m.id == nil {
  34875. return
  34876. }
  34877. return *m.id, true
  34878. }
  34879. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34880. // That means, if the mutation is applied within a transaction with an isolation level such
  34881. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34882. // or updated by the mutation.
  34883. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  34884. switch {
  34885. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34886. id, exists := m.ID()
  34887. if exists {
  34888. return []uint64{id}, nil
  34889. }
  34890. fallthrough
  34891. case m.op.Is(OpUpdate | OpDelete):
  34892. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  34893. default:
  34894. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34895. }
  34896. }
  34897. // SetCreatedAt sets the "created_at" field.
  34898. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  34899. m.created_at = &t
  34900. }
  34901. // CreatedAt returns the value of the "created_at" field in the mutation.
  34902. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  34903. v := m.created_at
  34904. if v == nil {
  34905. return
  34906. }
  34907. return *v, true
  34908. }
  34909. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  34910. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34912. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34913. if !m.op.Is(OpUpdateOne) {
  34914. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34915. }
  34916. if m.id == nil || m.oldValue == nil {
  34917. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34918. }
  34919. oldValue, err := m.oldValue(ctx)
  34920. if err != nil {
  34921. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34922. }
  34923. return oldValue.CreatedAt, nil
  34924. }
  34925. // ResetCreatedAt resets all changes to the "created_at" field.
  34926. func (m *WxCardMutation) ResetCreatedAt() {
  34927. m.created_at = nil
  34928. }
  34929. // SetUpdatedAt sets the "updated_at" field.
  34930. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  34931. m.updated_at = &t
  34932. }
  34933. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34934. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  34935. v := m.updated_at
  34936. if v == nil {
  34937. return
  34938. }
  34939. return *v, true
  34940. }
  34941. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  34942. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34944. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34945. if !m.op.Is(OpUpdateOne) {
  34946. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34947. }
  34948. if m.id == nil || m.oldValue == nil {
  34949. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34950. }
  34951. oldValue, err := m.oldValue(ctx)
  34952. if err != nil {
  34953. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34954. }
  34955. return oldValue.UpdatedAt, nil
  34956. }
  34957. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34958. func (m *WxCardMutation) ResetUpdatedAt() {
  34959. m.updated_at = nil
  34960. }
  34961. // SetDeletedAt sets the "deleted_at" field.
  34962. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  34963. m.deleted_at = &t
  34964. }
  34965. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34966. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  34967. v := m.deleted_at
  34968. if v == nil {
  34969. return
  34970. }
  34971. return *v, true
  34972. }
  34973. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  34974. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34976. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34977. if !m.op.Is(OpUpdateOne) {
  34978. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34979. }
  34980. if m.id == nil || m.oldValue == nil {
  34981. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34982. }
  34983. oldValue, err := m.oldValue(ctx)
  34984. if err != nil {
  34985. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34986. }
  34987. return oldValue.DeletedAt, nil
  34988. }
  34989. // ClearDeletedAt clears the value of the "deleted_at" field.
  34990. func (m *WxCardMutation) ClearDeletedAt() {
  34991. m.deleted_at = nil
  34992. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  34993. }
  34994. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34995. func (m *WxCardMutation) DeletedAtCleared() bool {
  34996. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  34997. return ok
  34998. }
  34999. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35000. func (m *WxCardMutation) ResetDeletedAt() {
  35001. m.deleted_at = nil
  35002. delete(m.clearedFields, wxcard.FieldDeletedAt)
  35003. }
  35004. // SetUserID sets the "user_id" field.
  35005. func (m *WxCardMutation) SetUserID(u uint64) {
  35006. m.user_id = &u
  35007. m.adduser_id = nil
  35008. }
  35009. // UserID returns the value of the "user_id" field in the mutation.
  35010. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  35011. v := m.user_id
  35012. if v == nil {
  35013. return
  35014. }
  35015. return *v, true
  35016. }
  35017. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  35018. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35020. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  35021. if !m.op.Is(OpUpdateOne) {
  35022. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  35023. }
  35024. if m.id == nil || m.oldValue == nil {
  35025. return v, errors.New("OldUserID requires an ID field in the mutation")
  35026. }
  35027. oldValue, err := m.oldValue(ctx)
  35028. if err != nil {
  35029. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  35030. }
  35031. return oldValue.UserID, nil
  35032. }
  35033. // AddUserID adds u to the "user_id" field.
  35034. func (m *WxCardMutation) AddUserID(u int64) {
  35035. if m.adduser_id != nil {
  35036. *m.adduser_id += u
  35037. } else {
  35038. m.adduser_id = &u
  35039. }
  35040. }
  35041. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  35042. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  35043. v := m.adduser_id
  35044. if v == nil {
  35045. return
  35046. }
  35047. return *v, true
  35048. }
  35049. // ClearUserID clears the value of the "user_id" field.
  35050. func (m *WxCardMutation) ClearUserID() {
  35051. m.user_id = nil
  35052. m.adduser_id = nil
  35053. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  35054. }
  35055. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  35056. func (m *WxCardMutation) UserIDCleared() bool {
  35057. _, ok := m.clearedFields[wxcard.FieldUserID]
  35058. return ok
  35059. }
  35060. // ResetUserID resets all changes to the "user_id" field.
  35061. func (m *WxCardMutation) ResetUserID() {
  35062. m.user_id = nil
  35063. m.adduser_id = nil
  35064. delete(m.clearedFields, wxcard.FieldUserID)
  35065. }
  35066. // SetWxUserID sets the "wx_user_id" field.
  35067. func (m *WxCardMutation) SetWxUserID(u uint64) {
  35068. m.wx_user_id = &u
  35069. m.addwx_user_id = nil
  35070. }
  35071. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  35072. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  35073. v := m.wx_user_id
  35074. if v == nil {
  35075. return
  35076. }
  35077. return *v, true
  35078. }
  35079. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  35080. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35082. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  35083. if !m.op.Is(OpUpdateOne) {
  35084. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  35085. }
  35086. if m.id == nil || m.oldValue == nil {
  35087. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  35088. }
  35089. oldValue, err := m.oldValue(ctx)
  35090. if err != nil {
  35091. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  35092. }
  35093. return oldValue.WxUserID, nil
  35094. }
  35095. // AddWxUserID adds u to the "wx_user_id" field.
  35096. func (m *WxCardMutation) AddWxUserID(u int64) {
  35097. if m.addwx_user_id != nil {
  35098. *m.addwx_user_id += u
  35099. } else {
  35100. m.addwx_user_id = &u
  35101. }
  35102. }
  35103. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  35104. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  35105. v := m.addwx_user_id
  35106. if v == nil {
  35107. return
  35108. }
  35109. return *v, true
  35110. }
  35111. // ClearWxUserID clears the value of the "wx_user_id" field.
  35112. func (m *WxCardMutation) ClearWxUserID() {
  35113. m.wx_user_id = nil
  35114. m.addwx_user_id = nil
  35115. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  35116. }
  35117. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  35118. func (m *WxCardMutation) WxUserIDCleared() bool {
  35119. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  35120. return ok
  35121. }
  35122. // ResetWxUserID resets all changes to the "wx_user_id" field.
  35123. func (m *WxCardMutation) ResetWxUserID() {
  35124. m.wx_user_id = nil
  35125. m.addwx_user_id = nil
  35126. delete(m.clearedFields, wxcard.FieldWxUserID)
  35127. }
  35128. // SetAvatar sets the "avatar" field.
  35129. func (m *WxCardMutation) SetAvatar(s string) {
  35130. m.avatar = &s
  35131. }
  35132. // Avatar returns the value of the "avatar" field in the mutation.
  35133. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  35134. v := m.avatar
  35135. if v == nil {
  35136. return
  35137. }
  35138. return *v, true
  35139. }
  35140. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  35141. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35143. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  35144. if !m.op.Is(OpUpdateOne) {
  35145. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  35146. }
  35147. if m.id == nil || m.oldValue == nil {
  35148. return v, errors.New("OldAvatar requires an ID field in the mutation")
  35149. }
  35150. oldValue, err := m.oldValue(ctx)
  35151. if err != nil {
  35152. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  35153. }
  35154. return oldValue.Avatar, nil
  35155. }
  35156. // ResetAvatar resets all changes to the "avatar" field.
  35157. func (m *WxCardMutation) ResetAvatar() {
  35158. m.avatar = nil
  35159. }
  35160. // SetLogo sets the "logo" field.
  35161. func (m *WxCardMutation) SetLogo(s string) {
  35162. m.logo = &s
  35163. }
  35164. // Logo returns the value of the "logo" field in the mutation.
  35165. func (m *WxCardMutation) Logo() (r string, exists bool) {
  35166. v := m.logo
  35167. if v == nil {
  35168. return
  35169. }
  35170. return *v, true
  35171. }
  35172. // OldLogo returns the old "logo" field's value of the WxCard entity.
  35173. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35175. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  35176. if !m.op.Is(OpUpdateOne) {
  35177. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  35178. }
  35179. if m.id == nil || m.oldValue == nil {
  35180. return v, errors.New("OldLogo requires an ID field in the mutation")
  35181. }
  35182. oldValue, err := m.oldValue(ctx)
  35183. if err != nil {
  35184. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  35185. }
  35186. return oldValue.Logo, nil
  35187. }
  35188. // ResetLogo resets all changes to the "logo" field.
  35189. func (m *WxCardMutation) ResetLogo() {
  35190. m.logo = nil
  35191. }
  35192. // SetName sets the "name" field.
  35193. func (m *WxCardMutation) SetName(s string) {
  35194. m.name = &s
  35195. }
  35196. // Name returns the value of the "name" field in the mutation.
  35197. func (m *WxCardMutation) Name() (r string, exists bool) {
  35198. v := m.name
  35199. if v == nil {
  35200. return
  35201. }
  35202. return *v, true
  35203. }
  35204. // OldName returns the old "name" field's value of the WxCard entity.
  35205. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35207. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  35208. if !m.op.Is(OpUpdateOne) {
  35209. return v, errors.New("OldName is only allowed on UpdateOne operations")
  35210. }
  35211. if m.id == nil || m.oldValue == nil {
  35212. return v, errors.New("OldName requires an ID field in the mutation")
  35213. }
  35214. oldValue, err := m.oldValue(ctx)
  35215. if err != nil {
  35216. return v, fmt.Errorf("querying old value for OldName: %w", err)
  35217. }
  35218. return oldValue.Name, nil
  35219. }
  35220. // ResetName resets all changes to the "name" field.
  35221. func (m *WxCardMutation) ResetName() {
  35222. m.name = nil
  35223. }
  35224. // SetCompany sets the "company" field.
  35225. func (m *WxCardMutation) SetCompany(s string) {
  35226. m.company = &s
  35227. }
  35228. // Company returns the value of the "company" field in the mutation.
  35229. func (m *WxCardMutation) Company() (r string, exists bool) {
  35230. v := m.company
  35231. if v == nil {
  35232. return
  35233. }
  35234. return *v, true
  35235. }
  35236. // OldCompany returns the old "company" field's value of the WxCard entity.
  35237. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35239. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  35240. if !m.op.Is(OpUpdateOne) {
  35241. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  35242. }
  35243. if m.id == nil || m.oldValue == nil {
  35244. return v, errors.New("OldCompany requires an ID field in the mutation")
  35245. }
  35246. oldValue, err := m.oldValue(ctx)
  35247. if err != nil {
  35248. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  35249. }
  35250. return oldValue.Company, nil
  35251. }
  35252. // ResetCompany resets all changes to the "company" field.
  35253. func (m *WxCardMutation) ResetCompany() {
  35254. m.company = nil
  35255. }
  35256. // SetAddress sets the "address" field.
  35257. func (m *WxCardMutation) SetAddress(s string) {
  35258. m.address = &s
  35259. }
  35260. // Address returns the value of the "address" field in the mutation.
  35261. func (m *WxCardMutation) Address() (r string, exists bool) {
  35262. v := m.address
  35263. if v == nil {
  35264. return
  35265. }
  35266. return *v, true
  35267. }
  35268. // OldAddress returns the old "address" field's value of the WxCard entity.
  35269. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35271. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  35272. if !m.op.Is(OpUpdateOne) {
  35273. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  35274. }
  35275. if m.id == nil || m.oldValue == nil {
  35276. return v, errors.New("OldAddress requires an ID field in the mutation")
  35277. }
  35278. oldValue, err := m.oldValue(ctx)
  35279. if err != nil {
  35280. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  35281. }
  35282. return oldValue.Address, nil
  35283. }
  35284. // ResetAddress resets all changes to the "address" field.
  35285. func (m *WxCardMutation) ResetAddress() {
  35286. m.address = nil
  35287. }
  35288. // SetPhone sets the "phone" field.
  35289. func (m *WxCardMutation) SetPhone(s string) {
  35290. m.phone = &s
  35291. }
  35292. // Phone returns the value of the "phone" field in the mutation.
  35293. func (m *WxCardMutation) Phone() (r string, exists bool) {
  35294. v := m.phone
  35295. if v == nil {
  35296. return
  35297. }
  35298. return *v, true
  35299. }
  35300. // OldPhone returns the old "phone" field's value of the WxCard entity.
  35301. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35303. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  35304. if !m.op.Is(OpUpdateOne) {
  35305. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35306. }
  35307. if m.id == nil || m.oldValue == nil {
  35308. return v, errors.New("OldPhone requires an ID field in the mutation")
  35309. }
  35310. oldValue, err := m.oldValue(ctx)
  35311. if err != nil {
  35312. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35313. }
  35314. return oldValue.Phone, nil
  35315. }
  35316. // ResetPhone resets all changes to the "phone" field.
  35317. func (m *WxCardMutation) ResetPhone() {
  35318. m.phone = nil
  35319. }
  35320. // SetOfficialAccount sets the "official_account" field.
  35321. func (m *WxCardMutation) SetOfficialAccount(s string) {
  35322. m.official_account = &s
  35323. }
  35324. // OfficialAccount returns the value of the "official_account" field in the mutation.
  35325. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  35326. v := m.official_account
  35327. if v == nil {
  35328. return
  35329. }
  35330. return *v, true
  35331. }
  35332. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  35333. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35335. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  35336. if !m.op.Is(OpUpdateOne) {
  35337. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  35338. }
  35339. if m.id == nil || m.oldValue == nil {
  35340. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  35341. }
  35342. oldValue, err := m.oldValue(ctx)
  35343. if err != nil {
  35344. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  35345. }
  35346. return oldValue.OfficialAccount, nil
  35347. }
  35348. // ResetOfficialAccount resets all changes to the "official_account" field.
  35349. func (m *WxCardMutation) ResetOfficialAccount() {
  35350. m.official_account = nil
  35351. }
  35352. // SetWechatAccount sets the "wechat_account" field.
  35353. func (m *WxCardMutation) SetWechatAccount(s string) {
  35354. m.wechat_account = &s
  35355. }
  35356. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  35357. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  35358. v := m.wechat_account
  35359. if v == nil {
  35360. return
  35361. }
  35362. return *v, true
  35363. }
  35364. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  35365. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35367. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  35368. if !m.op.Is(OpUpdateOne) {
  35369. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  35370. }
  35371. if m.id == nil || m.oldValue == nil {
  35372. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  35373. }
  35374. oldValue, err := m.oldValue(ctx)
  35375. if err != nil {
  35376. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  35377. }
  35378. return oldValue.WechatAccount, nil
  35379. }
  35380. // ResetWechatAccount resets all changes to the "wechat_account" field.
  35381. func (m *WxCardMutation) ResetWechatAccount() {
  35382. m.wechat_account = nil
  35383. }
  35384. // SetEmail sets the "email" field.
  35385. func (m *WxCardMutation) SetEmail(s string) {
  35386. m.email = &s
  35387. }
  35388. // Email returns the value of the "email" field in the mutation.
  35389. func (m *WxCardMutation) Email() (r string, exists bool) {
  35390. v := m.email
  35391. if v == nil {
  35392. return
  35393. }
  35394. return *v, true
  35395. }
  35396. // OldEmail returns the old "email" field's value of the WxCard entity.
  35397. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35399. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  35400. if !m.op.Is(OpUpdateOne) {
  35401. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  35402. }
  35403. if m.id == nil || m.oldValue == nil {
  35404. return v, errors.New("OldEmail requires an ID field in the mutation")
  35405. }
  35406. oldValue, err := m.oldValue(ctx)
  35407. if err != nil {
  35408. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  35409. }
  35410. return oldValue.Email, nil
  35411. }
  35412. // ClearEmail clears the value of the "email" field.
  35413. func (m *WxCardMutation) ClearEmail() {
  35414. m.email = nil
  35415. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  35416. }
  35417. // EmailCleared returns if the "email" field was cleared in this mutation.
  35418. func (m *WxCardMutation) EmailCleared() bool {
  35419. _, ok := m.clearedFields[wxcard.FieldEmail]
  35420. return ok
  35421. }
  35422. // ResetEmail resets all changes to the "email" field.
  35423. func (m *WxCardMutation) ResetEmail() {
  35424. m.email = nil
  35425. delete(m.clearedFields, wxcard.FieldEmail)
  35426. }
  35427. // SetAPIBase sets the "api_base" field.
  35428. func (m *WxCardMutation) SetAPIBase(s string) {
  35429. m.api_base = &s
  35430. }
  35431. // APIBase returns the value of the "api_base" field in the mutation.
  35432. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  35433. v := m.api_base
  35434. if v == nil {
  35435. return
  35436. }
  35437. return *v, true
  35438. }
  35439. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  35440. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35442. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35443. if !m.op.Is(OpUpdateOne) {
  35444. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35445. }
  35446. if m.id == nil || m.oldValue == nil {
  35447. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35448. }
  35449. oldValue, err := m.oldValue(ctx)
  35450. if err != nil {
  35451. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35452. }
  35453. return oldValue.APIBase, nil
  35454. }
  35455. // ClearAPIBase clears the value of the "api_base" field.
  35456. func (m *WxCardMutation) ClearAPIBase() {
  35457. m.api_base = nil
  35458. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  35459. }
  35460. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35461. func (m *WxCardMutation) APIBaseCleared() bool {
  35462. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  35463. return ok
  35464. }
  35465. // ResetAPIBase resets all changes to the "api_base" field.
  35466. func (m *WxCardMutation) ResetAPIBase() {
  35467. m.api_base = nil
  35468. delete(m.clearedFields, wxcard.FieldAPIBase)
  35469. }
  35470. // SetAPIKey sets the "api_key" field.
  35471. func (m *WxCardMutation) SetAPIKey(s string) {
  35472. m.api_key = &s
  35473. }
  35474. // APIKey returns the value of the "api_key" field in the mutation.
  35475. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  35476. v := m.api_key
  35477. if v == nil {
  35478. return
  35479. }
  35480. return *v, true
  35481. }
  35482. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  35483. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35485. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35486. if !m.op.Is(OpUpdateOne) {
  35487. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35488. }
  35489. if m.id == nil || m.oldValue == nil {
  35490. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35491. }
  35492. oldValue, err := m.oldValue(ctx)
  35493. if err != nil {
  35494. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35495. }
  35496. return oldValue.APIKey, nil
  35497. }
  35498. // ClearAPIKey clears the value of the "api_key" field.
  35499. func (m *WxCardMutation) ClearAPIKey() {
  35500. m.api_key = nil
  35501. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  35502. }
  35503. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35504. func (m *WxCardMutation) APIKeyCleared() bool {
  35505. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  35506. return ok
  35507. }
  35508. // ResetAPIKey resets all changes to the "api_key" field.
  35509. func (m *WxCardMutation) ResetAPIKey() {
  35510. m.api_key = nil
  35511. delete(m.clearedFields, wxcard.FieldAPIKey)
  35512. }
  35513. // SetAiInfo sets the "ai_info" field.
  35514. func (m *WxCardMutation) SetAiInfo(s string) {
  35515. m.ai_info = &s
  35516. }
  35517. // AiInfo returns the value of the "ai_info" field in the mutation.
  35518. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  35519. v := m.ai_info
  35520. if v == nil {
  35521. return
  35522. }
  35523. return *v, true
  35524. }
  35525. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  35526. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35528. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  35529. if !m.op.Is(OpUpdateOne) {
  35530. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  35531. }
  35532. if m.id == nil || m.oldValue == nil {
  35533. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  35534. }
  35535. oldValue, err := m.oldValue(ctx)
  35536. if err != nil {
  35537. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  35538. }
  35539. return oldValue.AiInfo, nil
  35540. }
  35541. // ClearAiInfo clears the value of the "ai_info" field.
  35542. func (m *WxCardMutation) ClearAiInfo() {
  35543. m.ai_info = nil
  35544. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  35545. }
  35546. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  35547. func (m *WxCardMutation) AiInfoCleared() bool {
  35548. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  35549. return ok
  35550. }
  35551. // ResetAiInfo resets all changes to the "ai_info" field.
  35552. func (m *WxCardMutation) ResetAiInfo() {
  35553. m.ai_info = nil
  35554. delete(m.clearedFields, wxcard.FieldAiInfo)
  35555. }
  35556. // SetIntro sets the "intro" field.
  35557. func (m *WxCardMutation) SetIntro(s string) {
  35558. m.intro = &s
  35559. }
  35560. // Intro returns the value of the "intro" field in the mutation.
  35561. func (m *WxCardMutation) Intro() (r string, exists bool) {
  35562. v := m.intro
  35563. if v == nil {
  35564. return
  35565. }
  35566. return *v, true
  35567. }
  35568. // OldIntro returns the old "intro" field's value of the WxCard entity.
  35569. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  35570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35571. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  35572. if !m.op.Is(OpUpdateOne) {
  35573. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  35574. }
  35575. if m.id == nil || m.oldValue == nil {
  35576. return v, errors.New("OldIntro requires an ID field in the mutation")
  35577. }
  35578. oldValue, err := m.oldValue(ctx)
  35579. if err != nil {
  35580. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  35581. }
  35582. return oldValue.Intro, nil
  35583. }
  35584. // ClearIntro clears the value of the "intro" field.
  35585. func (m *WxCardMutation) ClearIntro() {
  35586. m.intro = nil
  35587. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  35588. }
  35589. // IntroCleared returns if the "intro" field was cleared in this mutation.
  35590. func (m *WxCardMutation) IntroCleared() bool {
  35591. _, ok := m.clearedFields[wxcard.FieldIntro]
  35592. return ok
  35593. }
  35594. // ResetIntro resets all changes to the "intro" field.
  35595. func (m *WxCardMutation) ResetIntro() {
  35596. m.intro = nil
  35597. delete(m.clearedFields, wxcard.FieldIntro)
  35598. }
  35599. // Where appends a list predicates to the WxCardMutation builder.
  35600. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  35601. m.predicates = append(m.predicates, ps...)
  35602. }
  35603. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  35604. // users can use type-assertion to append predicates that do not depend on any generated package.
  35605. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  35606. p := make([]predicate.WxCard, len(ps))
  35607. for i := range ps {
  35608. p[i] = ps[i]
  35609. }
  35610. m.Where(p...)
  35611. }
  35612. // Op returns the operation name.
  35613. func (m *WxCardMutation) Op() Op {
  35614. return m.op
  35615. }
  35616. // SetOp allows setting the mutation operation.
  35617. func (m *WxCardMutation) SetOp(op Op) {
  35618. m.op = op
  35619. }
  35620. // Type returns the node type of this mutation (WxCard).
  35621. func (m *WxCardMutation) Type() string {
  35622. return m.typ
  35623. }
  35624. // Fields returns all fields that were changed during this mutation. Note that in
  35625. // order to get all numeric fields that were incremented/decremented, call
  35626. // AddedFields().
  35627. func (m *WxCardMutation) Fields() []string {
  35628. fields := make([]string, 0, 18)
  35629. if m.created_at != nil {
  35630. fields = append(fields, wxcard.FieldCreatedAt)
  35631. }
  35632. if m.updated_at != nil {
  35633. fields = append(fields, wxcard.FieldUpdatedAt)
  35634. }
  35635. if m.deleted_at != nil {
  35636. fields = append(fields, wxcard.FieldDeletedAt)
  35637. }
  35638. if m.user_id != nil {
  35639. fields = append(fields, wxcard.FieldUserID)
  35640. }
  35641. if m.wx_user_id != nil {
  35642. fields = append(fields, wxcard.FieldWxUserID)
  35643. }
  35644. if m.avatar != nil {
  35645. fields = append(fields, wxcard.FieldAvatar)
  35646. }
  35647. if m.logo != nil {
  35648. fields = append(fields, wxcard.FieldLogo)
  35649. }
  35650. if m.name != nil {
  35651. fields = append(fields, wxcard.FieldName)
  35652. }
  35653. if m.company != nil {
  35654. fields = append(fields, wxcard.FieldCompany)
  35655. }
  35656. if m.address != nil {
  35657. fields = append(fields, wxcard.FieldAddress)
  35658. }
  35659. if m.phone != nil {
  35660. fields = append(fields, wxcard.FieldPhone)
  35661. }
  35662. if m.official_account != nil {
  35663. fields = append(fields, wxcard.FieldOfficialAccount)
  35664. }
  35665. if m.wechat_account != nil {
  35666. fields = append(fields, wxcard.FieldWechatAccount)
  35667. }
  35668. if m.email != nil {
  35669. fields = append(fields, wxcard.FieldEmail)
  35670. }
  35671. if m.api_base != nil {
  35672. fields = append(fields, wxcard.FieldAPIBase)
  35673. }
  35674. if m.api_key != nil {
  35675. fields = append(fields, wxcard.FieldAPIKey)
  35676. }
  35677. if m.ai_info != nil {
  35678. fields = append(fields, wxcard.FieldAiInfo)
  35679. }
  35680. if m.intro != nil {
  35681. fields = append(fields, wxcard.FieldIntro)
  35682. }
  35683. return fields
  35684. }
  35685. // Field returns the value of a field with the given name. The second boolean
  35686. // return value indicates that this field was not set, or was not defined in the
  35687. // schema.
  35688. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  35689. switch name {
  35690. case wxcard.FieldCreatedAt:
  35691. return m.CreatedAt()
  35692. case wxcard.FieldUpdatedAt:
  35693. return m.UpdatedAt()
  35694. case wxcard.FieldDeletedAt:
  35695. return m.DeletedAt()
  35696. case wxcard.FieldUserID:
  35697. return m.UserID()
  35698. case wxcard.FieldWxUserID:
  35699. return m.WxUserID()
  35700. case wxcard.FieldAvatar:
  35701. return m.Avatar()
  35702. case wxcard.FieldLogo:
  35703. return m.Logo()
  35704. case wxcard.FieldName:
  35705. return m.Name()
  35706. case wxcard.FieldCompany:
  35707. return m.Company()
  35708. case wxcard.FieldAddress:
  35709. return m.Address()
  35710. case wxcard.FieldPhone:
  35711. return m.Phone()
  35712. case wxcard.FieldOfficialAccount:
  35713. return m.OfficialAccount()
  35714. case wxcard.FieldWechatAccount:
  35715. return m.WechatAccount()
  35716. case wxcard.FieldEmail:
  35717. return m.Email()
  35718. case wxcard.FieldAPIBase:
  35719. return m.APIBase()
  35720. case wxcard.FieldAPIKey:
  35721. return m.APIKey()
  35722. case wxcard.FieldAiInfo:
  35723. return m.AiInfo()
  35724. case wxcard.FieldIntro:
  35725. return m.Intro()
  35726. }
  35727. return nil, false
  35728. }
  35729. // OldField returns the old value of the field from the database. An error is
  35730. // returned if the mutation operation is not UpdateOne, or the query to the
  35731. // database failed.
  35732. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35733. switch name {
  35734. case wxcard.FieldCreatedAt:
  35735. return m.OldCreatedAt(ctx)
  35736. case wxcard.FieldUpdatedAt:
  35737. return m.OldUpdatedAt(ctx)
  35738. case wxcard.FieldDeletedAt:
  35739. return m.OldDeletedAt(ctx)
  35740. case wxcard.FieldUserID:
  35741. return m.OldUserID(ctx)
  35742. case wxcard.FieldWxUserID:
  35743. return m.OldWxUserID(ctx)
  35744. case wxcard.FieldAvatar:
  35745. return m.OldAvatar(ctx)
  35746. case wxcard.FieldLogo:
  35747. return m.OldLogo(ctx)
  35748. case wxcard.FieldName:
  35749. return m.OldName(ctx)
  35750. case wxcard.FieldCompany:
  35751. return m.OldCompany(ctx)
  35752. case wxcard.FieldAddress:
  35753. return m.OldAddress(ctx)
  35754. case wxcard.FieldPhone:
  35755. return m.OldPhone(ctx)
  35756. case wxcard.FieldOfficialAccount:
  35757. return m.OldOfficialAccount(ctx)
  35758. case wxcard.FieldWechatAccount:
  35759. return m.OldWechatAccount(ctx)
  35760. case wxcard.FieldEmail:
  35761. return m.OldEmail(ctx)
  35762. case wxcard.FieldAPIBase:
  35763. return m.OldAPIBase(ctx)
  35764. case wxcard.FieldAPIKey:
  35765. return m.OldAPIKey(ctx)
  35766. case wxcard.FieldAiInfo:
  35767. return m.OldAiInfo(ctx)
  35768. case wxcard.FieldIntro:
  35769. return m.OldIntro(ctx)
  35770. }
  35771. return nil, fmt.Errorf("unknown WxCard field %s", name)
  35772. }
  35773. // SetField sets the value of a field with the given name. It returns an error if
  35774. // the field is not defined in the schema, or if the type mismatched the field
  35775. // type.
  35776. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  35777. switch name {
  35778. case wxcard.FieldCreatedAt:
  35779. v, ok := value.(time.Time)
  35780. if !ok {
  35781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35782. }
  35783. m.SetCreatedAt(v)
  35784. return nil
  35785. case wxcard.FieldUpdatedAt:
  35786. v, ok := value.(time.Time)
  35787. if !ok {
  35788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35789. }
  35790. m.SetUpdatedAt(v)
  35791. return nil
  35792. case wxcard.FieldDeletedAt:
  35793. v, ok := value.(time.Time)
  35794. if !ok {
  35795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35796. }
  35797. m.SetDeletedAt(v)
  35798. return nil
  35799. case wxcard.FieldUserID:
  35800. v, ok := value.(uint64)
  35801. if !ok {
  35802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35803. }
  35804. m.SetUserID(v)
  35805. return nil
  35806. case wxcard.FieldWxUserID:
  35807. v, ok := value.(uint64)
  35808. if !ok {
  35809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35810. }
  35811. m.SetWxUserID(v)
  35812. return nil
  35813. case wxcard.FieldAvatar:
  35814. v, ok := value.(string)
  35815. if !ok {
  35816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35817. }
  35818. m.SetAvatar(v)
  35819. return nil
  35820. case wxcard.FieldLogo:
  35821. v, ok := value.(string)
  35822. if !ok {
  35823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35824. }
  35825. m.SetLogo(v)
  35826. return nil
  35827. case wxcard.FieldName:
  35828. v, ok := value.(string)
  35829. if !ok {
  35830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35831. }
  35832. m.SetName(v)
  35833. return nil
  35834. case wxcard.FieldCompany:
  35835. v, ok := value.(string)
  35836. if !ok {
  35837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35838. }
  35839. m.SetCompany(v)
  35840. return nil
  35841. case wxcard.FieldAddress:
  35842. v, ok := value.(string)
  35843. if !ok {
  35844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35845. }
  35846. m.SetAddress(v)
  35847. return nil
  35848. case wxcard.FieldPhone:
  35849. v, ok := value.(string)
  35850. if !ok {
  35851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35852. }
  35853. m.SetPhone(v)
  35854. return nil
  35855. case wxcard.FieldOfficialAccount:
  35856. v, ok := value.(string)
  35857. if !ok {
  35858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35859. }
  35860. m.SetOfficialAccount(v)
  35861. return nil
  35862. case wxcard.FieldWechatAccount:
  35863. v, ok := value.(string)
  35864. if !ok {
  35865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35866. }
  35867. m.SetWechatAccount(v)
  35868. return nil
  35869. case wxcard.FieldEmail:
  35870. v, ok := value.(string)
  35871. if !ok {
  35872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35873. }
  35874. m.SetEmail(v)
  35875. return nil
  35876. case wxcard.FieldAPIBase:
  35877. v, ok := value.(string)
  35878. if !ok {
  35879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35880. }
  35881. m.SetAPIBase(v)
  35882. return nil
  35883. case wxcard.FieldAPIKey:
  35884. v, ok := value.(string)
  35885. if !ok {
  35886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35887. }
  35888. m.SetAPIKey(v)
  35889. return nil
  35890. case wxcard.FieldAiInfo:
  35891. v, ok := value.(string)
  35892. if !ok {
  35893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35894. }
  35895. m.SetAiInfo(v)
  35896. return nil
  35897. case wxcard.FieldIntro:
  35898. v, ok := value.(string)
  35899. if !ok {
  35900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35901. }
  35902. m.SetIntro(v)
  35903. return nil
  35904. }
  35905. return fmt.Errorf("unknown WxCard field %s", name)
  35906. }
  35907. // AddedFields returns all numeric fields that were incremented/decremented during
  35908. // this mutation.
  35909. func (m *WxCardMutation) AddedFields() []string {
  35910. var fields []string
  35911. if m.adduser_id != nil {
  35912. fields = append(fields, wxcard.FieldUserID)
  35913. }
  35914. if m.addwx_user_id != nil {
  35915. fields = append(fields, wxcard.FieldWxUserID)
  35916. }
  35917. return fields
  35918. }
  35919. // AddedField returns the numeric value that was incremented/decremented on a field
  35920. // with the given name. The second boolean return value indicates that this field
  35921. // was not set, or was not defined in the schema.
  35922. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  35923. switch name {
  35924. case wxcard.FieldUserID:
  35925. return m.AddedUserID()
  35926. case wxcard.FieldWxUserID:
  35927. return m.AddedWxUserID()
  35928. }
  35929. return nil, false
  35930. }
  35931. // AddField adds the value to the 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 *WxCardMutation) AddField(name string, value ent.Value) error {
  35935. switch name {
  35936. case wxcard.FieldUserID:
  35937. v, ok := value.(int64)
  35938. if !ok {
  35939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35940. }
  35941. m.AddUserID(v)
  35942. return nil
  35943. case wxcard.FieldWxUserID:
  35944. v, ok := value.(int64)
  35945. if !ok {
  35946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35947. }
  35948. m.AddWxUserID(v)
  35949. return nil
  35950. }
  35951. return fmt.Errorf("unknown WxCard numeric field %s", name)
  35952. }
  35953. // ClearedFields returns all nullable fields that were cleared during this
  35954. // mutation.
  35955. func (m *WxCardMutation) ClearedFields() []string {
  35956. var fields []string
  35957. if m.FieldCleared(wxcard.FieldDeletedAt) {
  35958. fields = append(fields, wxcard.FieldDeletedAt)
  35959. }
  35960. if m.FieldCleared(wxcard.FieldUserID) {
  35961. fields = append(fields, wxcard.FieldUserID)
  35962. }
  35963. if m.FieldCleared(wxcard.FieldWxUserID) {
  35964. fields = append(fields, wxcard.FieldWxUserID)
  35965. }
  35966. if m.FieldCleared(wxcard.FieldEmail) {
  35967. fields = append(fields, wxcard.FieldEmail)
  35968. }
  35969. if m.FieldCleared(wxcard.FieldAPIBase) {
  35970. fields = append(fields, wxcard.FieldAPIBase)
  35971. }
  35972. if m.FieldCleared(wxcard.FieldAPIKey) {
  35973. fields = append(fields, wxcard.FieldAPIKey)
  35974. }
  35975. if m.FieldCleared(wxcard.FieldAiInfo) {
  35976. fields = append(fields, wxcard.FieldAiInfo)
  35977. }
  35978. if m.FieldCleared(wxcard.FieldIntro) {
  35979. fields = append(fields, wxcard.FieldIntro)
  35980. }
  35981. return fields
  35982. }
  35983. // FieldCleared returns a boolean indicating if a field with the given name was
  35984. // cleared in this mutation.
  35985. func (m *WxCardMutation) FieldCleared(name string) bool {
  35986. _, ok := m.clearedFields[name]
  35987. return ok
  35988. }
  35989. // ClearField clears the value of the field with the given name. It returns an
  35990. // error if the field is not defined in the schema.
  35991. func (m *WxCardMutation) ClearField(name string) error {
  35992. switch name {
  35993. case wxcard.FieldDeletedAt:
  35994. m.ClearDeletedAt()
  35995. return nil
  35996. case wxcard.FieldUserID:
  35997. m.ClearUserID()
  35998. return nil
  35999. case wxcard.FieldWxUserID:
  36000. m.ClearWxUserID()
  36001. return nil
  36002. case wxcard.FieldEmail:
  36003. m.ClearEmail()
  36004. return nil
  36005. case wxcard.FieldAPIBase:
  36006. m.ClearAPIBase()
  36007. return nil
  36008. case wxcard.FieldAPIKey:
  36009. m.ClearAPIKey()
  36010. return nil
  36011. case wxcard.FieldAiInfo:
  36012. m.ClearAiInfo()
  36013. return nil
  36014. case wxcard.FieldIntro:
  36015. m.ClearIntro()
  36016. return nil
  36017. }
  36018. return fmt.Errorf("unknown WxCard nullable field %s", name)
  36019. }
  36020. // ResetField resets all changes in the mutation for the field with the given name.
  36021. // It returns an error if the field is not defined in the schema.
  36022. func (m *WxCardMutation) ResetField(name string) error {
  36023. switch name {
  36024. case wxcard.FieldCreatedAt:
  36025. m.ResetCreatedAt()
  36026. return nil
  36027. case wxcard.FieldUpdatedAt:
  36028. m.ResetUpdatedAt()
  36029. return nil
  36030. case wxcard.FieldDeletedAt:
  36031. m.ResetDeletedAt()
  36032. return nil
  36033. case wxcard.FieldUserID:
  36034. m.ResetUserID()
  36035. return nil
  36036. case wxcard.FieldWxUserID:
  36037. m.ResetWxUserID()
  36038. return nil
  36039. case wxcard.FieldAvatar:
  36040. m.ResetAvatar()
  36041. return nil
  36042. case wxcard.FieldLogo:
  36043. m.ResetLogo()
  36044. return nil
  36045. case wxcard.FieldName:
  36046. m.ResetName()
  36047. return nil
  36048. case wxcard.FieldCompany:
  36049. m.ResetCompany()
  36050. return nil
  36051. case wxcard.FieldAddress:
  36052. m.ResetAddress()
  36053. return nil
  36054. case wxcard.FieldPhone:
  36055. m.ResetPhone()
  36056. return nil
  36057. case wxcard.FieldOfficialAccount:
  36058. m.ResetOfficialAccount()
  36059. return nil
  36060. case wxcard.FieldWechatAccount:
  36061. m.ResetWechatAccount()
  36062. return nil
  36063. case wxcard.FieldEmail:
  36064. m.ResetEmail()
  36065. return nil
  36066. case wxcard.FieldAPIBase:
  36067. m.ResetAPIBase()
  36068. return nil
  36069. case wxcard.FieldAPIKey:
  36070. m.ResetAPIKey()
  36071. return nil
  36072. case wxcard.FieldAiInfo:
  36073. m.ResetAiInfo()
  36074. return nil
  36075. case wxcard.FieldIntro:
  36076. m.ResetIntro()
  36077. return nil
  36078. }
  36079. return fmt.Errorf("unknown WxCard field %s", name)
  36080. }
  36081. // AddedEdges returns all edge names that were set/added in this mutation.
  36082. func (m *WxCardMutation) AddedEdges() []string {
  36083. edges := make([]string, 0, 0)
  36084. return edges
  36085. }
  36086. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36087. // name in this mutation.
  36088. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  36089. return nil
  36090. }
  36091. // RemovedEdges returns all edge names that were removed in this mutation.
  36092. func (m *WxCardMutation) RemovedEdges() []string {
  36093. edges := make([]string, 0, 0)
  36094. return edges
  36095. }
  36096. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36097. // the given name in this mutation.
  36098. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  36099. return nil
  36100. }
  36101. // ClearedEdges returns all edge names that were cleared in this mutation.
  36102. func (m *WxCardMutation) ClearedEdges() []string {
  36103. edges := make([]string, 0, 0)
  36104. return edges
  36105. }
  36106. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36107. // was cleared in this mutation.
  36108. func (m *WxCardMutation) EdgeCleared(name string) bool {
  36109. return false
  36110. }
  36111. // ClearEdge clears the value of the edge with the given name. It returns an error
  36112. // if that edge is not defined in the schema.
  36113. func (m *WxCardMutation) ClearEdge(name string) error {
  36114. return fmt.Errorf("unknown WxCard unique edge %s", name)
  36115. }
  36116. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36117. // It returns an error if the edge is not defined in the schema.
  36118. func (m *WxCardMutation) ResetEdge(name string) error {
  36119. return fmt.Errorf("unknown WxCard edge %s", name)
  36120. }
  36121. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  36122. type WxCardUserMutation struct {
  36123. config
  36124. op Op
  36125. typ string
  36126. id *uint64
  36127. created_at *time.Time
  36128. updated_at *time.Time
  36129. deleted_at *time.Time
  36130. wxid *string
  36131. account *string
  36132. avatar *string
  36133. nickname *string
  36134. remark *string
  36135. phone *string
  36136. open_id *string
  36137. union_id *string
  36138. session_key *string
  36139. is_vip *int
  36140. addis_vip *int
  36141. clearedFields map[string]struct{}
  36142. done bool
  36143. oldValue func(context.Context) (*WxCardUser, error)
  36144. predicates []predicate.WxCardUser
  36145. }
  36146. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  36147. // wxcarduserOption allows management of the mutation configuration using functional options.
  36148. type wxcarduserOption func(*WxCardUserMutation)
  36149. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  36150. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  36151. m := &WxCardUserMutation{
  36152. config: c,
  36153. op: op,
  36154. typ: TypeWxCardUser,
  36155. clearedFields: make(map[string]struct{}),
  36156. }
  36157. for _, opt := range opts {
  36158. opt(m)
  36159. }
  36160. return m
  36161. }
  36162. // withWxCardUserID sets the ID field of the mutation.
  36163. func withWxCardUserID(id uint64) wxcarduserOption {
  36164. return func(m *WxCardUserMutation) {
  36165. var (
  36166. err error
  36167. once sync.Once
  36168. value *WxCardUser
  36169. )
  36170. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  36171. once.Do(func() {
  36172. if m.done {
  36173. err = errors.New("querying old values post mutation is not allowed")
  36174. } else {
  36175. value, err = m.Client().WxCardUser.Get(ctx, id)
  36176. }
  36177. })
  36178. return value, err
  36179. }
  36180. m.id = &id
  36181. }
  36182. }
  36183. // withWxCardUser sets the old WxCardUser of the mutation.
  36184. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  36185. return func(m *WxCardUserMutation) {
  36186. m.oldValue = func(context.Context) (*WxCardUser, error) {
  36187. return node, nil
  36188. }
  36189. m.id = &node.ID
  36190. }
  36191. }
  36192. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36193. // executed in a transaction (ent.Tx), a transactional client is returned.
  36194. func (m WxCardUserMutation) Client() *Client {
  36195. client := &Client{config: m.config}
  36196. client.init()
  36197. return client
  36198. }
  36199. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36200. // it returns an error otherwise.
  36201. func (m WxCardUserMutation) Tx() (*Tx, error) {
  36202. if _, ok := m.driver.(*txDriver); !ok {
  36203. return nil, errors.New("ent: mutation is not running in a transaction")
  36204. }
  36205. tx := &Tx{config: m.config}
  36206. tx.init()
  36207. return tx, nil
  36208. }
  36209. // SetID sets the value of the id field. Note that this
  36210. // operation is only accepted on creation of WxCardUser entities.
  36211. func (m *WxCardUserMutation) SetID(id uint64) {
  36212. m.id = &id
  36213. }
  36214. // ID returns the ID value in the mutation. Note that the ID is only available
  36215. // if it was provided to the builder or after it was returned from the database.
  36216. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  36217. if m.id == nil {
  36218. return
  36219. }
  36220. return *m.id, true
  36221. }
  36222. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36223. // That means, if the mutation is applied within a transaction with an isolation level such
  36224. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36225. // or updated by the mutation.
  36226. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  36227. switch {
  36228. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36229. id, exists := m.ID()
  36230. if exists {
  36231. return []uint64{id}, nil
  36232. }
  36233. fallthrough
  36234. case m.op.Is(OpUpdate | OpDelete):
  36235. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  36236. default:
  36237. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36238. }
  36239. }
  36240. // SetCreatedAt sets the "created_at" field.
  36241. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  36242. m.created_at = &t
  36243. }
  36244. // CreatedAt returns the value of the "created_at" field in the mutation.
  36245. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  36246. v := m.created_at
  36247. if v == nil {
  36248. return
  36249. }
  36250. return *v, true
  36251. }
  36252. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  36253. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36255. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36256. if !m.op.Is(OpUpdateOne) {
  36257. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36258. }
  36259. if m.id == nil || m.oldValue == nil {
  36260. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36261. }
  36262. oldValue, err := m.oldValue(ctx)
  36263. if err != nil {
  36264. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36265. }
  36266. return oldValue.CreatedAt, nil
  36267. }
  36268. // ResetCreatedAt resets all changes to the "created_at" field.
  36269. func (m *WxCardUserMutation) ResetCreatedAt() {
  36270. m.created_at = nil
  36271. }
  36272. // SetUpdatedAt sets the "updated_at" field.
  36273. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  36274. m.updated_at = &t
  36275. }
  36276. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36277. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  36278. v := m.updated_at
  36279. if v == nil {
  36280. return
  36281. }
  36282. return *v, true
  36283. }
  36284. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  36285. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36287. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36288. if !m.op.Is(OpUpdateOne) {
  36289. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36290. }
  36291. if m.id == nil || m.oldValue == nil {
  36292. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36293. }
  36294. oldValue, err := m.oldValue(ctx)
  36295. if err != nil {
  36296. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36297. }
  36298. return oldValue.UpdatedAt, nil
  36299. }
  36300. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36301. func (m *WxCardUserMutation) ResetUpdatedAt() {
  36302. m.updated_at = nil
  36303. }
  36304. // SetDeletedAt sets the "deleted_at" field.
  36305. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  36306. m.deleted_at = &t
  36307. }
  36308. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36309. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  36310. v := m.deleted_at
  36311. if v == nil {
  36312. return
  36313. }
  36314. return *v, true
  36315. }
  36316. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  36317. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36319. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36320. if !m.op.Is(OpUpdateOne) {
  36321. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36322. }
  36323. if m.id == nil || m.oldValue == nil {
  36324. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36325. }
  36326. oldValue, err := m.oldValue(ctx)
  36327. if err != nil {
  36328. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36329. }
  36330. return oldValue.DeletedAt, nil
  36331. }
  36332. // ClearDeletedAt clears the value of the "deleted_at" field.
  36333. func (m *WxCardUserMutation) ClearDeletedAt() {
  36334. m.deleted_at = nil
  36335. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  36336. }
  36337. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36338. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  36339. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  36340. return ok
  36341. }
  36342. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36343. func (m *WxCardUserMutation) ResetDeletedAt() {
  36344. m.deleted_at = nil
  36345. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  36346. }
  36347. // SetWxid sets the "wxid" field.
  36348. func (m *WxCardUserMutation) SetWxid(s string) {
  36349. m.wxid = &s
  36350. }
  36351. // Wxid returns the value of the "wxid" field in the mutation.
  36352. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  36353. v := m.wxid
  36354. if v == nil {
  36355. return
  36356. }
  36357. return *v, true
  36358. }
  36359. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  36360. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36362. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  36363. if !m.op.Is(OpUpdateOne) {
  36364. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  36365. }
  36366. if m.id == nil || m.oldValue == nil {
  36367. return v, errors.New("OldWxid requires an ID field in the mutation")
  36368. }
  36369. oldValue, err := m.oldValue(ctx)
  36370. if err != nil {
  36371. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  36372. }
  36373. return oldValue.Wxid, nil
  36374. }
  36375. // ResetWxid resets all changes to the "wxid" field.
  36376. func (m *WxCardUserMutation) ResetWxid() {
  36377. m.wxid = nil
  36378. }
  36379. // SetAccount sets the "account" field.
  36380. func (m *WxCardUserMutation) SetAccount(s string) {
  36381. m.account = &s
  36382. }
  36383. // Account returns the value of the "account" field in the mutation.
  36384. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  36385. v := m.account
  36386. if v == nil {
  36387. return
  36388. }
  36389. return *v, true
  36390. }
  36391. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  36392. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36394. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  36395. if !m.op.Is(OpUpdateOne) {
  36396. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36397. }
  36398. if m.id == nil || m.oldValue == nil {
  36399. return v, errors.New("OldAccount requires an ID field in the mutation")
  36400. }
  36401. oldValue, err := m.oldValue(ctx)
  36402. if err != nil {
  36403. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36404. }
  36405. return oldValue.Account, nil
  36406. }
  36407. // ResetAccount resets all changes to the "account" field.
  36408. func (m *WxCardUserMutation) ResetAccount() {
  36409. m.account = nil
  36410. }
  36411. // SetAvatar sets the "avatar" field.
  36412. func (m *WxCardUserMutation) SetAvatar(s string) {
  36413. m.avatar = &s
  36414. }
  36415. // Avatar returns the value of the "avatar" field in the mutation.
  36416. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  36417. v := m.avatar
  36418. if v == nil {
  36419. return
  36420. }
  36421. return *v, true
  36422. }
  36423. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  36424. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36426. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36427. if !m.op.Is(OpUpdateOne) {
  36428. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36429. }
  36430. if m.id == nil || m.oldValue == nil {
  36431. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36432. }
  36433. oldValue, err := m.oldValue(ctx)
  36434. if err != nil {
  36435. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36436. }
  36437. return oldValue.Avatar, nil
  36438. }
  36439. // ResetAvatar resets all changes to the "avatar" field.
  36440. func (m *WxCardUserMutation) ResetAvatar() {
  36441. m.avatar = nil
  36442. }
  36443. // SetNickname sets the "nickname" field.
  36444. func (m *WxCardUserMutation) SetNickname(s string) {
  36445. m.nickname = &s
  36446. }
  36447. // Nickname returns the value of the "nickname" field in the mutation.
  36448. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  36449. v := m.nickname
  36450. if v == nil {
  36451. return
  36452. }
  36453. return *v, true
  36454. }
  36455. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  36456. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36458. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  36459. if !m.op.Is(OpUpdateOne) {
  36460. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36461. }
  36462. if m.id == nil || m.oldValue == nil {
  36463. return v, errors.New("OldNickname requires an ID field in the mutation")
  36464. }
  36465. oldValue, err := m.oldValue(ctx)
  36466. if err != nil {
  36467. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36468. }
  36469. return oldValue.Nickname, nil
  36470. }
  36471. // ResetNickname resets all changes to the "nickname" field.
  36472. func (m *WxCardUserMutation) ResetNickname() {
  36473. m.nickname = nil
  36474. }
  36475. // SetRemark sets the "remark" field.
  36476. func (m *WxCardUserMutation) SetRemark(s string) {
  36477. m.remark = &s
  36478. }
  36479. // Remark returns the value of the "remark" field in the mutation.
  36480. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  36481. v := m.remark
  36482. if v == nil {
  36483. return
  36484. }
  36485. return *v, true
  36486. }
  36487. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  36488. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36490. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  36491. if !m.op.Is(OpUpdateOne) {
  36492. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  36493. }
  36494. if m.id == nil || m.oldValue == nil {
  36495. return v, errors.New("OldRemark requires an ID field in the mutation")
  36496. }
  36497. oldValue, err := m.oldValue(ctx)
  36498. if err != nil {
  36499. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  36500. }
  36501. return oldValue.Remark, nil
  36502. }
  36503. // ResetRemark resets all changes to the "remark" field.
  36504. func (m *WxCardUserMutation) ResetRemark() {
  36505. m.remark = nil
  36506. }
  36507. // SetPhone sets the "phone" field.
  36508. func (m *WxCardUserMutation) SetPhone(s string) {
  36509. m.phone = &s
  36510. }
  36511. // Phone returns the value of the "phone" field in the mutation.
  36512. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  36513. v := m.phone
  36514. if v == nil {
  36515. return
  36516. }
  36517. return *v, true
  36518. }
  36519. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  36520. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36522. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  36523. if !m.op.Is(OpUpdateOne) {
  36524. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36525. }
  36526. if m.id == nil || m.oldValue == nil {
  36527. return v, errors.New("OldPhone requires an ID field in the mutation")
  36528. }
  36529. oldValue, err := m.oldValue(ctx)
  36530. if err != nil {
  36531. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36532. }
  36533. return oldValue.Phone, nil
  36534. }
  36535. // ResetPhone resets all changes to the "phone" field.
  36536. func (m *WxCardUserMutation) ResetPhone() {
  36537. m.phone = nil
  36538. }
  36539. // SetOpenID sets the "open_id" field.
  36540. func (m *WxCardUserMutation) SetOpenID(s string) {
  36541. m.open_id = &s
  36542. }
  36543. // OpenID returns the value of the "open_id" field in the mutation.
  36544. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  36545. v := m.open_id
  36546. if v == nil {
  36547. return
  36548. }
  36549. return *v, true
  36550. }
  36551. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  36552. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36554. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  36555. if !m.op.Is(OpUpdateOne) {
  36556. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  36557. }
  36558. if m.id == nil || m.oldValue == nil {
  36559. return v, errors.New("OldOpenID requires an ID field in the mutation")
  36560. }
  36561. oldValue, err := m.oldValue(ctx)
  36562. if err != nil {
  36563. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  36564. }
  36565. return oldValue.OpenID, nil
  36566. }
  36567. // ResetOpenID resets all changes to the "open_id" field.
  36568. func (m *WxCardUserMutation) ResetOpenID() {
  36569. m.open_id = nil
  36570. }
  36571. // SetUnionID sets the "union_id" field.
  36572. func (m *WxCardUserMutation) SetUnionID(s string) {
  36573. m.union_id = &s
  36574. }
  36575. // UnionID returns the value of the "union_id" field in the mutation.
  36576. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  36577. v := m.union_id
  36578. if v == nil {
  36579. return
  36580. }
  36581. return *v, true
  36582. }
  36583. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  36584. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36586. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  36587. if !m.op.Is(OpUpdateOne) {
  36588. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  36589. }
  36590. if m.id == nil || m.oldValue == nil {
  36591. return v, errors.New("OldUnionID requires an ID field in the mutation")
  36592. }
  36593. oldValue, err := m.oldValue(ctx)
  36594. if err != nil {
  36595. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  36596. }
  36597. return oldValue.UnionID, nil
  36598. }
  36599. // ResetUnionID resets all changes to the "union_id" field.
  36600. func (m *WxCardUserMutation) ResetUnionID() {
  36601. m.union_id = nil
  36602. }
  36603. // SetSessionKey sets the "session_key" field.
  36604. func (m *WxCardUserMutation) SetSessionKey(s string) {
  36605. m.session_key = &s
  36606. }
  36607. // SessionKey returns the value of the "session_key" field in the mutation.
  36608. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  36609. v := m.session_key
  36610. if v == nil {
  36611. return
  36612. }
  36613. return *v, true
  36614. }
  36615. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  36616. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36618. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  36619. if !m.op.Is(OpUpdateOne) {
  36620. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  36621. }
  36622. if m.id == nil || m.oldValue == nil {
  36623. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  36624. }
  36625. oldValue, err := m.oldValue(ctx)
  36626. if err != nil {
  36627. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  36628. }
  36629. return oldValue.SessionKey, nil
  36630. }
  36631. // ResetSessionKey resets all changes to the "session_key" field.
  36632. func (m *WxCardUserMutation) ResetSessionKey() {
  36633. m.session_key = nil
  36634. }
  36635. // SetIsVip sets the "is_vip" field.
  36636. func (m *WxCardUserMutation) SetIsVip(i int) {
  36637. m.is_vip = &i
  36638. m.addis_vip = nil
  36639. }
  36640. // IsVip returns the value of the "is_vip" field in the mutation.
  36641. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  36642. v := m.is_vip
  36643. if v == nil {
  36644. return
  36645. }
  36646. return *v, true
  36647. }
  36648. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  36649. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  36650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36651. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  36652. if !m.op.Is(OpUpdateOne) {
  36653. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  36654. }
  36655. if m.id == nil || m.oldValue == nil {
  36656. return v, errors.New("OldIsVip requires an ID field in the mutation")
  36657. }
  36658. oldValue, err := m.oldValue(ctx)
  36659. if err != nil {
  36660. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  36661. }
  36662. return oldValue.IsVip, nil
  36663. }
  36664. // AddIsVip adds i to the "is_vip" field.
  36665. func (m *WxCardUserMutation) AddIsVip(i int) {
  36666. if m.addis_vip != nil {
  36667. *m.addis_vip += i
  36668. } else {
  36669. m.addis_vip = &i
  36670. }
  36671. }
  36672. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  36673. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  36674. v := m.addis_vip
  36675. if v == nil {
  36676. return
  36677. }
  36678. return *v, true
  36679. }
  36680. // ResetIsVip resets all changes to the "is_vip" field.
  36681. func (m *WxCardUserMutation) ResetIsVip() {
  36682. m.is_vip = nil
  36683. m.addis_vip = nil
  36684. }
  36685. // Where appends a list predicates to the WxCardUserMutation builder.
  36686. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  36687. m.predicates = append(m.predicates, ps...)
  36688. }
  36689. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  36690. // users can use type-assertion to append predicates that do not depend on any generated package.
  36691. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  36692. p := make([]predicate.WxCardUser, len(ps))
  36693. for i := range ps {
  36694. p[i] = ps[i]
  36695. }
  36696. m.Where(p...)
  36697. }
  36698. // Op returns the operation name.
  36699. func (m *WxCardUserMutation) Op() Op {
  36700. return m.op
  36701. }
  36702. // SetOp allows setting the mutation operation.
  36703. func (m *WxCardUserMutation) SetOp(op Op) {
  36704. m.op = op
  36705. }
  36706. // Type returns the node type of this mutation (WxCardUser).
  36707. func (m *WxCardUserMutation) Type() string {
  36708. return m.typ
  36709. }
  36710. // Fields returns all fields that were changed during this mutation. Note that in
  36711. // order to get all numeric fields that were incremented/decremented, call
  36712. // AddedFields().
  36713. func (m *WxCardUserMutation) Fields() []string {
  36714. fields := make([]string, 0, 13)
  36715. if m.created_at != nil {
  36716. fields = append(fields, wxcarduser.FieldCreatedAt)
  36717. }
  36718. if m.updated_at != nil {
  36719. fields = append(fields, wxcarduser.FieldUpdatedAt)
  36720. }
  36721. if m.deleted_at != nil {
  36722. fields = append(fields, wxcarduser.FieldDeletedAt)
  36723. }
  36724. if m.wxid != nil {
  36725. fields = append(fields, wxcarduser.FieldWxid)
  36726. }
  36727. if m.account != nil {
  36728. fields = append(fields, wxcarduser.FieldAccount)
  36729. }
  36730. if m.avatar != nil {
  36731. fields = append(fields, wxcarduser.FieldAvatar)
  36732. }
  36733. if m.nickname != nil {
  36734. fields = append(fields, wxcarduser.FieldNickname)
  36735. }
  36736. if m.remark != nil {
  36737. fields = append(fields, wxcarduser.FieldRemark)
  36738. }
  36739. if m.phone != nil {
  36740. fields = append(fields, wxcarduser.FieldPhone)
  36741. }
  36742. if m.open_id != nil {
  36743. fields = append(fields, wxcarduser.FieldOpenID)
  36744. }
  36745. if m.union_id != nil {
  36746. fields = append(fields, wxcarduser.FieldUnionID)
  36747. }
  36748. if m.session_key != nil {
  36749. fields = append(fields, wxcarduser.FieldSessionKey)
  36750. }
  36751. if m.is_vip != nil {
  36752. fields = append(fields, wxcarduser.FieldIsVip)
  36753. }
  36754. return fields
  36755. }
  36756. // Field returns the value of a field with the given name. The second boolean
  36757. // return value indicates that this field was not set, or was not defined in the
  36758. // schema.
  36759. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  36760. switch name {
  36761. case wxcarduser.FieldCreatedAt:
  36762. return m.CreatedAt()
  36763. case wxcarduser.FieldUpdatedAt:
  36764. return m.UpdatedAt()
  36765. case wxcarduser.FieldDeletedAt:
  36766. return m.DeletedAt()
  36767. case wxcarduser.FieldWxid:
  36768. return m.Wxid()
  36769. case wxcarduser.FieldAccount:
  36770. return m.Account()
  36771. case wxcarduser.FieldAvatar:
  36772. return m.Avatar()
  36773. case wxcarduser.FieldNickname:
  36774. return m.Nickname()
  36775. case wxcarduser.FieldRemark:
  36776. return m.Remark()
  36777. case wxcarduser.FieldPhone:
  36778. return m.Phone()
  36779. case wxcarduser.FieldOpenID:
  36780. return m.OpenID()
  36781. case wxcarduser.FieldUnionID:
  36782. return m.UnionID()
  36783. case wxcarduser.FieldSessionKey:
  36784. return m.SessionKey()
  36785. case wxcarduser.FieldIsVip:
  36786. return m.IsVip()
  36787. }
  36788. return nil, false
  36789. }
  36790. // OldField returns the old value of the field from the database. An error is
  36791. // returned if the mutation operation is not UpdateOne, or the query to the
  36792. // database failed.
  36793. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36794. switch name {
  36795. case wxcarduser.FieldCreatedAt:
  36796. return m.OldCreatedAt(ctx)
  36797. case wxcarduser.FieldUpdatedAt:
  36798. return m.OldUpdatedAt(ctx)
  36799. case wxcarduser.FieldDeletedAt:
  36800. return m.OldDeletedAt(ctx)
  36801. case wxcarduser.FieldWxid:
  36802. return m.OldWxid(ctx)
  36803. case wxcarduser.FieldAccount:
  36804. return m.OldAccount(ctx)
  36805. case wxcarduser.FieldAvatar:
  36806. return m.OldAvatar(ctx)
  36807. case wxcarduser.FieldNickname:
  36808. return m.OldNickname(ctx)
  36809. case wxcarduser.FieldRemark:
  36810. return m.OldRemark(ctx)
  36811. case wxcarduser.FieldPhone:
  36812. return m.OldPhone(ctx)
  36813. case wxcarduser.FieldOpenID:
  36814. return m.OldOpenID(ctx)
  36815. case wxcarduser.FieldUnionID:
  36816. return m.OldUnionID(ctx)
  36817. case wxcarduser.FieldSessionKey:
  36818. return m.OldSessionKey(ctx)
  36819. case wxcarduser.FieldIsVip:
  36820. return m.OldIsVip(ctx)
  36821. }
  36822. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  36823. }
  36824. // SetField sets the value of a field with the given name. It returns an error if
  36825. // the field is not defined in the schema, or if the type mismatched the field
  36826. // type.
  36827. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  36828. switch name {
  36829. case wxcarduser.FieldCreatedAt:
  36830. v, ok := value.(time.Time)
  36831. if !ok {
  36832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36833. }
  36834. m.SetCreatedAt(v)
  36835. return nil
  36836. case wxcarduser.FieldUpdatedAt:
  36837. v, ok := value.(time.Time)
  36838. if !ok {
  36839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36840. }
  36841. m.SetUpdatedAt(v)
  36842. return nil
  36843. case wxcarduser.FieldDeletedAt:
  36844. v, ok := value.(time.Time)
  36845. if !ok {
  36846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36847. }
  36848. m.SetDeletedAt(v)
  36849. return nil
  36850. case wxcarduser.FieldWxid:
  36851. v, ok := value.(string)
  36852. if !ok {
  36853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36854. }
  36855. m.SetWxid(v)
  36856. return nil
  36857. case wxcarduser.FieldAccount:
  36858. v, ok := value.(string)
  36859. if !ok {
  36860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36861. }
  36862. m.SetAccount(v)
  36863. return nil
  36864. case wxcarduser.FieldAvatar:
  36865. v, ok := value.(string)
  36866. if !ok {
  36867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36868. }
  36869. m.SetAvatar(v)
  36870. return nil
  36871. case wxcarduser.FieldNickname:
  36872. v, ok := value.(string)
  36873. if !ok {
  36874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36875. }
  36876. m.SetNickname(v)
  36877. return nil
  36878. case wxcarduser.FieldRemark:
  36879. v, ok := value.(string)
  36880. if !ok {
  36881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36882. }
  36883. m.SetRemark(v)
  36884. return nil
  36885. case wxcarduser.FieldPhone:
  36886. v, ok := value.(string)
  36887. if !ok {
  36888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36889. }
  36890. m.SetPhone(v)
  36891. return nil
  36892. case wxcarduser.FieldOpenID:
  36893. v, ok := value.(string)
  36894. if !ok {
  36895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36896. }
  36897. m.SetOpenID(v)
  36898. return nil
  36899. case wxcarduser.FieldUnionID:
  36900. v, ok := value.(string)
  36901. if !ok {
  36902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36903. }
  36904. m.SetUnionID(v)
  36905. return nil
  36906. case wxcarduser.FieldSessionKey:
  36907. v, ok := value.(string)
  36908. if !ok {
  36909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36910. }
  36911. m.SetSessionKey(v)
  36912. return nil
  36913. case wxcarduser.FieldIsVip:
  36914. v, ok := value.(int)
  36915. if !ok {
  36916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36917. }
  36918. m.SetIsVip(v)
  36919. return nil
  36920. }
  36921. return fmt.Errorf("unknown WxCardUser field %s", name)
  36922. }
  36923. // AddedFields returns all numeric fields that were incremented/decremented during
  36924. // this mutation.
  36925. func (m *WxCardUserMutation) AddedFields() []string {
  36926. var fields []string
  36927. if m.addis_vip != nil {
  36928. fields = append(fields, wxcarduser.FieldIsVip)
  36929. }
  36930. return fields
  36931. }
  36932. // AddedField returns the numeric value that was incremented/decremented on a field
  36933. // with the given name. The second boolean return value indicates that this field
  36934. // was not set, or was not defined in the schema.
  36935. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  36936. switch name {
  36937. case wxcarduser.FieldIsVip:
  36938. return m.AddedIsVip()
  36939. }
  36940. return nil, false
  36941. }
  36942. // AddField adds the value to the field with the given name. It returns an error if
  36943. // the field is not defined in the schema, or if the type mismatched the field
  36944. // type.
  36945. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  36946. switch name {
  36947. case wxcarduser.FieldIsVip:
  36948. v, ok := value.(int)
  36949. if !ok {
  36950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36951. }
  36952. m.AddIsVip(v)
  36953. return nil
  36954. }
  36955. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  36956. }
  36957. // ClearedFields returns all nullable fields that were cleared during this
  36958. // mutation.
  36959. func (m *WxCardUserMutation) ClearedFields() []string {
  36960. var fields []string
  36961. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  36962. fields = append(fields, wxcarduser.FieldDeletedAt)
  36963. }
  36964. return fields
  36965. }
  36966. // FieldCleared returns a boolean indicating if a field with the given name was
  36967. // cleared in this mutation.
  36968. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  36969. _, ok := m.clearedFields[name]
  36970. return ok
  36971. }
  36972. // ClearField clears the value of the field with the given name. It returns an
  36973. // error if the field is not defined in the schema.
  36974. func (m *WxCardUserMutation) ClearField(name string) error {
  36975. switch name {
  36976. case wxcarduser.FieldDeletedAt:
  36977. m.ClearDeletedAt()
  36978. return nil
  36979. }
  36980. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  36981. }
  36982. // ResetField resets all changes in the mutation for the field with the given name.
  36983. // It returns an error if the field is not defined in the schema.
  36984. func (m *WxCardUserMutation) ResetField(name string) error {
  36985. switch name {
  36986. case wxcarduser.FieldCreatedAt:
  36987. m.ResetCreatedAt()
  36988. return nil
  36989. case wxcarduser.FieldUpdatedAt:
  36990. m.ResetUpdatedAt()
  36991. return nil
  36992. case wxcarduser.FieldDeletedAt:
  36993. m.ResetDeletedAt()
  36994. return nil
  36995. case wxcarduser.FieldWxid:
  36996. m.ResetWxid()
  36997. return nil
  36998. case wxcarduser.FieldAccount:
  36999. m.ResetAccount()
  37000. return nil
  37001. case wxcarduser.FieldAvatar:
  37002. m.ResetAvatar()
  37003. return nil
  37004. case wxcarduser.FieldNickname:
  37005. m.ResetNickname()
  37006. return nil
  37007. case wxcarduser.FieldRemark:
  37008. m.ResetRemark()
  37009. return nil
  37010. case wxcarduser.FieldPhone:
  37011. m.ResetPhone()
  37012. return nil
  37013. case wxcarduser.FieldOpenID:
  37014. m.ResetOpenID()
  37015. return nil
  37016. case wxcarduser.FieldUnionID:
  37017. m.ResetUnionID()
  37018. return nil
  37019. case wxcarduser.FieldSessionKey:
  37020. m.ResetSessionKey()
  37021. return nil
  37022. case wxcarduser.FieldIsVip:
  37023. m.ResetIsVip()
  37024. return nil
  37025. }
  37026. return fmt.Errorf("unknown WxCardUser field %s", name)
  37027. }
  37028. // AddedEdges returns all edge names that were set/added in this mutation.
  37029. func (m *WxCardUserMutation) AddedEdges() []string {
  37030. edges := make([]string, 0, 0)
  37031. return edges
  37032. }
  37033. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37034. // name in this mutation.
  37035. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  37036. return nil
  37037. }
  37038. // RemovedEdges returns all edge names that were removed in this mutation.
  37039. func (m *WxCardUserMutation) RemovedEdges() []string {
  37040. edges := make([]string, 0, 0)
  37041. return edges
  37042. }
  37043. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37044. // the given name in this mutation.
  37045. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  37046. return nil
  37047. }
  37048. // ClearedEdges returns all edge names that were cleared in this mutation.
  37049. func (m *WxCardUserMutation) ClearedEdges() []string {
  37050. edges := make([]string, 0, 0)
  37051. return edges
  37052. }
  37053. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37054. // was cleared in this mutation.
  37055. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  37056. return false
  37057. }
  37058. // ClearEdge clears the value of the edge with the given name. It returns an error
  37059. // if that edge is not defined in the schema.
  37060. func (m *WxCardUserMutation) ClearEdge(name string) error {
  37061. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  37062. }
  37063. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37064. // It returns an error if the edge is not defined in the schema.
  37065. func (m *WxCardUserMutation) ResetEdge(name string) error {
  37066. return fmt.Errorf("unknown WxCardUser edge %s", name)
  37067. }
  37068. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  37069. type WxCardVisitMutation struct {
  37070. config
  37071. op Op
  37072. typ string
  37073. id *uint64
  37074. created_at *time.Time
  37075. updated_at *time.Time
  37076. deleted_at *time.Time
  37077. user_id *uint64
  37078. adduser_id *int64
  37079. bot_id *uint64
  37080. addbot_id *int64
  37081. bot_type *uint8
  37082. addbot_type *int8
  37083. clearedFields map[string]struct{}
  37084. done bool
  37085. oldValue func(context.Context) (*WxCardVisit, error)
  37086. predicates []predicate.WxCardVisit
  37087. }
  37088. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  37089. // wxcardvisitOption allows management of the mutation configuration using functional options.
  37090. type wxcardvisitOption func(*WxCardVisitMutation)
  37091. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  37092. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  37093. m := &WxCardVisitMutation{
  37094. config: c,
  37095. op: op,
  37096. typ: TypeWxCardVisit,
  37097. clearedFields: make(map[string]struct{}),
  37098. }
  37099. for _, opt := range opts {
  37100. opt(m)
  37101. }
  37102. return m
  37103. }
  37104. // withWxCardVisitID sets the ID field of the mutation.
  37105. func withWxCardVisitID(id uint64) wxcardvisitOption {
  37106. return func(m *WxCardVisitMutation) {
  37107. var (
  37108. err error
  37109. once sync.Once
  37110. value *WxCardVisit
  37111. )
  37112. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  37113. once.Do(func() {
  37114. if m.done {
  37115. err = errors.New("querying old values post mutation is not allowed")
  37116. } else {
  37117. value, err = m.Client().WxCardVisit.Get(ctx, id)
  37118. }
  37119. })
  37120. return value, err
  37121. }
  37122. m.id = &id
  37123. }
  37124. }
  37125. // withWxCardVisit sets the old WxCardVisit of the mutation.
  37126. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  37127. return func(m *WxCardVisitMutation) {
  37128. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  37129. return node, nil
  37130. }
  37131. m.id = &node.ID
  37132. }
  37133. }
  37134. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37135. // executed in a transaction (ent.Tx), a transactional client is returned.
  37136. func (m WxCardVisitMutation) Client() *Client {
  37137. client := &Client{config: m.config}
  37138. client.init()
  37139. return client
  37140. }
  37141. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37142. // it returns an error otherwise.
  37143. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  37144. if _, ok := m.driver.(*txDriver); !ok {
  37145. return nil, errors.New("ent: mutation is not running in a transaction")
  37146. }
  37147. tx := &Tx{config: m.config}
  37148. tx.init()
  37149. return tx, nil
  37150. }
  37151. // SetID sets the value of the id field. Note that this
  37152. // operation is only accepted on creation of WxCardVisit entities.
  37153. func (m *WxCardVisitMutation) SetID(id uint64) {
  37154. m.id = &id
  37155. }
  37156. // ID returns the ID value in the mutation. Note that the ID is only available
  37157. // if it was provided to the builder or after it was returned from the database.
  37158. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  37159. if m.id == nil {
  37160. return
  37161. }
  37162. return *m.id, true
  37163. }
  37164. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37165. // That means, if the mutation is applied within a transaction with an isolation level such
  37166. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37167. // or updated by the mutation.
  37168. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  37169. switch {
  37170. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37171. id, exists := m.ID()
  37172. if exists {
  37173. return []uint64{id}, nil
  37174. }
  37175. fallthrough
  37176. case m.op.Is(OpUpdate | OpDelete):
  37177. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  37178. default:
  37179. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37180. }
  37181. }
  37182. // SetCreatedAt sets the "created_at" field.
  37183. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  37184. m.created_at = &t
  37185. }
  37186. // CreatedAt returns the value of the "created_at" field in the mutation.
  37187. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  37188. v := m.created_at
  37189. if v == nil {
  37190. return
  37191. }
  37192. return *v, true
  37193. }
  37194. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  37195. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37197. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37198. if !m.op.Is(OpUpdateOne) {
  37199. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37200. }
  37201. if m.id == nil || m.oldValue == nil {
  37202. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37203. }
  37204. oldValue, err := m.oldValue(ctx)
  37205. if err != nil {
  37206. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37207. }
  37208. return oldValue.CreatedAt, nil
  37209. }
  37210. // ResetCreatedAt resets all changes to the "created_at" field.
  37211. func (m *WxCardVisitMutation) ResetCreatedAt() {
  37212. m.created_at = nil
  37213. }
  37214. // SetUpdatedAt sets the "updated_at" field.
  37215. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  37216. m.updated_at = &t
  37217. }
  37218. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37219. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  37220. v := m.updated_at
  37221. if v == nil {
  37222. return
  37223. }
  37224. return *v, true
  37225. }
  37226. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  37227. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37229. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37230. if !m.op.Is(OpUpdateOne) {
  37231. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37232. }
  37233. if m.id == nil || m.oldValue == nil {
  37234. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37235. }
  37236. oldValue, err := m.oldValue(ctx)
  37237. if err != nil {
  37238. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37239. }
  37240. return oldValue.UpdatedAt, nil
  37241. }
  37242. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37243. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  37244. m.updated_at = nil
  37245. }
  37246. // SetDeletedAt sets the "deleted_at" field.
  37247. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  37248. m.deleted_at = &t
  37249. }
  37250. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37251. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  37252. v := m.deleted_at
  37253. if v == nil {
  37254. return
  37255. }
  37256. return *v, true
  37257. }
  37258. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  37259. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37261. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37262. if !m.op.Is(OpUpdateOne) {
  37263. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37264. }
  37265. if m.id == nil || m.oldValue == nil {
  37266. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37267. }
  37268. oldValue, err := m.oldValue(ctx)
  37269. if err != nil {
  37270. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37271. }
  37272. return oldValue.DeletedAt, nil
  37273. }
  37274. // ClearDeletedAt clears the value of the "deleted_at" field.
  37275. func (m *WxCardVisitMutation) ClearDeletedAt() {
  37276. m.deleted_at = nil
  37277. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  37278. }
  37279. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37280. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  37281. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  37282. return ok
  37283. }
  37284. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37285. func (m *WxCardVisitMutation) ResetDeletedAt() {
  37286. m.deleted_at = nil
  37287. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  37288. }
  37289. // SetUserID sets the "user_id" field.
  37290. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  37291. m.user_id = &u
  37292. m.adduser_id = nil
  37293. }
  37294. // UserID returns the value of the "user_id" field in the mutation.
  37295. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  37296. v := m.user_id
  37297. if v == nil {
  37298. return
  37299. }
  37300. return *v, true
  37301. }
  37302. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  37303. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37305. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  37306. if !m.op.Is(OpUpdateOne) {
  37307. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  37308. }
  37309. if m.id == nil || m.oldValue == nil {
  37310. return v, errors.New("OldUserID requires an ID field in the mutation")
  37311. }
  37312. oldValue, err := m.oldValue(ctx)
  37313. if err != nil {
  37314. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  37315. }
  37316. return oldValue.UserID, nil
  37317. }
  37318. // AddUserID adds u to the "user_id" field.
  37319. func (m *WxCardVisitMutation) AddUserID(u int64) {
  37320. if m.adduser_id != nil {
  37321. *m.adduser_id += u
  37322. } else {
  37323. m.adduser_id = &u
  37324. }
  37325. }
  37326. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  37327. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  37328. v := m.adduser_id
  37329. if v == nil {
  37330. return
  37331. }
  37332. return *v, true
  37333. }
  37334. // ClearUserID clears the value of the "user_id" field.
  37335. func (m *WxCardVisitMutation) ClearUserID() {
  37336. m.user_id = nil
  37337. m.adduser_id = nil
  37338. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  37339. }
  37340. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  37341. func (m *WxCardVisitMutation) UserIDCleared() bool {
  37342. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  37343. return ok
  37344. }
  37345. // ResetUserID resets all changes to the "user_id" field.
  37346. func (m *WxCardVisitMutation) ResetUserID() {
  37347. m.user_id = nil
  37348. m.adduser_id = nil
  37349. delete(m.clearedFields, wxcardvisit.FieldUserID)
  37350. }
  37351. // SetBotID sets the "bot_id" field.
  37352. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  37353. m.bot_id = &u
  37354. m.addbot_id = nil
  37355. }
  37356. // BotID returns the value of the "bot_id" field in the mutation.
  37357. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  37358. v := m.bot_id
  37359. if v == nil {
  37360. return
  37361. }
  37362. return *v, true
  37363. }
  37364. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  37365. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37367. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  37368. if !m.op.Is(OpUpdateOne) {
  37369. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37370. }
  37371. if m.id == nil || m.oldValue == nil {
  37372. return v, errors.New("OldBotID requires an ID field in the mutation")
  37373. }
  37374. oldValue, err := m.oldValue(ctx)
  37375. if err != nil {
  37376. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37377. }
  37378. return oldValue.BotID, nil
  37379. }
  37380. // AddBotID adds u to the "bot_id" field.
  37381. func (m *WxCardVisitMutation) AddBotID(u int64) {
  37382. if m.addbot_id != nil {
  37383. *m.addbot_id += u
  37384. } else {
  37385. m.addbot_id = &u
  37386. }
  37387. }
  37388. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  37389. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  37390. v := m.addbot_id
  37391. if v == nil {
  37392. return
  37393. }
  37394. return *v, true
  37395. }
  37396. // ResetBotID resets all changes to the "bot_id" field.
  37397. func (m *WxCardVisitMutation) ResetBotID() {
  37398. m.bot_id = nil
  37399. m.addbot_id = nil
  37400. }
  37401. // SetBotType sets the "bot_type" field.
  37402. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  37403. m.bot_type = &u
  37404. m.addbot_type = nil
  37405. }
  37406. // BotType returns the value of the "bot_type" field in the mutation.
  37407. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  37408. v := m.bot_type
  37409. if v == nil {
  37410. return
  37411. }
  37412. return *v, true
  37413. }
  37414. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  37415. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  37416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37417. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  37418. if !m.op.Is(OpUpdateOne) {
  37419. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  37420. }
  37421. if m.id == nil || m.oldValue == nil {
  37422. return v, errors.New("OldBotType requires an ID field in the mutation")
  37423. }
  37424. oldValue, err := m.oldValue(ctx)
  37425. if err != nil {
  37426. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  37427. }
  37428. return oldValue.BotType, nil
  37429. }
  37430. // AddBotType adds u to the "bot_type" field.
  37431. func (m *WxCardVisitMutation) AddBotType(u int8) {
  37432. if m.addbot_type != nil {
  37433. *m.addbot_type += u
  37434. } else {
  37435. m.addbot_type = &u
  37436. }
  37437. }
  37438. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  37439. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  37440. v := m.addbot_type
  37441. if v == nil {
  37442. return
  37443. }
  37444. return *v, true
  37445. }
  37446. // ResetBotType resets all changes to the "bot_type" field.
  37447. func (m *WxCardVisitMutation) ResetBotType() {
  37448. m.bot_type = nil
  37449. m.addbot_type = nil
  37450. }
  37451. // Where appends a list predicates to the WxCardVisitMutation builder.
  37452. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  37453. m.predicates = append(m.predicates, ps...)
  37454. }
  37455. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  37456. // users can use type-assertion to append predicates that do not depend on any generated package.
  37457. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  37458. p := make([]predicate.WxCardVisit, len(ps))
  37459. for i := range ps {
  37460. p[i] = ps[i]
  37461. }
  37462. m.Where(p...)
  37463. }
  37464. // Op returns the operation name.
  37465. func (m *WxCardVisitMutation) Op() Op {
  37466. return m.op
  37467. }
  37468. // SetOp allows setting the mutation operation.
  37469. func (m *WxCardVisitMutation) SetOp(op Op) {
  37470. m.op = op
  37471. }
  37472. // Type returns the node type of this mutation (WxCardVisit).
  37473. func (m *WxCardVisitMutation) Type() string {
  37474. return m.typ
  37475. }
  37476. // Fields returns all fields that were changed during this mutation. Note that in
  37477. // order to get all numeric fields that were incremented/decremented, call
  37478. // AddedFields().
  37479. func (m *WxCardVisitMutation) Fields() []string {
  37480. fields := make([]string, 0, 6)
  37481. if m.created_at != nil {
  37482. fields = append(fields, wxcardvisit.FieldCreatedAt)
  37483. }
  37484. if m.updated_at != nil {
  37485. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  37486. }
  37487. if m.deleted_at != nil {
  37488. fields = append(fields, wxcardvisit.FieldDeletedAt)
  37489. }
  37490. if m.user_id != nil {
  37491. fields = append(fields, wxcardvisit.FieldUserID)
  37492. }
  37493. if m.bot_id != nil {
  37494. fields = append(fields, wxcardvisit.FieldBotID)
  37495. }
  37496. if m.bot_type != nil {
  37497. fields = append(fields, wxcardvisit.FieldBotType)
  37498. }
  37499. return fields
  37500. }
  37501. // Field returns the value of a field with the given name. The second boolean
  37502. // return value indicates that this field was not set, or was not defined in the
  37503. // schema.
  37504. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  37505. switch name {
  37506. case wxcardvisit.FieldCreatedAt:
  37507. return m.CreatedAt()
  37508. case wxcardvisit.FieldUpdatedAt:
  37509. return m.UpdatedAt()
  37510. case wxcardvisit.FieldDeletedAt:
  37511. return m.DeletedAt()
  37512. case wxcardvisit.FieldUserID:
  37513. return m.UserID()
  37514. case wxcardvisit.FieldBotID:
  37515. return m.BotID()
  37516. case wxcardvisit.FieldBotType:
  37517. return m.BotType()
  37518. }
  37519. return nil, false
  37520. }
  37521. // OldField returns the old value of the field from the database. An error is
  37522. // returned if the mutation operation is not UpdateOne, or the query to the
  37523. // database failed.
  37524. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37525. switch name {
  37526. case wxcardvisit.FieldCreatedAt:
  37527. return m.OldCreatedAt(ctx)
  37528. case wxcardvisit.FieldUpdatedAt:
  37529. return m.OldUpdatedAt(ctx)
  37530. case wxcardvisit.FieldDeletedAt:
  37531. return m.OldDeletedAt(ctx)
  37532. case wxcardvisit.FieldUserID:
  37533. return m.OldUserID(ctx)
  37534. case wxcardvisit.FieldBotID:
  37535. return m.OldBotID(ctx)
  37536. case wxcardvisit.FieldBotType:
  37537. return m.OldBotType(ctx)
  37538. }
  37539. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  37540. }
  37541. // SetField sets the value of a field with the given name. It returns an error if
  37542. // the field is not defined in the schema, or if the type mismatched the field
  37543. // type.
  37544. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  37545. switch name {
  37546. case wxcardvisit.FieldCreatedAt:
  37547. v, ok := value.(time.Time)
  37548. if !ok {
  37549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37550. }
  37551. m.SetCreatedAt(v)
  37552. return nil
  37553. case wxcardvisit.FieldUpdatedAt:
  37554. v, ok := value.(time.Time)
  37555. if !ok {
  37556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37557. }
  37558. m.SetUpdatedAt(v)
  37559. return nil
  37560. case wxcardvisit.FieldDeletedAt:
  37561. v, ok := value.(time.Time)
  37562. if !ok {
  37563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37564. }
  37565. m.SetDeletedAt(v)
  37566. return nil
  37567. case wxcardvisit.FieldUserID:
  37568. v, ok := value.(uint64)
  37569. if !ok {
  37570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37571. }
  37572. m.SetUserID(v)
  37573. return nil
  37574. case wxcardvisit.FieldBotID:
  37575. v, ok := value.(uint64)
  37576. if !ok {
  37577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37578. }
  37579. m.SetBotID(v)
  37580. return nil
  37581. case wxcardvisit.FieldBotType:
  37582. v, ok := value.(uint8)
  37583. if !ok {
  37584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37585. }
  37586. m.SetBotType(v)
  37587. return nil
  37588. }
  37589. return fmt.Errorf("unknown WxCardVisit field %s", name)
  37590. }
  37591. // AddedFields returns all numeric fields that were incremented/decremented during
  37592. // this mutation.
  37593. func (m *WxCardVisitMutation) AddedFields() []string {
  37594. var fields []string
  37595. if m.adduser_id != nil {
  37596. fields = append(fields, wxcardvisit.FieldUserID)
  37597. }
  37598. if m.addbot_id != nil {
  37599. fields = append(fields, wxcardvisit.FieldBotID)
  37600. }
  37601. if m.addbot_type != nil {
  37602. fields = append(fields, wxcardvisit.FieldBotType)
  37603. }
  37604. return fields
  37605. }
  37606. // AddedField returns the numeric value that was incremented/decremented on a field
  37607. // with the given name. The second boolean return value indicates that this field
  37608. // was not set, or was not defined in the schema.
  37609. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  37610. switch name {
  37611. case wxcardvisit.FieldUserID:
  37612. return m.AddedUserID()
  37613. case wxcardvisit.FieldBotID:
  37614. return m.AddedBotID()
  37615. case wxcardvisit.FieldBotType:
  37616. return m.AddedBotType()
  37617. }
  37618. return nil, false
  37619. }
  37620. // AddField adds the value to the field with the given name. It returns an error if
  37621. // the field is not defined in the schema, or if the type mismatched the field
  37622. // type.
  37623. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  37624. switch name {
  37625. case wxcardvisit.FieldUserID:
  37626. v, ok := value.(int64)
  37627. if !ok {
  37628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37629. }
  37630. m.AddUserID(v)
  37631. return nil
  37632. case wxcardvisit.FieldBotID:
  37633. v, ok := value.(int64)
  37634. if !ok {
  37635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37636. }
  37637. m.AddBotID(v)
  37638. return nil
  37639. case wxcardvisit.FieldBotType:
  37640. v, ok := value.(int8)
  37641. if !ok {
  37642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37643. }
  37644. m.AddBotType(v)
  37645. return nil
  37646. }
  37647. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  37648. }
  37649. // ClearedFields returns all nullable fields that were cleared during this
  37650. // mutation.
  37651. func (m *WxCardVisitMutation) ClearedFields() []string {
  37652. var fields []string
  37653. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  37654. fields = append(fields, wxcardvisit.FieldDeletedAt)
  37655. }
  37656. if m.FieldCleared(wxcardvisit.FieldUserID) {
  37657. fields = append(fields, wxcardvisit.FieldUserID)
  37658. }
  37659. return fields
  37660. }
  37661. // FieldCleared returns a boolean indicating if a field with the given name was
  37662. // cleared in this mutation.
  37663. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  37664. _, ok := m.clearedFields[name]
  37665. return ok
  37666. }
  37667. // ClearField clears the value of the field with the given name. It returns an
  37668. // error if the field is not defined in the schema.
  37669. func (m *WxCardVisitMutation) ClearField(name string) error {
  37670. switch name {
  37671. case wxcardvisit.FieldDeletedAt:
  37672. m.ClearDeletedAt()
  37673. return nil
  37674. case wxcardvisit.FieldUserID:
  37675. m.ClearUserID()
  37676. return nil
  37677. }
  37678. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  37679. }
  37680. // ResetField resets all changes in the mutation for the field with the given name.
  37681. // It returns an error if the field is not defined in the schema.
  37682. func (m *WxCardVisitMutation) ResetField(name string) error {
  37683. switch name {
  37684. case wxcardvisit.FieldCreatedAt:
  37685. m.ResetCreatedAt()
  37686. return nil
  37687. case wxcardvisit.FieldUpdatedAt:
  37688. m.ResetUpdatedAt()
  37689. return nil
  37690. case wxcardvisit.FieldDeletedAt:
  37691. m.ResetDeletedAt()
  37692. return nil
  37693. case wxcardvisit.FieldUserID:
  37694. m.ResetUserID()
  37695. return nil
  37696. case wxcardvisit.FieldBotID:
  37697. m.ResetBotID()
  37698. return nil
  37699. case wxcardvisit.FieldBotType:
  37700. m.ResetBotType()
  37701. return nil
  37702. }
  37703. return fmt.Errorf("unknown WxCardVisit field %s", name)
  37704. }
  37705. // AddedEdges returns all edge names that were set/added in this mutation.
  37706. func (m *WxCardVisitMutation) AddedEdges() []string {
  37707. edges := make([]string, 0, 0)
  37708. return edges
  37709. }
  37710. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37711. // name in this mutation.
  37712. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  37713. return nil
  37714. }
  37715. // RemovedEdges returns all edge names that were removed in this mutation.
  37716. func (m *WxCardVisitMutation) RemovedEdges() []string {
  37717. edges := make([]string, 0, 0)
  37718. return edges
  37719. }
  37720. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37721. // the given name in this mutation.
  37722. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  37723. return nil
  37724. }
  37725. // ClearedEdges returns all edge names that were cleared in this mutation.
  37726. func (m *WxCardVisitMutation) ClearedEdges() []string {
  37727. edges := make([]string, 0, 0)
  37728. return edges
  37729. }
  37730. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37731. // was cleared in this mutation.
  37732. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  37733. return false
  37734. }
  37735. // ClearEdge clears the value of the edge with the given name. It returns an error
  37736. // if that edge is not defined in the schema.
  37737. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  37738. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  37739. }
  37740. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37741. // It returns an error if the edge is not defined in the schema.
  37742. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  37743. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  37744. }