mutation.go 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330
  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/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/workexperience"
  43. "wechat-api/ent/wpchatroom"
  44. "wechat-api/ent/wpchatroommember"
  45. "wechat-api/ent/wx"
  46. "wechat-api/ent/wxcard"
  47. "wechat-api/ent/wxcarduser"
  48. "wechat-api/ent/wxcardvisit"
  49. "entgo.io/ent"
  50. "entgo.io/ent/dialect/sql"
  51. )
  52. const (
  53. // Operation types.
  54. OpCreate = ent.OpCreate
  55. OpDelete = ent.OpDelete
  56. OpDeleteOne = ent.OpDeleteOne
  57. OpUpdate = ent.OpUpdate
  58. OpUpdateOne = ent.OpUpdateOne
  59. // Node types.
  60. TypeAgent = "Agent"
  61. TypeAgentBase = "AgentBase"
  62. TypeAliyunAvatar = "AliyunAvatar"
  63. TypeAllocAgent = "AllocAgent"
  64. TypeBatchMsg = "BatchMsg"
  65. TypeCategory = "Category"
  66. TypeChatRecords = "ChatRecords"
  67. TypeChatSession = "ChatSession"
  68. TypeContact = "Contact"
  69. TypeCreditBalance = "CreditBalance"
  70. TypeCreditUsage = "CreditUsage"
  71. TypeEmployee = "Employee"
  72. TypeEmployeeConfig = "EmployeeConfig"
  73. TypeLabel = "Label"
  74. TypeLabelRelationship = "LabelRelationship"
  75. TypeLabelTagging = "LabelTagging"
  76. TypeMessage = "Message"
  77. TypeMessageRecords = "MessageRecords"
  78. TypeMsg = "Msg"
  79. TypePayRecharge = "PayRecharge"
  80. TypeServer = "Server"
  81. TypeSopNode = "SopNode"
  82. TypeSopStage = "SopStage"
  83. TypeSopTask = "SopTask"
  84. TypeToken = "Token"
  85. TypeTutorial = "Tutorial"
  86. TypeUsageDetail = "UsageDetail"
  87. TypeUsageStatisticDay = "UsageStatisticDay"
  88. TypeUsageStatisticHour = "UsageStatisticHour"
  89. TypeUsageStatisticMonth = "UsageStatisticMonth"
  90. TypeUsageTotal = "UsageTotal"
  91. TypeWorkExperience = "WorkExperience"
  92. TypeWpChatroom = "WpChatroom"
  93. TypeWpChatroomMember = "WpChatroomMember"
  94. TypeWx = "Wx"
  95. TypeWxCard = "WxCard"
  96. TypeWxCardUser = "WxCardUser"
  97. TypeWxCardVisit = "WxCardVisit"
  98. )
  99. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  100. type AgentMutation struct {
  101. config
  102. op Op
  103. typ string
  104. id *uint64
  105. created_at *time.Time
  106. updated_at *time.Time
  107. deleted_at *time.Time
  108. name *string
  109. role *string
  110. status *int
  111. addstatus *int
  112. background *string
  113. examples *string
  114. organization_id *uint64
  115. addorganization_id *int64
  116. dataset_id *string
  117. collection_id *string
  118. clearedFields map[string]struct{}
  119. wx_agent map[uint64]struct{}
  120. removedwx_agent map[uint64]struct{}
  121. clearedwx_agent bool
  122. token_agent map[uint64]struct{}
  123. removedtoken_agent map[uint64]struct{}
  124. clearedtoken_agent bool
  125. done bool
  126. oldValue func(context.Context) (*Agent, error)
  127. predicates []predicate.Agent
  128. }
  129. var _ ent.Mutation = (*AgentMutation)(nil)
  130. // agentOption allows management of the mutation configuration using functional options.
  131. type agentOption func(*AgentMutation)
  132. // newAgentMutation creates new mutation for the Agent entity.
  133. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  134. m := &AgentMutation{
  135. config: c,
  136. op: op,
  137. typ: TypeAgent,
  138. clearedFields: make(map[string]struct{}),
  139. }
  140. for _, opt := range opts {
  141. opt(m)
  142. }
  143. return m
  144. }
  145. // withAgentID sets the ID field of the mutation.
  146. func withAgentID(id uint64) agentOption {
  147. return func(m *AgentMutation) {
  148. var (
  149. err error
  150. once sync.Once
  151. value *Agent
  152. )
  153. m.oldValue = func(ctx context.Context) (*Agent, error) {
  154. once.Do(func() {
  155. if m.done {
  156. err = errors.New("querying old values post mutation is not allowed")
  157. } else {
  158. value, err = m.Client().Agent.Get(ctx, id)
  159. }
  160. })
  161. return value, err
  162. }
  163. m.id = &id
  164. }
  165. }
  166. // withAgent sets the old Agent of the mutation.
  167. func withAgent(node *Agent) agentOption {
  168. return func(m *AgentMutation) {
  169. m.oldValue = func(context.Context) (*Agent, error) {
  170. return node, nil
  171. }
  172. m.id = &node.ID
  173. }
  174. }
  175. // Client returns a new `ent.Client` from the mutation. If the mutation was
  176. // executed in a transaction (ent.Tx), a transactional client is returned.
  177. func (m AgentMutation) Client() *Client {
  178. client := &Client{config: m.config}
  179. client.init()
  180. return client
  181. }
  182. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  183. // it returns an error otherwise.
  184. func (m AgentMutation) Tx() (*Tx, error) {
  185. if _, ok := m.driver.(*txDriver); !ok {
  186. return nil, errors.New("ent: mutation is not running in a transaction")
  187. }
  188. tx := &Tx{config: m.config}
  189. tx.init()
  190. return tx, nil
  191. }
  192. // SetID sets the value of the id field. Note that this
  193. // operation is only accepted on creation of Agent entities.
  194. func (m *AgentMutation) SetID(id uint64) {
  195. m.id = &id
  196. }
  197. // ID returns the ID value in the mutation. Note that the ID is only available
  198. // if it was provided to the builder or after it was returned from the database.
  199. func (m *AgentMutation) ID() (id uint64, exists bool) {
  200. if m.id == nil {
  201. return
  202. }
  203. return *m.id, true
  204. }
  205. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  206. // That means, if the mutation is applied within a transaction with an isolation level such
  207. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  208. // or updated by the mutation.
  209. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  210. switch {
  211. case m.op.Is(OpUpdateOne | OpDeleteOne):
  212. id, exists := m.ID()
  213. if exists {
  214. return []uint64{id}, nil
  215. }
  216. fallthrough
  217. case m.op.Is(OpUpdate | OpDelete):
  218. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  219. default:
  220. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  221. }
  222. }
  223. // SetCreatedAt sets the "created_at" field.
  224. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  225. m.created_at = &t
  226. }
  227. // CreatedAt returns the value of the "created_at" field in the mutation.
  228. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  229. v := m.created_at
  230. if v == nil {
  231. return
  232. }
  233. return *v, true
  234. }
  235. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  236. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  238. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  239. if !m.op.Is(OpUpdateOne) {
  240. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  241. }
  242. if m.id == nil || m.oldValue == nil {
  243. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  244. }
  245. oldValue, err := m.oldValue(ctx)
  246. if err != nil {
  247. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  248. }
  249. return oldValue.CreatedAt, nil
  250. }
  251. // ResetCreatedAt resets all changes to the "created_at" field.
  252. func (m *AgentMutation) ResetCreatedAt() {
  253. m.created_at = nil
  254. }
  255. // SetUpdatedAt sets the "updated_at" field.
  256. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  257. m.updated_at = &t
  258. }
  259. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  260. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  261. v := m.updated_at
  262. if v == nil {
  263. return
  264. }
  265. return *v, true
  266. }
  267. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  268. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  270. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  271. if !m.op.Is(OpUpdateOne) {
  272. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  273. }
  274. if m.id == nil || m.oldValue == nil {
  275. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  276. }
  277. oldValue, err := m.oldValue(ctx)
  278. if err != nil {
  279. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  280. }
  281. return oldValue.UpdatedAt, nil
  282. }
  283. // ResetUpdatedAt resets all changes to the "updated_at" field.
  284. func (m *AgentMutation) ResetUpdatedAt() {
  285. m.updated_at = nil
  286. }
  287. // SetDeletedAt sets the "deleted_at" field.
  288. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  289. m.deleted_at = &t
  290. }
  291. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  292. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  293. v := m.deleted_at
  294. if v == nil {
  295. return
  296. }
  297. return *v, true
  298. }
  299. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  300. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  302. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  303. if !m.op.Is(OpUpdateOne) {
  304. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  305. }
  306. if m.id == nil || m.oldValue == nil {
  307. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  308. }
  309. oldValue, err := m.oldValue(ctx)
  310. if err != nil {
  311. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  312. }
  313. return oldValue.DeletedAt, nil
  314. }
  315. // ClearDeletedAt clears the value of the "deleted_at" field.
  316. func (m *AgentMutation) ClearDeletedAt() {
  317. m.deleted_at = nil
  318. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  319. }
  320. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  321. func (m *AgentMutation) DeletedAtCleared() bool {
  322. _, ok := m.clearedFields[agent.FieldDeletedAt]
  323. return ok
  324. }
  325. // ResetDeletedAt resets all changes to the "deleted_at" field.
  326. func (m *AgentMutation) ResetDeletedAt() {
  327. m.deleted_at = nil
  328. delete(m.clearedFields, agent.FieldDeletedAt)
  329. }
  330. // SetName sets the "name" field.
  331. func (m *AgentMutation) SetName(s string) {
  332. m.name = &s
  333. }
  334. // Name returns the value of the "name" field in the mutation.
  335. func (m *AgentMutation) Name() (r string, exists bool) {
  336. v := m.name
  337. if v == nil {
  338. return
  339. }
  340. return *v, true
  341. }
  342. // OldName returns the old "name" field's value of the Agent entity.
  343. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  345. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  346. if !m.op.Is(OpUpdateOne) {
  347. return v, errors.New("OldName is only allowed on UpdateOne operations")
  348. }
  349. if m.id == nil || m.oldValue == nil {
  350. return v, errors.New("OldName requires an ID field in the mutation")
  351. }
  352. oldValue, err := m.oldValue(ctx)
  353. if err != nil {
  354. return v, fmt.Errorf("querying old value for OldName: %w", err)
  355. }
  356. return oldValue.Name, nil
  357. }
  358. // ResetName resets all changes to the "name" field.
  359. func (m *AgentMutation) ResetName() {
  360. m.name = nil
  361. }
  362. // SetRole sets the "role" field.
  363. func (m *AgentMutation) SetRole(s string) {
  364. m.role = &s
  365. }
  366. // Role returns the value of the "role" field in the mutation.
  367. func (m *AgentMutation) Role() (r string, exists bool) {
  368. v := m.role
  369. if v == nil {
  370. return
  371. }
  372. return *v, true
  373. }
  374. // OldRole returns the old "role" field's value of the Agent entity.
  375. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  377. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  378. if !m.op.Is(OpUpdateOne) {
  379. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  380. }
  381. if m.id == nil || m.oldValue == nil {
  382. return v, errors.New("OldRole requires an ID field in the mutation")
  383. }
  384. oldValue, err := m.oldValue(ctx)
  385. if err != nil {
  386. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  387. }
  388. return oldValue.Role, nil
  389. }
  390. // ResetRole resets all changes to the "role" field.
  391. func (m *AgentMutation) ResetRole() {
  392. m.role = nil
  393. }
  394. // SetStatus sets the "status" field.
  395. func (m *AgentMutation) SetStatus(i int) {
  396. m.status = &i
  397. m.addstatus = nil
  398. }
  399. // Status returns the value of the "status" field in the mutation.
  400. func (m *AgentMutation) Status() (r int, exists bool) {
  401. v := m.status
  402. if v == nil {
  403. return
  404. }
  405. return *v, true
  406. }
  407. // OldStatus returns the old "status" field's value of the Agent entity.
  408. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  410. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  411. if !m.op.Is(OpUpdateOne) {
  412. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  413. }
  414. if m.id == nil || m.oldValue == nil {
  415. return v, errors.New("OldStatus requires an ID field in the mutation")
  416. }
  417. oldValue, err := m.oldValue(ctx)
  418. if err != nil {
  419. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  420. }
  421. return oldValue.Status, nil
  422. }
  423. // AddStatus adds i to the "status" field.
  424. func (m *AgentMutation) AddStatus(i int) {
  425. if m.addstatus != nil {
  426. *m.addstatus += i
  427. } else {
  428. m.addstatus = &i
  429. }
  430. }
  431. // AddedStatus returns the value that was added to the "status" field in this mutation.
  432. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  433. v := m.addstatus
  434. if v == nil {
  435. return
  436. }
  437. return *v, true
  438. }
  439. // ClearStatus clears the value of the "status" field.
  440. func (m *AgentMutation) ClearStatus() {
  441. m.status = nil
  442. m.addstatus = nil
  443. m.clearedFields[agent.FieldStatus] = struct{}{}
  444. }
  445. // StatusCleared returns if the "status" field was cleared in this mutation.
  446. func (m *AgentMutation) StatusCleared() bool {
  447. _, ok := m.clearedFields[agent.FieldStatus]
  448. return ok
  449. }
  450. // ResetStatus resets all changes to the "status" field.
  451. func (m *AgentMutation) ResetStatus() {
  452. m.status = nil
  453. m.addstatus = nil
  454. delete(m.clearedFields, agent.FieldStatus)
  455. }
  456. // SetBackground sets the "background" field.
  457. func (m *AgentMutation) SetBackground(s string) {
  458. m.background = &s
  459. }
  460. // Background returns the value of the "background" field in the mutation.
  461. func (m *AgentMutation) Background() (r string, exists bool) {
  462. v := m.background
  463. if v == nil {
  464. return
  465. }
  466. return *v, true
  467. }
  468. // OldBackground returns the old "background" field's value of the Agent entity.
  469. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  471. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  472. if !m.op.Is(OpUpdateOne) {
  473. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  474. }
  475. if m.id == nil || m.oldValue == nil {
  476. return v, errors.New("OldBackground requires an ID field in the mutation")
  477. }
  478. oldValue, err := m.oldValue(ctx)
  479. if err != nil {
  480. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  481. }
  482. return oldValue.Background, nil
  483. }
  484. // ClearBackground clears the value of the "background" field.
  485. func (m *AgentMutation) ClearBackground() {
  486. m.background = nil
  487. m.clearedFields[agent.FieldBackground] = struct{}{}
  488. }
  489. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  490. func (m *AgentMutation) BackgroundCleared() bool {
  491. _, ok := m.clearedFields[agent.FieldBackground]
  492. return ok
  493. }
  494. // ResetBackground resets all changes to the "background" field.
  495. func (m *AgentMutation) ResetBackground() {
  496. m.background = nil
  497. delete(m.clearedFields, agent.FieldBackground)
  498. }
  499. // SetExamples sets the "examples" field.
  500. func (m *AgentMutation) SetExamples(s string) {
  501. m.examples = &s
  502. }
  503. // Examples returns the value of the "examples" field in the mutation.
  504. func (m *AgentMutation) Examples() (r string, exists bool) {
  505. v := m.examples
  506. if v == nil {
  507. return
  508. }
  509. return *v, true
  510. }
  511. // OldExamples returns the old "examples" field's value of the Agent entity.
  512. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  514. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  515. if !m.op.Is(OpUpdateOne) {
  516. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  517. }
  518. if m.id == nil || m.oldValue == nil {
  519. return v, errors.New("OldExamples requires an ID field in the mutation")
  520. }
  521. oldValue, err := m.oldValue(ctx)
  522. if err != nil {
  523. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  524. }
  525. return oldValue.Examples, nil
  526. }
  527. // ClearExamples clears the value of the "examples" field.
  528. func (m *AgentMutation) ClearExamples() {
  529. m.examples = nil
  530. m.clearedFields[agent.FieldExamples] = struct{}{}
  531. }
  532. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  533. func (m *AgentMutation) ExamplesCleared() bool {
  534. _, ok := m.clearedFields[agent.FieldExamples]
  535. return ok
  536. }
  537. // ResetExamples resets all changes to the "examples" field.
  538. func (m *AgentMutation) ResetExamples() {
  539. m.examples = nil
  540. delete(m.clearedFields, agent.FieldExamples)
  541. }
  542. // SetOrganizationID sets the "organization_id" field.
  543. func (m *AgentMutation) SetOrganizationID(u uint64) {
  544. m.organization_id = &u
  545. m.addorganization_id = nil
  546. }
  547. // OrganizationID returns the value of the "organization_id" field in the mutation.
  548. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  549. v := m.organization_id
  550. if v == nil {
  551. return
  552. }
  553. return *v, true
  554. }
  555. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  556. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  558. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  559. if !m.op.Is(OpUpdateOne) {
  560. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  561. }
  562. if m.id == nil || m.oldValue == nil {
  563. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  564. }
  565. oldValue, err := m.oldValue(ctx)
  566. if err != nil {
  567. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  568. }
  569. return oldValue.OrganizationID, nil
  570. }
  571. // AddOrganizationID adds u to the "organization_id" field.
  572. func (m *AgentMutation) AddOrganizationID(u int64) {
  573. if m.addorganization_id != nil {
  574. *m.addorganization_id += u
  575. } else {
  576. m.addorganization_id = &u
  577. }
  578. }
  579. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  580. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  581. v := m.addorganization_id
  582. if v == nil {
  583. return
  584. }
  585. return *v, true
  586. }
  587. // ResetOrganizationID resets all changes to the "organization_id" field.
  588. func (m *AgentMutation) ResetOrganizationID() {
  589. m.organization_id = nil
  590. m.addorganization_id = nil
  591. }
  592. // SetDatasetID sets the "dataset_id" field.
  593. func (m *AgentMutation) SetDatasetID(s string) {
  594. m.dataset_id = &s
  595. }
  596. // DatasetID returns the value of the "dataset_id" field in the mutation.
  597. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  598. v := m.dataset_id
  599. if v == nil {
  600. return
  601. }
  602. return *v, true
  603. }
  604. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  605. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  607. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  608. if !m.op.Is(OpUpdateOne) {
  609. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  610. }
  611. if m.id == nil || m.oldValue == nil {
  612. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  613. }
  614. oldValue, err := m.oldValue(ctx)
  615. if err != nil {
  616. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  617. }
  618. return oldValue.DatasetID, nil
  619. }
  620. // ResetDatasetID resets all changes to the "dataset_id" field.
  621. func (m *AgentMutation) ResetDatasetID() {
  622. m.dataset_id = nil
  623. }
  624. // SetCollectionID sets the "collection_id" field.
  625. func (m *AgentMutation) SetCollectionID(s string) {
  626. m.collection_id = &s
  627. }
  628. // CollectionID returns the value of the "collection_id" field in the mutation.
  629. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  630. v := m.collection_id
  631. if v == nil {
  632. return
  633. }
  634. return *v, true
  635. }
  636. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  637. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  639. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  640. if !m.op.Is(OpUpdateOne) {
  641. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  642. }
  643. if m.id == nil || m.oldValue == nil {
  644. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  645. }
  646. oldValue, err := m.oldValue(ctx)
  647. if err != nil {
  648. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  649. }
  650. return oldValue.CollectionID, nil
  651. }
  652. // ResetCollectionID resets all changes to the "collection_id" field.
  653. func (m *AgentMutation) ResetCollectionID() {
  654. m.collection_id = nil
  655. }
  656. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  657. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  658. if m.wx_agent == nil {
  659. m.wx_agent = make(map[uint64]struct{})
  660. }
  661. for i := range ids {
  662. m.wx_agent[ids[i]] = struct{}{}
  663. }
  664. }
  665. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  666. func (m *AgentMutation) ClearWxAgent() {
  667. m.clearedwx_agent = true
  668. }
  669. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  670. func (m *AgentMutation) WxAgentCleared() bool {
  671. return m.clearedwx_agent
  672. }
  673. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  674. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  675. if m.removedwx_agent == nil {
  676. m.removedwx_agent = make(map[uint64]struct{})
  677. }
  678. for i := range ids {
  679. delete(m.wx_agent, ids[i])
  680. m.removedwx_agent[ids[i]] = struct{}{}
  681. }
  682. }
  683. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  684. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  685. for id := range m.removedwx_agent {
  686. ids = append(ids, id)
  687. }
  688. return
  689. }
  690. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  691. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  692. for id := range m.wx_agent {
  693. ids = append(ids, id)
  694. }
  695. return
  696. }
  697. // ResetWxAgent resets all changes to the "wx_agent" edge.
  698. func (m *AgentMutation) ResetWxAgent() {
  699. m.wx_agent = nil
  700. m.clearedwx_agent = false
  701. m.removedwx_agent = nil
  702. }
  703. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  704. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  705. if m.token_agent == nil {
  706. m.token_agent = make(map[uint64]struct{})
  707. }
  708. for i := range ids {
  709. m.token_agent[ids[i]] = struct{}{}
  710. }
  711. }
  712. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  713. func (m *AgentMutation) ClearTokenAgent() {
  714. m.clearedtoken_agent = true
  715. }
  716. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  717. func (m *AgentMutation) TokenAgentCleared() bool {
  718. return m.clearedtoken_agent
  719. }
  720. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  721. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  722. if m.removedtoken_agent == nil {
  723. m.removedtoken_agent = make(map[uint64]struct{})
  724. }
  725. for i := range ids {
  726. delete(m.token_agent, ids[i])
  727. m.removedtoken_agent[ids[i]] = struct{}{}
  728. }
  729. }
  730. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  731. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  732. for id := range m.removedtoken_agent {
  733. ids = append(ids, id)
  734. }
  735. return
  736. }
  737. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  738. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  739. for id := range m.token_agent {
  740. ids = append(ids, id)
  741. }
  742. return
  743. }
  744. // ResetTokenAgent resets all changes to the "token_agent" edge.
  745. func (m *AgentMutation) ResetTokenAgent() {
  746. m.token_agent = nil
  747. m.clearedtoken_agent = false
  748. m.removedtoken_agent = nil
  749. }
  750. // Where appends a list predicates to the AgentMutation builder.
  751. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  752. m.predicates = append(m.predicates, ps...)
  753. }
  754. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  755. // users can use type-assertion to append predicates that do not depend on any generated package.
  756. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  757. p := make([]predicate.Agent, len(ps))
  758. for i := range ps {
  759. p[i] = ps[i]
  760. }
  761. m.Where(p...)
  762. }
  763. // Op returns the operation name.
  764. func (m *AgentMutation) Op() Op {
  765. return m.op
  766. }
  767. // SetOp allows setting the mutation operation.
  768. func (m *AgentMutation) SetOp(op Op) {
  769. m.op = op
  770. }
  771. // Type returns the node type of this mutation (Agent).
  772. func (m *AgentMutation) Type() string {
  773. return m.typ
  774. }
  775. // Fields returns all fields that were changed during this mutation. Note that in
  776. // order to get all numeric fields that were incremented/decremented, call
  777. // AddedFields().
  778. func (m *AgentMutation) Fields() []string {
  779. fields := make([]string, 0, 11)
  780. if m.created_at != nil {
  781. fields = append(fields, agent.FieldCreatedAt)
  782. }
  783. if m.updated_at != nil {
  784. fields = append(fields, agent.FieldUpdatedAt)
  785. }
  786. if m.deleted_at != nil {
  787. fields = append(fields, agent.FieldDeletedAt)
  788. }
  789. if m.name != nil {
  790. fields = append(fields, agent.FieldName)
  791. }
  792. if m.role != nil {
  793. fields = append(fields, agent.FieldRole)
  794. }
  795. if m.status != nil {
  796. fields = append(fields, agent.FieldStatus)
  797. }
  798. if m.background != nil {
  799. fields = append(fields, agent.FieldBackground)
  800. }
  801. if m.examples != nil {
  802. fields = append(fields, agent.FieldExamples)
  803. }
  804. if m.organization_id != nil {
  805. fields = append(fields, agent.FieldOrganizationID)
  806. }
  807. if m.dataset_id != nil {
  808. fields = append(fields, agent.FieldDatasetID)
  809. }
  810. if m.collection_id != nil {
  811. fields = append(fields, agent.FieldCollectionID)
  812. }
  813. return fields
  814. }
  815. // Field returns the value of a field with the given name. The second boolean
  816. // return value indicates that this field was not set, or was not defined in the
  817. // schema.
  818. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  819. switch name {
  820. case agent.FieldCreatedAt:
  821. return m.CreatedAt()
  822. case agent.FieldUpdatedAt:
  823. return m.UpdatedAt()
  824. case agent.FieldDeletedAt:
  825. return m.DeletedAt()
  826. case agent.FieldName:
  827. return m.Name()
  828. case agent.FieldRole:
  829. return m.Role()
  830. case agent.FieldStatus:
  831. return m.Status()
  832. case agent.FieldBackground:
  833. return m.Background()
  834. case agent.FieldExamples:
  835. return m.Examples()
  836. case agent.FieldOrganizationID:
  837. return m.OrganizationID()
  838. case agent.FieldDatasetID:
  839. return m.DatasetID()
  840. case agent.FieldCollectionID:
  841. return m.CollectionID()
  842. }
  843. return nil, false
  844. }
  845. // OldField returns the old value of the field from the database. An error is
  846. // returned if the mutation operation is not UpdateOne, or the query to the
  847. // database failed.
  848. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  849. switch name {
  850. case agent.FieldCreatedAt:
  851. return m.OldCreatedAt(ctx)
  852. case agent.FieldUpdatedAt:
  853. return m.OldUpdatedAt(ctx)
  854. case agent.FieldDeletedAt:
  855. return m.OldDeletedAt(ctx)
  856. case agent.FieldName:
  857. return m.OldName(ctx)
  858. case agent.FieldRole:
  859. return m.OldRole(ctx)
  860. case agent.FieldStatus:
  861. return m.OldStatus(ctx)
  862. case agent.FieldBackground:
  863. return m.OldBackground(ctx)
  864. case agent.FieldExamples:
  865. return m.OldExamples(ctx)
  866. case agent.FieldOrganizationID:
  867. return m.OldOrganizationID(ctx)
  868. case agent.FieldDatasetID:
  869. return m.OldDatasetID(ctx)
  870. case agent.FieldCollectionID:
  871. return m.OldCollectionID(ctx)
  872. }
  873. return nil, fmt.Errorf("unknown Agent field %s", name)
  874. }
  875. // SetField sets the value of a field with the given name. It returns an error if
  876. // the field is not defined in the schema, or if the type mismatched the field
  877. // type.
  878. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  879. switch name {
  880. case agent.FieldCreatedAt:
  881. v, ok := value.(time.Time)
  882. if !ok {
  883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  884. }
  885. m.SetCreatedAt(v)
  886. return nil
  887. case agent.FieldUpdatedAt:
  888. v, ok := value.(time.Time)
  889. if !ok {
  890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  891. }
  892. m.SetUpdatedAt(v)
  893. return nil
  894. case agent.FieldDeletedAt:
  895. v, ok := value.(time.Time)
  896. if !ok {
  897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  898. }
  899. m.SetDeletedAt(v)
  900. return nil
  901. case agent.FieldName:
  902. v, ok := value.(string)
  903. if !ok {
  904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  905. }
  906. m.SetName(v)
  907. return nil
  908. case agent.FieldRole:
  909. v, ok := value.(string)
  910. if !ok {
  911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  912. }
  913. m.SetRole(v)
  914. return nil
  915. case agent.FieldStatus:
  916. v, ok := value.(int)
  917. if !ok {
  918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  919. }
  920. m.SetStatus(v)
  921. return nil
  922. case agent.FieldBackground:
  923. v, ok := value.(string)
  924. if !ok {
  925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  926. }
  927. m.SetBackground(v)
  928. return nil
  929. case agent.FieldExamples:
  930. v, ok := value.(string)
  931. if !ok {
  932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  933. }
  934. m.SetExamples(v)
  935. return nil
  936. case agent.FieldOrganizationID:
  937. v, ok := value.(uint64)
  938. if !ok {
  939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  940. }
  941. m.SetOrganizationID(v)
  942. return nil
  943. case agent.FieldDatasetID:
  944. v, ok := value.(string)
  945. if !ok {
  946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  947. }
  948. m.SetDatasetID(v)
  949. return nil
  950. case agent.FieldCollectionID:
  951. v, ok := value.(string)
  952. if !ok {
  953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  954. }
  955. m.SetCollectionID(v)
  956. return nil
  957. }
  958. return fmt.Errorf("unknown Agent field %s", name)
  959. }
  960. // AddedFields returns all numeric fields that were incremented/decremented during
  961. // this mutation.
  962. func (m *AgentMutation) AddedFields() []string {
  963. var fields []string
  964. if m.addstatus != nil {
  965. fields = append(fields, agent.FieldStatus)
  966. }
  967. if m.addorganization_id != nil {
  968. fields = append(fields, agent.FieldOrganizationID)
  969. }
  970. return fields
  971. }
  972. // AddedField returns the numeric value that was incremented/decremented on a field
  973. // with the given name. The second boolean return value indicates that this field
  974. // was not set, or was not defined in the schema.
  975. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  976. switch name {
  977. case agent.FieldStatus:
  978. return m.AddedStatus()
  979. case agent.FieldOrganizationID:
  980. return m.AddedOrganizationID()
  981. }
  982. return nil, false
  983. }
  984. // AddField adds the value to the field with the given name. It returns an error if
  985. // the field is not defined in the schema, or if the type mismatched the field
  986. // type.
  987. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  988. switch name {
  989. case agent.FieldStatus:
  990. v, ok := value.(int)
  991. if !ok {
  992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  993. }
  994. m.AddStatus(v)
  995. return nil
  996. case agent.FieldOrganizationID:
  997. v, ok := value.(int64)
  998. if !ok {
  999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1000. }
  1001. m.AddOrganizationID(v)
  1002. return nil
  1003. }
  1004. return fmt.Errorf("unknown Agent numeric field %s", name)
  1005. }
  1006. // ClearedFields returns all nullable fields that were cleared during this
  1007. // mutation.
  1008. func (m *AgentMutation) ClearedFields() []string {
  1009. var fields []string
  1010. if m.FieldCleared(agent.FieldDeletedAt) {
  1011. fields = append(fields, agent.FieldDeletedAt)
  1012. }
  1013. if m.FieldCleared(agent.FieldStatus) {
  1014. fields = append(fields, agent.FieldStatus)
  1015. }
  1016. if m.FieldCleared(agent.FieldBackground) {
  1017. fields = append(fields, agent.FieldBackground)
  1018. }
  1019. if m.FieldCleared(agent.FieldExamples) {
  1020. fields = append(fields, agent.FieldExamples)
  1021. }
  1022. return fields
  1023. }
  1024. // FieldCleared returns a boolean indicating if a field with the given name was
  1025. // cleared in this mutation.
  1026. func (m *AgentMutation) FieldCleared(name string) bool {
  1027. _, ok := m.clearedFields[name]
  1028. return ok
  1029. }
  1030. // ClearField clears the value of the field with the given name. It returns an
  1031. // error if the field is not defined in the schema.
  1032. func (m *AgentMutation) ClearField(name string) error {
  1033. switch name {
  1034. case agent.FieldDeletedAt:
  1035. m.ClearDeletedAt()
  1036. return nil
  1037. case agent.FieldStatus:
  1038. m.ClearStatus()
  1039. return nil
  1040. case agent.FieldBackground:
  1041. m.ClearBackground()
  1042. return nil
  1043. case agent.FieldExamples:
  1044. m.ClearExamples()
  1045. return nil
  1046. }
  1047. return fmt.Errorf("unknown Agent nullable field %s", name)
  1048. }
  1049. // ResetField resets all changes in the mutation for the field with the given name.
  1050. // It returns an error if the field is not defined in the schema.
  1051. func (m *AgentMutation) ResetField(name string) error {
  1052. switch name {
  1053. case agent.FieldCreatedAt:
  1054. m.ResetCreatedAt()
  1055. return nil
  1056. case agent.FieldUpdatedAt:
  1057. m.ResetUpdatedAt()
  1058. return nil
  1059. case agent.FieldDeletedAt:
  1060. m.ResetDeletedAt()
  1061. return nil
  1062. case agent.FieldName:
  1063. m.ResetName()
  1064. return nil
  1065. case agent.FieldRole:
  1066. m.ResetRole()
  1067. return nil
  1068. case agent.FieldStatus:
  1069. m.ResetStatus()
  1070. return nil
  1071. case agent.FieldBackground:
  1072. m.ResetBackground()
  1073. return nil
  1074. case agent.FieldExamples:
  1075. m.ResetExamples()
  1076. return nil
  1077. case agent.FieldOrganizationID:
  1078. m.ResetOrganizationID()
  1079. return nil
  1080. case agent.FieldDatasetID:
  1081. m.ResetDatasetID()
  1082. return nil
  1083. case agent.FieldCollectionID:
  1084. m.ResetCollectionID()
  1085. return nil
  1086. }
  1087. return fmt.Errorf("unknown Agent field %s", name)
  1088. }
  1089. // AddedEdges returns all edge names that were set/added in this mutation.
  1090. func (m *AgentMutation) AddedEdges() []string {
  1091. edges := make([]string, 0, 2)
  1092. if m.wx_agent != nil {
  1093. edges = append(edges, agent.EdgeWxAgent)
  1094. }
  1095. if m.token_agent != nil {
  1096. edges = append(edges, agent.EdgeTokenAgent)
  1097. }
  1098. return edges
  1099. }
  1100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1101. // name in this mutation.
  1102. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1103. switch name {
  1104. case agent.EdgeWxAgent:
  1105. ids := make([]ent.Value, 0, len(m.wx_agent))
  1106. for id := range m.wx_agent {
  1107. ids = append(ids, id)
  1108. }
  1109. return ids
  1110. case agent.EdgeTokenAgent:
  1111. ids := make([]ent.Value, 0, len(m.token_agent))
  1112. for id := range m.token_agent {
  1113. ids = append(ids, id)
  1114. }
  1115. return ids
  1116. }
  1117. return nil
  1118. }
  1119. // RemovedEdges returns all edge names that were removed in this mutation.
  1120. func (m *AgentMutation) RemovedEdges() []string {
  1121. edges := make([]string, 0, 2)
  1122. if m.removedwx_agent != nil {
  1123. edges = append(edges, agent.EdgeWxAgent)
  1124. }
  1125. if m.removedtoken_agent != nil {
  1126. edges = append(edges, agent.EdgeTokenAgent)
  1127. }
  1128. return edges
  1129. }
  1130. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1131. // the given name in this mutation.
  1132. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1133. switch name {
  1134. case agent.EdgeWxAgent:
  1135. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1136. for id := range m.removedwx_agent {
  1137. ids = append(ids, id)
  1138. }
  1139. return ids
  1140. case agent.EdgeTokenAgent:
  1141. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1142. for id := range m.removedtoken_agent {
  1143. ids = append(ids, id)
  1144. }
  1145. return ids
  1146. }
  1147. return nil
  1148. }
  1149. // ClearedEdges returns all edge names that were cleared in this mutation.
  1150. func (m *AgentMutation) ClearedEdges() []string {
  1151. edges := make([]string, 0, 2)
  1152. if m.clearedwx_agent {
  1153. edges = append(edges, agent.EdgeWxAgent)
  1154. }
  1155. if m.clearedtoken_agent {
  1156. edges = append(edges, agent.EdgeTokenAgent)
  1157. }
  1158. return edges
  1159. }
  1160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1161. // was cleared in this mutation.
  1162. func (m *AgentMutation) EdgeCleared(name string) bool {
  1163. switch name {
  1164. case agent.EdgeWxAgent:
  1165. return m.clearedwx_agent
  1166. case agent.EdgeTokenAgent:
  1167. return m.clearedtoken_agent
  1168. }
  1169. return false
  1170. }
  1171. // ClearEdge clears the value of the edge with the given name. It returns an error
  1172. // if that edge is not defined in the schema.
  1173. func (m *AgentMutation) ClearEdge(name string) error {
  1174. switch name {
  1175. }
  1176. return fmt.Errorf("unknown Agent unique edge %s", name)
  1177. }
  1178. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1179. // It returns an error if the edge is not defined in the schema.
  1180. func (m *AgentMutation) ResetEdge(name string) error {
  1181. switch name {
  1182. case agent.EdgeWxAgent:
  1183. m.ResetWxAgent()
  1184. return nil
  1185. case agent.EdgeTokenAgent:
  1186. m.ResetTokenAgent()
  1187. return nil
  1188. }
  1189. return fmt.Errorf("unknown Agent edge %s", name)
  1190. }
  1191. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1192. type AgentBaseMutation struct {
  1193. config
  1194. op Op
  1195. typ string
  1196. id *string
  1197. q *string
  1198. a *string
  1199. chunk_index *uint64
  1200. addchunk_index *int64
  1201. indexes *[]string
  1202. appendindexes []string
  1203. dataset_id *string
  1204. collection_id *string
  1205. source_name *string
  1206. can_write *[]bool
  1207. appendcan_write []bool
  1208. is_owner *[]bool
  1209. appendis_owner []bool
  1210. clearedFields map[string]struct{}
  1211. wx_agent map[uint64]struct{}
  1212. removedwx_agent map[uint64]struct{}
  1213. clearedwx_agent bool
  1214. done bool
  1215. oldValue func(context.Context) (*AgentBase, error)
  1216. predicates []predicate.AgentBase
  1217. }
  1218. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1219. // agentbaseOption allows management of the mutation configuration using functional options.
  1220. type agentbaseOption func(*AgentBaseMutation)
  1221. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1222. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1223. m := &AgentBaseMutation{
  1224. config: c,
  1225. op: op,
  1226. typ: TypeAgentBase,
  1227. clearedFields: make(map[string]struct{}),
  1228. }
  1229. for _, opt := range opts {
  1230. opt(m)
  1231. }
  1232. return m
  1233. }
  1234. // withAgentBaseID sets the ID field of the mutation.
  1235. func withAgentBaseID(id string) agentbaseOption {
  1236. return func(m *AgentBaseMutation) {
  1237. var (
  1238. err error
  1239. once sync.Once
  1240. value *AgentBase
  1241. )
  1242. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1243. once.Do(func() {
  1244. if m.done {
  1245. err = errors.New("querying old values post mutation is not allowed")
  1246. } else {
  1247. value, err = m.Client().AgentBase.Get(ctx, id)
  1248. }
  1249. })
  1250. return value, err
  1251. }
  1252. m.id = &id
  1253. }
  1254. }
  1255. // withAgentBase sets the old AgentBase of the mutation.
  1256. func withAgentBase(node *AgentBase) agentbaseOption {
  1257. return func(m *AgentBaseMutation) {
  1258. m.oldValue = func(context.Context) (*AgentBase, error) {
  1259. return node, nil
  1260. }
  1261. m.id = &node.ID
  1262. }
  1263. }
  1264. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1265. // executed in a transaction (ent.Tx), a transactional client is returned.
  1266. func (m AgentBaseMutation) Client() *Client {
  1267. client := &Client{config: m.config}
  1268. client.init()
  1269. return client
  1270. }
  1271. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1272. // it returns an error otherwise.
  1273. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1274. if _, ok := m.driver.(*txDriver); !ok {
  1275. return nil, errors.New("ent: mutation is not running in a transaction")
  1276. }
  1277. tx := &Tx{config: m.config}
  1278. tx.init()
  1279. return tx, nil
  1280. }
  1281. // SetID sets the value of the id field. Note that this
  1282. // operation is only accepted on creation of AgentBase entities.
  1283. func (m *AgentBaseMutation) SetID(id string) {
  1284. m.id = &id
  1285. }
  1286. // ID returns the ID value in the mutation. Note that the ID is only available
  1287. // if it was provided to the builder or after it was returned from the database.
  1288. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1289. if m.id == nil {
  1290. return
  1291. }
  1292. return *m.id, true
  1293. }
  1294. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1295. // That means, if the mutation is applied within a transaction with an isolation level such
  1296. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1297. // or updated by the mutation.
  1298. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1299. switch {
  1300. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1301. id, exists := m.ID()
  1302. if exists {
  1303. return []string{id}, nil
  1304. }
  1305. fallthrough
  1306. case m.op.Is(OpUpdate | OpDelete):
  1307. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1308. default:
  1309. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1310. }
  1311. }
  1312. // SetQ sets the "q" field.
  1313. func (m *AgentBaseMutation) SetQ(s string) {
  1314. m.q = &s
  1315. }
  1316. // Q returns the value of the "q" field in the mutation.
  1317. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1318. v := m.q
  1319. if v == nil {
  1320. return
  1321. }
  1322. return *v, true
  1323. }
  1324. // OldQ returns the old "q" field's value of the AgentBase entity.
  1325. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1327. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1328. if !m.op.Is(OpUpdateOne) {
  1329. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1330. }
  1331. if m.id == nil || m.oldValue == nil {
  1332. return v, errors.New("OldQ requires an ID field in the mutation")
  1333. }
  1334. oldValue, err := m.oldValue(ctx)
  1335. if err != nil {
  1336. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1337. }
  1338. return oldValue.Q, nil
  1339. }
  1340. // ClearQ clears the value of the "q" field.
  1341. func (m *AgentBaseMutation) ClearQ() {
  1342. m.q = nil
  1343. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1344. }
  1345. // QCleared returns if the "q" field was cleared in this mutation.
  1346. func (m *AgentBaseMutation) QCleared() bool {
  1347. _, ok := m.clearedFields[agentbase.FieldQ]
  1348. return ok
  1349. }
  1350. // ResetQ resets all changes to the "q" field.
  1351. func (m *AgentBaseMutation) ResetQ() {
  1352. m.q = nil
  1353. delete(m.clearedFields, agentbase.FieldQ)
  1354. }
  1355. // SetA sets the "a" field.
  1356. func (m *AgentBaseMutation) SetA(s string) {
  1357. m.a = &s
  1358. }
  1359. // A returns the value of the "a" field in the mutation.
  1360. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1361. v := m.a
  1362. if v == nil {
  1363. return
  1364. }
  1365. return *v, true
  1366. }
  1367. // OldA returns the old "a" field's value of the AgentBase entity.
  1368. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1370. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1371. if !m.op.Is(OpUpdateOne) {
  1372. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1373. }
  1374. if m.id == nil || m.oldValue == nil {
  1375. return v, errors.New("OldA requires an ID field in the mutation")
  1376. }
  1377. oldValue, err := m.oldValue(ctx)
  1378. if err != nil {
  1379. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1380. }
  1381. return oldValue.A, nil
  1382. }
  1383. // ClearA clears the value of the "a" field.
  1384. func (m *AgentBaseMutation) ClearA() {
  1385. m.a = nil
  1386. m.clearedFields[agentbase.FieldA] = struct{}{}
  1387. }
  1388. // ACleared returns if the "a" field was cleared in this mutation.
  1389. func (m *AgentBaseMutation) ACleared() bool {
  1390. _, ok := m.clearedFields[agentbase.FieldA]
  1391. return ok
  1392. }
  1393. // ResetA resets all changes to the "a" field.
  1394. func (m *AgentBaseMutation) ResetA() {
  1395. m.a = nil
  1396. delete(m.clearedFields, agentbase.FieldA)
  1397. }
  1398. // SetChunkIndex sets the "chunk_index" field.
  1399. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1400. m.chunk_index = &u
  1401. m.addchunk_index = nil
  1402. }
  1403. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1404. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1405. v := m.chunk_index
  1406. if v == nil {
  1407. return
  1408. }
  1409. return *v, true
  1410. }
  1411. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1412. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1414. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1415. if !m.op.Is(OpUpdateOne) {
  1416. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1417. }
  1418. if m.id == nil || m.oldValue == nil {
  1419. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1420. }
  1421. oldValue, err := m.oldValue(ctx)
  1422. if err != nil {
  1423. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1424. }
  1425. return oldValue.ChunkIndex, nil
  1426. }
  1427. // AddChunkIndex adds u to the "chunk_index" field.
  1428. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1429. if m.addchunk_index != nil {
  1430. *m.addchunk_index += u
  1431. } else {
  1432. m.addchunk_index = &u
  1433. }
  1434. }
  1435. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1436. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1437. v := m.addchunk_index
  1438. if v == nil {
  1439. return
  1440. }
  1441. return *v, true
  1442. }
  1443. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1444. func (m *AgentBaseMutation) ResetChunkIndex() {
  1445. m.chunk_index = nil
  1446. m.addchunk_index = nil
  1447. }
  1448. // SetIndexes sets the "indexes" field.
  1449. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1450. m.indexes = &s
  1451. m.appendindexes = nil
  1452. }
  1453. // Indexes returns the value of the "indexes" field in the mutation.
  1454. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1455. v := m.indexes
  1456. if v == nil {
  1457. return
  1458. }
  1459. return *v, true
  1460. }
  1461. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1462. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1464. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1465. if !m.op.Is(OpUpdateOne) {
  1466. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1467. }
  1468. if m.id == nil || m.oldValue == nil {
  1469. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1470. }
  1471. oldValue, err := m.oldValue(ctx)
  1472. if err != nil {
  1473. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1474. }
  1475. return oldValue.Indexes, nil
  1476. }
  1477. // AppendIndexes adds s to the "indexes" field.
  1478. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1479. m.appendindexes = append(m.appendindexes, s...)
  1480. }
  1481. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1482. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1483. if len(m.appendindexes) == 0 {
  1484. return nil, false
  1485. }
  1486. return m.appendindexes, true
  1487. }
  1488. // ClearIndexes clears the value of the "indexes" field.
  1489. func (m *AgentBaseMutation) ClearIndexes() {
  1490. m.indexes = nil
  1491. m.appendindexes = nil
  1492. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1493. }
  1494. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1495. func (m *AgentBaseMutation) IndexesCleared() bool {
  1496. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1497. return ok
  1498. }
  1499. // ResetIndexes resets all changes to the "indexes" field.
  1500. func (m *AgentBaseMutation) ResetIndexes() {
  1501. m.indexes = nil
  1502. m.appendindexes = nil
  1503. delete(m.clearedFields, agentbase.FieldIndexes)
  1504. }
  1505. // SetDatasetID sets the "dataset_id" field.
  1506. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1507. m.dataset_id = &s
  1508. }
  1509. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1510. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1511. v := m.dataset_id
  1512. if v == nil {
  1513. return
  1514. }
  1515. return *v, true
  1516. }
  1517. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1518. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1520. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1521. if !m.op.Is(OpUpdateOne) {
  1522. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1523. }
  1524. if m.id == nil || m.oldValue == nil {
  1525. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1526. }
  1527. oldValue, err := m.oldValue(ctx)
  1528. if err != nil {
  1529. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1530. }
  1531. return oldValue.DatasetID, nil
  1532. }
  1533. // ClearDatasetID clears the value of the "dataset_id" field.
  1534. func (m *AgentBaseMutation) ClearDatasetID() {
  1535. m.dataset_id = nil
  1536. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1537. }
  1538. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1539. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1540. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1541. return ok
  1542. }
  1543. // ResetDatasetID resets all changes to the "dataset_id" field.
  1544. func (m *AgentBaseMutation) ResetDatasetID() {
  1545. m.dataset_id = nil
  1546. delete(m.clearedFields, agentbase.FieldDatasetID)
  1547. }
  1548. // SetCollectionID sets the "collection_id" field.
  1549. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1550. m.collection_id = &s
  1551. }
  1552. // CollectionID returns the value of the "collection_id" field in the mutation.
  1553. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1554. v := m.collection_id
  1555. if v == nil {
  1556. return
  1557. }
  1558. return *v, true
  1559. }
  1560. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1561. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1563. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1564. if !m.op.Is(OpUpdateOne) {
  1565. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1566. }
  1567. if m.id == nil || m.oldValue == nil {
  1568. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1569. }
  1570. oldValue, err := m.oldValue(ctx)
  1571. if err != nil {
  1572. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1573. }
  1574. return oldValue.CollectionID, nil
  1575. }
  1576. // ClearCollectionID clears the value of the "collection_id" field.
  1577. func (m *AgentBaseMutation) ClearCollectionID() {
  1578. m.collection_id = nil
  1579. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1580. }
  1581. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1582. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1583. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1584. return ok
  1585. }
  1586. // ResetCollectionID resets all changes to the "collection_id" field.
  1587. func (m *AgentBaseMutation) ResetCollectionID() {
  1588. m.collection_id = nil
  1589. delete(m.clearedFields, agentbase.FieldCollectionID)
  1590. }
  1591. // SetSourceName sets the "source_name" field.
  1592. func (m *AgentBaseMutation) SetSourceName(s string) {
  1593. m.source_name = &s
  1594. }
  1595. // SourceName returns the value of the "source_name" field in the mutation.
  1596. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1597. v := m.source_name
  1598. if v == nil {
  1599. return
  1600. }
  1601. return *v, true
  1602. }
  1603. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1604. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1606. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1607. if !m.op.Is(OpUpdateOne) {
  1608. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1609. }
  1610. if m.id == nil || m.oldValue == nil {
  1611. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1612. }
  1613. oldValue, err := m.oldValue(ctx)
  1614. if err != nil {
  1615. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1616. }
  1617. return oldValue.SourceName, nil
  1618. }
  1619. // ClearSourceName clears the value of the "source_name" field.
  1620. func (m *AgentBaseMutation) ClearSourceName() {
  1621. m.source_name = nil
  1622. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1623. }
  1624. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1625. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1626. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1627. return ok
  1628. }
  1629. // ResetSourceName resets all changes to the "source_name" field.
  1630. func (m *AgentBaseMutation) ResetSourceName() {
  1631. m.source_name = nil
  1632. delete(m.clearedFields, agentbase.FieldSourceName)
  1633. }
  1634. // SetCanWrite sets the "can_write" field.
  1635. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1636. m.can_write = &b
  1637. m.appendcan_write = nil
  1638. }
  1639. // CanWrite returns the value of the "can_write" field in the mutation.
  1640. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1641. v := m.can_write
  1642. if v == nil {
  1643. return
  1644. }
  1645. return *v, true
  1646. }
  1647. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1648. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1650. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1651. if !m.op.Is(OpUpdateOne) {
  1652. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1653. }
  1654. if m.id == nil || m.oldValue == nil {
  1655. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1656. }
  1657. oldValue, err := m.oldValue(ctx)
  1658. if err != nil {
  1659. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1660. }
  1661. return oldValue.CanWrite, nil
  1662. }
  1663. // AppendCanWrite adds b to the "can_write" field.
  1664. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1665. m.appendcan_write = append(m.appendcan_write, b...)
  1666. }
  1667. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1668. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1669. if len(m.appendcan_write) == 0 {
  1670. return nil, false
  1671. }
  1672. return m.appendcan_write, true
  1673. }
  1674. // ClearCanWrite clears the value of the "can_write" field.
  1675. func (m *AgentBaseMutation) ClearCanWrite() {
  1676. m.can_write = nil
  1677. m.appendcan_write = nil
  1678. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1679. }
  1680. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1681. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1682. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1683. return ok
  1684. }
  1685. // ResetCanWrite resets all changes to the "can_write" field.
  1686. func (m *AgentBaseMutation) ResetCanWrite() {
  1687. m.can_write = nil
  1688. m.appendcan_write = nil
  1689. delete(m.clearedFields, agentbase.FieldCanWrite)
  1690. }
  1691. // SetIsOwner sets the "is_owner" field.
  1692. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1693. m.is_owner = &b
  1694. m.appendis_owner = nil
  1695. }
  1696. // IsOwner returns the value of the "is_owner" field in the mutation.
  1697. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1698. v := m.is_owner
  1699. if v == nil {
  1700. return
  1701. }
  1702. return *v, true
  1703. }
  1704. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1705. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1707. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1708. if !m.op.Is(OpUpdateOne) {
  1709. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1710. }
  1711. if m.id == nil || m.oldValue == nil {
  1712. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1713. }
  1714. oldValue, err := m.oldValue(ctx)
  1715. if err != nil {
  1716. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1717. }
  1718. return oldValue.IsOwner, nil
  1719. }
  1720. // AppendIsOwner adds b to the "is_owner" field.
  1721. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1722. m.appendis_owner = append(m.appendis_owner, b...)
  1723. }
  1724. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1725. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1726. if len(m.appendis_owner) == 0 {
  1727. return nil, false
  1728. }
  1729. return m.appendis_owner, true
  1730. }
  1731. // ClearIsOwner clears the value of the "is_owner" field.
  1732. func (m *AgentBaseMutation) ClearIsOwner() {
  1733. m.is_owner = nil
  1734. m.appendis_owner = nil
  1735. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1736. }
  1737. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1738. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1739. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1740. return ok
  1741. }
  1742. // ResetIsOwner resets all changes to the "is_owner" field.
  1743. func (m *AgentBaseMutation) ResetIsOwner() {
  1744. m.is_owner = nil
  1745. m.appendis_owner = nil
  1746. delete(m.clearedFields, agentbase.FieldIsOwner)
  1747. }
  1748. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1749. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1750. if m.wx_agent == nil {
  1751. m.wx_agent = make(map[uint64]struct{})
  1752. }
  1753. for i := range ids {
  1754. m.wx_agent[ids[i]] = struct{}{}
  1755. }
  1756. }
  1757. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1758. func (m *AgentBaseMutation) ClearWxAgent() {
  1759. m.clearedwx_agent = true
  1760. }
  1761. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1762. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1763. return m.clearedwx_agent
  1764. }
  1765. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1766. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1767. if m.removedwx_agent == nil {
  1768. m.removedwx_agent = make(map[uint64]struct{})
  1769. }
  1770. for i := range ids {
  1771. delete(m.wx_agent, ids[i])
  1772. m.removedwx_agent[ids[i]] = struct{}{}
  1773. }
  1774. }
  1775. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1776. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1777. for id := range m.removedwx_agent {
  1778. ids = append(ids, id)
  1779. }
  1780. return
  1781. }
  1782. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1783. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1784. for id := range m.wx_agent {
  1785. ids = append(ids, id)
  1786. }
  1787. return
  1788. }
  1789. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1790. func (m *AgentBaseMutation) ResetWxAgent() {
  1791. m.wx_agent = nil
  1792. m.clearedwx_agent = false
  1793. m.removedwx_agent = nil
  1794. }
  1795. // Where appends a list predicates to the AgentBaseMutation builder.
  1796. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1797. m.predicates = append(m.predicates, ps...)
  1798. }
  1799. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1800. // users can use type-assertion to append predicates that do not depend on any generated package.
  1801. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1802. p := make([]predicate.AgentBase, len(ps))
  1803. for i := range ps {
  1804. p[i] = ps[i]
  1805. }
  1806. m.Where(p...)
  1807. }
  1808. // Op returns the operation name.
  1809. func (m *AgentBaseMutation) Op() Op {
  1810. return m.op
  1811. }
  1812. // SetOp allows setting the mutation operation.
  1813. func (m *AgentBaseMutation) SetOp(op Op) {
  1814. m.op = op
  1815. }
  1816. // Type returns the node type of this mutation (AgentBase).
  1817. func (m *AgentBaseMutation) Type() string {
  1818. return m.typ
  1819. }
  1820. // Fields returns all fields that were changed during this mutation. Note that in
  1821. // order to get all numeric fields that were incremented/decremented, call
  1822. // AddedFields().
  1823. func (m *AgentBaseMutation) Fields() []string {
  1824. fields := make([]string, 0, 9)
  1825. if m.q != nil {
  1826. fields = append(fields, agentbase.FieldQ)
  1827. }
  1828. if m.a != nil {
  1829. fields = append(fields, agentbase.FieldA)
  1830. }
  1831. if m.chunk_index != nil {
  1832. fields = append(fields, agentbase.FieldChunkIndex)
  1833. }
  1834. if m.indexes != nil {
  1835. fields = append(fields, agentbase.FieldIndexes)
  1836. }
  1837. if m.dataset_id != nil {
  1838. fields = append(fields, agentbase.FieldDatasetID)
  1839. }
  1840. if m.collection_id != nil {
  1841. fields = append(fields, agentbase.FieldCollectionID)
  1842. }
  1843. if m.source_name != nil {
  1844. fields = append(fields, agentbase.FieldSourceName)
  1845. }
  1846. if m.can_write != nil {
  1847. fields = append(fields, agentbase.FieldCanWrite)
  1848. }
  1849. if m.is_owner != nil {
  1850. fields = append(fields, agentbase.FieldIsOwner)
  1851. }
  1852. return fields
  1853. }
  1854. // Field returns the value of a field with the given name. The second boolean
  1855. // return value indicates that this field was not set, or was not defined in the
  1856. // schema.
  1857. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1858. switch name {
  1859. case agentbase.FieldQ:
  1860. return m.Q()
  1861. case agentbase.FieldA:
  1862. return m.A()
  1863. case agentbase.FieldChunkIndex:
  1864. return m.ChunkIndex()
  1865. case agentbase.FieldIndexes:
  1866. return m.Indexes()
  1867. case agentbase.FieldDatasetID:
  1868. return m.DatasetID()
  1869. case agentbase.FieldCollectionID:
  1870. return m.CollectionID()
  1871. case agentbase.FieldSourceName:
  1872. return m.SourceName()
  1873. case agentbase.FieldCanWrite:
  1874. return m.CanWrite()
  1875. case agentbase.FieldIsOwner:
  1876. return m.IsOwner()
  1877. }
  1878. return nil, false
  1879. }
  1880. // OldField returns the old value of the field from the database. An error is
  1881. // returned if the mutation operation is not UpdateOne, or the query to the
  1882. // database failed.
  1883. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1884. switch name {
  1885. case agentbase.FieldQ:
  1886. return m.OldQ(ctx)
  1887. case agentbase.FieldA:
  1888. return m.OldA(ctx)
  1889. case agentbase.FieldChunkIndex:
  1890. return m.OldChunkIndex(ctx)
  1891. case agentbase.FieldIndexes:
  1892. return m.OldIndexes(ctx)
  1893. case agentbase.FieldDatasetID:
  1894. return m.OldDatasetID(ctx)
  1895. case agentbase.FieldCollectionID:
  1896. return m.OldCollectionID(ctx)
  1897. case agentbase.FieldSourceName:
  1898. return m.OldSourceName(ctx)
  1899. case agentbase.FieldCanWrite:
  1900. return m.OldCanWrite(ctx)
  1901. case agentbase.FieldIsOwner:
  1902. return m.OldIsOwner(ctx)
  1903. }
  1904. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1905. }
  1906. // SetField sets the value of a field with the given name. It returns an error if
  1907. // the field is not defined in the schema, or if the type mismatched the field
  1908. // type.
  1909. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1910. switch name {
  1911. case agentbase.FieldQ:
  1912. v, ok := value.(string)
  1913. if !ok {
  1914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1915. }
  1916. m.SetQ(v)
  1917. return nil
  1918. case agentbase.FieldA:
  1919. v, ok := value.(string)
  1920. if !ok {
  1921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1922. }
  1923. m.SetA(v)
  1924. return nil
  1925. case agentbase.FieldChunkIndex:
  1926. v, ok := value.(uint64)
  1927. if !ok {
  1928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1929. }
  1930. m.SetChunkIndex(v)
  1931. return nil
  1932. case agentbase.FieldIndexes:
  1933. v, ok := value.([]string)
  1934. if !ok {
  1935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1936. }
  1937. m.SetIndexes(v)
  1938. return nil
  1939. case agentbase.FieldDatasetID:
  1940. v, ok := value.(string)
  1941. if !ok {
  1942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1943. }
  1944. m.SetDatasetID(v)
  1945. return nil
  1946. case agentbase.FieldCollectionID:
  1947. v, ok := value.(string)
  1948. if !ok {
  1949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1950. }
  1951. m.SetCollectionID(v)
  1952. return nil
  1953. case agentbase.FieldSourceName:
  1954. v, ok := value.(string)
  1955. if !ok {
  1956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1957. }
  1958. m.SetSourceName(v)
  1959. return nil
  1960. case agentbase.FieldCanWrite:
  1961. v, ok := value.([]bool)
  1962. if !ok {
  1963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1964. }
  1965. m.SetCanWrite(v)
  1966. return nil
  1967. case agentbase.FieldIsOwner:
  1968. v, ok := value.([]bool)
  1969. if !ok {
  1970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1971. }
  1972. m.SetIsOwner(v)
  1973. return nil
  1974. }
  1975. return fmt.Errorf("unknown AgentBase field %s", name)
  1976. }
  1977. // AddedFields returns all numeric fields that were incremented/decremented during
  1978. // this mutation.
  1979. func (m *AgentBaseMutation) AddedFields() []string {
  1980. var fields []string
  1981. if m.addchunk_index != nil {
  1982. fields = append(fields, agentbase.FieldChunkIndex)
  1983. }
  1984. return fields
  1985. }
  1986. // AddedField returns the numeric value that was incremented/decremented on a field
  1987. // with the given name. The second boolean return value indicates that this field
  1988. // was not set, or was not defined in the schema.
  1989. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1990. switch name {
  1991. case agentbase.FieldChunkIndex:
  1992. return m.AddedChunkIndex()
  1993. }
  1994. return nil, false
  1995. }
  1996. // AddField adds the value to the field with the given name. It returns an error if
  1997. // the field is not defined in the schema, or if the type mismatched the field
  1998. // type.
  1999. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2000. switch name {
  2001. case agentbase.FieldChunkIndex:
  2002. v, ok := value.(int64)
  2003. if !ok {
  2004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2005. }
  2006. m.AddChunkIndex(v)
  2007. return nil
  2008. }
  2009. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2010. }
  2011. // ClearedFields returns all nullable fields that were cleared during this
  2012. // mutation.
  2013. func (m *AgentBaseMutation) ClearedFields() []string {
  2014. var fields []string
  2015. if m.FieldCleared(agentbase.FieldQ) {
  2016. fields = append(fields, agentbase.FieldQ)
  2017. }
  2018. if m.FieldCleared(agentbase.FieldA) {
  2019. fields = append(fields, agentbase.FieldA)
  2020. }
  2021. if m.FieldCleared(agentbase.FieldIndexes) {
  2022. fields = append(fields, agentbase.FieldIndexes)
  2023. }
  2024. if m.FieldCleared(agentbase.FieldDatasetID) {
  2025. fields = append(fields, agentbase.FieldDatasetID)
  2026. }
  2027. if m.FieldCleared(agentbase.FieldCollectionID) {
  2028. fields = append(fields, agentbase.FieldCollectionID)
  2029. }
  2030. if m.FieldCleared(agentbase.FieldSourceName) {
  2031. fields = append(fields, agentbase.FieldSourceName)
  2032. }
  2033. if m.FieldCleared(agentbase.FieldCanWrite) {
  2034. fields = append(fields, agentbase.FieldCanWrite)
  2035. }
  2036. if m.FieldCleared(agentbase.FieldIsOwner) {
  2037. fields = append(fields, agentbase.FieldIsOwner)
  2038. }
  2039. return fields
  2040. }
  2041. // FieldCleared returns a boolean indicating if a field with the given name was
  2042. // cleared in this mutation.
  2043. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2044. _, ok := m.clearedFields[name]
  2045. return ok
  2046. }
  2047. // ClearField clears the value of the field with the given name. It returns an
  2048. // error if the field is not defined in the schema.
  2049. func (m *AgentBaseMutation) ClearField(name string) error {
  2050. switch name {
  2051. case agentbase.FieldQ:
  2052. m.ClearQ()
  2053. return nil
  2054. case agentbase.FieldA:
  2055. m.ClearA()
  2056. return nil
  2057. case agentbase.FieldIndexes:
  2058. m.ClearIndexes()
  2059. return nil
  2060. case agentbase.FieldDatasetID:
  2061. m.ClearDatasetID()
  2062. return nil
  2063. case agentbase.FieldCollectionID:
  2064. m.ClearCollectionID()
  2065. return nil
  2066. case agentbase.FieldSourceName:
  2067. m.ClearSourceName()
  2068. return nil
  2069. case agentbase.FieldCanWrite:
  2070. m.ClearCanWrite()
  2071. return nil
  2072. case agentbase.FieldIsOwner:
  2073. m.ClearIsOwner()
  2074. return nil
  2075. }
  2076. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2077. }
  2078. // ResetField resets all changes in the mutation for the field with the given name.
  2079. // It returns an error if the field is not defined in the schema.
  2080. func (m *AgentBaseMutation) ResetField(name string) error {
  2081. switch name {
  2082. case agentbase.FieldQ:
  2083. m.ResetQ()
  2084. return nil
  2085. case agentbase.FieldA:
  2086. m.ResetA()
  2087. return nil
  2088. case agentbase.FieldChunkIndex:
  2089. m.ResetChunkIndex()
  2090. return nil
  2091. case agentbase.FieldIndexes:
  2092. m.ResetIndexes()
  2093. return nil
  2094. case agentbase.FieldDatasetID:
  2095. m.ResetDatasetID()
  2096. return nil
  2097. case agentbase.FieldCollectionID:
  2098. m.ResetCollectionID()
  2099. return nil
  2100. case agentbase.FieldSourceName:
  2101. m.ResetSourceName()
  2102. return nil
  2103. case agentbase.FieldCanWrite:
  2104. m.ResetCanWrite()
  2105. return nil
  2106. case agentbase.FieldIsOwner:
  2107. m.ResetIsOwner()
  2108. return nil
  2109. }
  2110. return fmt.Errorf("unknown AgentBase field %s", name)
  2111. }
  2112. // AddedEdges returns all edge names that were set/added in this mutation.
  2113. func (m *AgentBaseMutation) AddedEdges() []string {
  2114. edges := make([]string, 0, 1)
  2115. if m.wx_agent != nil {
  2116. edges = append(edges, agentbase.EdgeWxAgent)
  2117. }
  2118. return edges
  2119. }
  2120. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2121. // name in this mutation.
  2122. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2123. switch name {
  2124. case agentbase.EdgeWxAgent:
  2125. ids := make([]ent.Value, 0, len(m.wx_agent))
  2126. for id := range m.wx_agent {
  2127. ids = append(ids, id)
  2128. }
  2129. return ids
  2130. }
  2131. return nil
  2132. }
  2133. // RemovedEdges returns all edge names that were removed in this mutation.
  2134. func (m *AgentBaseMutation) RemovedEdges() []string {
  2135. edges := make([]string, 0, 1)
  2136. if m.removedwx_agent != nil {
  2137. edges = append(edges, agentbase.EdgeWxAgent)
  2138. }
  2139. return edges
  2140. }
  2141. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2142. // the given name in this mutation.
  2143. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2144. switch name {
  2145. case agentbase.EdgeWxAgent:
  2146. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2147. for id := range m.removedwx_agent {
  2148. ids = append(ids, id)
  2149. }
  2150. return ids
  2151. }
  2152. return nil
  2153. }
  2154. // ClearedEdges returns all edge names that were cleared in this mutation.
  2155. func (m *AgentBaseMutation) ClearedEdges() []string {
  2156. edges := make([]string, 0, 1)
  2157. if m.clearedwx_agent {
  2158. edges = append(edges, agentbase.EdgeWxAgent)
  2159. }
  2160. return edges
  2161. }
  2162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2163. // was cleared in this mutation.
  2164. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2165. switch name {
  2166. case agentbase.EdgeWxAgent:
  2167. return m.clearedwx_agent
  2168. }
  2169. return false
  2170. }
  2171. // ClearEdge clears the value of the edge with the given name. It returns an error
  2172. // if that edge is not defined in the schema.
  2173. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2174. switch name {
  2175. }
  2176. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2177. }
  2178. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2179. // It returns an error if the edge is not defined in the schema.
  2180. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2181. switch name {
  2182. case agentbase.EdgeWxAgent:
  2183. m.ResetWxAgent()
  2184. return nil
  2185. }
  2186. return fmt.Errorf("unknown AgentBase edge %s", name)
  2187. }
  2188. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2189. type AliyunAvatarMutation struct {
  2190. config
  2191. op Op
  2192. typ string
  2193. id *uint64
  2194. created_at *time.Time
  2195. updated_at *time.Time
  2196. deleted_at *time.Time
  2197. user_id *uint64
  2198. adduser_id *int64
  2199. biz_id *string
  2200. access_key_id *string
  2201. access_key_secret *string
  2202. app_id *string
  2203. tenant_id *uint64
  2204. addtenant_id *int64
  2205. response *string
  2206. token *string
  2207. session_id *string
  2208. clearedFields map[string]struct{}
  2209. done bool
  2210. oldValue func(context.Context) (*AliyunAvatar, error)
  2211. predicates []predicate.AliyunAvatar
  2212. }
  2213. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2214. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2215. type aliyunavatarOption func(*AliyunAvatarMutation)
  2216. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2217. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2218. m := &AliyunAvatarMutation{
  2219. config: c,
  2220. op: op,
  2221. typ: TypeAliyunAvatar,
  2222. clearedFields: make(map[string]struct{}),
  2223. }
  2224. for _, opt := range opts {
  2225. opt(m)
  2226. }
  2227. return m
  2228. }
  2229. // withAliyunAvatarID sets the ID field of the mutation.
  2230. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2231. return func(m *AliyunAvatarMutation) {
  2232. var (
  2233. err error
  2234. once sync.Once
  2235. value *AliyunAvatar
  2236. )
  2237. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2238. once.Do(func() {
  2239. if m.done {
  2240. err = errors.New("querying old values post mutation is not allowed")
  2241. } else {
  2242. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2243. }
  2244. })
  2245. return value, err
  2246. }
  2247. m.id = &id
  2248. }
  2249. }
  2250. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2251. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2252. return func(m *AliyunAvatarMutation) {
  2253. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2254. return node, nil
  2255. }
  2256. m.id = &node.ID
  2257. }
  2258. }
  2259. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2260. // executed in a transaction (ent.Tx), a transactional client is returned.
  2261. func (m AliyunAvatarMutation) Client() *Client {
  2262. client := &Client{config: m.config}
  2263. client.init()
  2264. return client
  2265. }
  2266. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2267. // it returns an error otherwise.
  2268. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2269. if _, ok := m.driver.(*txDriver); !ok {
  2270. return nil, errors.New("ent: mutation is not running in a transaction")
  2271. }
  2272. tx := &Tx{config: m.config}
  2273. tx.init()
  2274. return tx, nil
  2275. }
  2276. // SetID sets the value of the id field. Note that this
  2277. // operation is only accepted on creation of AliyunAvatar entities.
  2278. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2279. m.id = &id
  2280. }
  2281. // ID returns the ID value in the mutation. Note that the ID is only available
  2282. // if it was provided to the builder or after it was returned from the database.
  2283. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2284. if m.id == nil {
  2285. return
  2286. }
  2287. return *m.id, true
  2288. }
  2289. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2290. // That means, if the mutation is applied within a transaction with an isolation level such
  2291. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2292. // or updated by the mutation.
  2293. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2294. switch {
  2295. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2296. id, exists := m.ID()
  2297. if exists {
  2298. return []uint64{id}, nil
  2299. }
  2300. fallthrough
  2301. case m.op.Is(OpUpdate | OpDelete):
  2302. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2303. default:
  2304. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2305. }
  2306. }
  2307. // SetCreatedAt sets the "created_at" field.
  2308. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2309. m.created_at = &t
  2310. }
  2311. // CreatedAt returns the value of the "created_at" field in the mutation.
  2312. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2313. v := m.created_at
  2314. if v == nil {
  2315. return
  2316. }
  2317. return *v, true
  2318. }
  2319. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2320. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2322. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2323. if !m.op.Is(OpUpdateOne) {
  2324. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2325. }
  2326. if m.id == nil || m.oldValue == nil {
  2327. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2328. }
  2329. oldValue, err := m.oldValue(ctx)
  2330. if err != nil {
  2331. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2332. }
  2333. return oldValue.CreatedAt, nil
  2334. }
  2335. // ResetCreatedAt resets all changes to the "created_at" field.
  2336. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2337. m.created_at = nil
  2338. }
  2339. // SetUpdatedAt sets the "updated_at" field.
  2340. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2341. m.updated_at = &t
  2342. }
  2343. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2344. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2345. v := m.updated_at
  2346. if v == nil {
  2347. return
  2348. }
  2349. return *v, true
  2350. }
  2351. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2352. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2354. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2355. if !m.op.Is(OpUpdateOne) {
  2356. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2357. }
  2358. if m.id == nil || m.oldValue == nil {
  2359. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2360. }
  2361. oldValue, err := m.oldValue(ctx)
  2362. if err != nil {
  2363. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2364. }
  2365. return oldValue.UpdatedAt, nil
  2366. }
  2367. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2368. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2369. m.updated_at = nil
  2370. }
  2371. // SetDeletedAt sets the "deleted_at" field.
  2372. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2373. m.deleted_at = &t
  2374. }
  2375. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2376. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2377. v := m.deleted_at
  2378. if v == nil {
  2379. return
  2380. }
  2381. return *v, true
  2382. }
  2383. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2384. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2386. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2387. if !m.op.Is(OpUpdateOne) {
  2388. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2389. }
  2390. if m.id == nil || m.oldValue == nil {
  2391. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2392. }
  2393. oldValue, err := m.oldValue(ctx)
  2394. if err != nil {
  2395. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2396. }
  2397. return oldValue.DeletedAt, nil
  2398. }
  2399. // ClearDeletedAt clears the value of the "deleted_at" field.
  2400. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2401. m.deleted_at = nil
  2402. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2403. }
  2404. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2405. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2406. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2407. return ok
  2408. }
  2409. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2410. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2411. m.deleted_at = nil
  2412. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2413. }
  2414. // SetUserID sets the "user_id" field.
  2415. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2416. m.user_id = &u
  2417. m.adduser_id = nil
  2418. }
  2419. // UserID returns the value of the "user_id" field in the mutation.
  2420. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2421. v := m.user_id
  2422. if v == nil {
  2423. return
  2424. }
  2425. return *v, true
  2426. }
  2427. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2428. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2430. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2431. if !m.op.Is(OpUpdateOne) {
  2432. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2433. }
  2434. if m.id == nil || m.oldValue == nil {
  2435. return v, errors.New("OldUserID requires an ID field in the mutation")
  2436. }
  2437. oldValue, err := m.oldValue(ctx)
  2438. if err != nil {
  2439. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2440. }
  2441. return oldValue.UserID, nil
  2442. }
  2443. // AddUserID adds u to the "user_id" field.
  2444. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2445. if m.adduser_id != nil {
  2446. *m.adduser_id += u
  2447. } else {
  2448. m.adduser_id = &u
  2449. }
  2450. }
  2451. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2452. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2453. v := m.adduser_id
  2454. if v == nil {
  2455. return
  2456. }
  2457. return *v, true
  2458. }
  2459. // ResetUserID resets all changes to the "user_id" field.
  2460. func (m *AliyunAvatarMutation) ResetUserID() {
  2461. m.user_id = nil
  2462. m.adduser_id = nil
  2463. }
  2464. // SetBizID sets the "biz_id" field.
  2465. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2466. m.biz_id = &s
  2467. }
  2468. // BizID returns the value of the "biz_id" field in the mutation.
  2469. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2470. v := m.biz_id
  2471. if v == nil {
  2472. return
  2473. }
  2474. return *v, true
  2475. }
  2476. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2477. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2479. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2480. if !m.op.Is(OpUpdateOne) {
  2481. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2482. }
  2483. if m.id == nil || m.oldValue == nil {
  2484. return v, errors.New("OldBizID requires an ID field in the mutation")
  2485. }
  2486. oldValue, err := m.oldValue(ctx)
  2487. if err != nil {
  2488. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2489. }
  2490. return oldValue.BizID, nil
  2491. }
  2492. // ResetBizID resets all changes to the "biz_id" field.
  2493. func (m *AliyunAvatarMutation) ResetBizID() {
  2494. m.biz_id = nil
  2495. }
  2496. // SetAccessKeyID sets the "access_key_id" field.
  2497. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2498. m.access_key_id = &s
  2499. }
  2500. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2501. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2502. v := m.access_key_id
  2503. if v == nil {
  2504. return
  2505. }
  2506. return *v, true
  2507. }
  2508. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2509. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2511. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2512. if !m.op.Is(OpUpdateOne) {
  2513. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2514. }
  2515. if m.id == nil || m.oldValue == nil {
  2516. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2517. }
  2518. oldValue, err := m.oldValue(ctx)
  2519. if err != nil {
  2520. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2521. }
  2522. return oldValue.AccessKeyID, nil
  2523. }
  2524. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2525. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2526. m.access_key_id = nil
  2527. }
  2528. // SetAccessKeySecret sets the "access_key_secret" field.
  2529. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2530. m.access_key_secret = &s
  2531. }
  2532. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2533. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2534. v := m.access_key_secret
  2535. if v == nil {
  2536. return
  2537. }
  2538. return *v, true
  2539. }
  2540. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2541. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2543. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2544. if !m.op.Is(OpUpdateOne) {
  2545. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2546. }
  2547. if m.id == nil || m.oldValue == nil {
  2548. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2549. }
  2550. oldValue, err := m.oldValue(ctx)
  2551. if err != nil {
  2552. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2553. }
  2554. return oldValue.AccessKeySecret, nil
  2555. }
  2556. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2557. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2558. m.access_key_secret = nil
  2559. }
  2560. // SetAppID sets the "app_id" field.
  2561. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2562. m.app_id = &s
  2563. }
  2564. // AppID returns the value of the "app_id" field in the mutation.
  2565. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2566. v := m.app_id
  2567. if v == nil {
  2568. return
  2569. }
  2570. return *v, true
  2571. }
  2572. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2573. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2575. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2576. if !m.op.Is(OpUpdateOne) {
  2577. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2578. }
  2579. if m.id == nil || m.oldValue == nil {
  2580. return v, errors.New("OldAppID requires an ID field in the mutation")
  2581. }
  2582. oldValue, err := m.oldValue(ctx)
  2583. if err != nil {
  2584. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2585. }
  2586. return oldValue.AppID, nil
  2587. }
  2588. // ClearAppID clears the value of the "app_id" field.
  2589. func (m *AliyunAvatarMutation) ClearAppID() {
  2590. m.app_id = nil
  2591. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2592. }
  2593. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2594. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2595. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2596. return ok
  2597. }
  2598. // ResetAppID resets all changes to the "app_id" field.
  2599. func (m *AliyunAvatarMutation) ResetAppID() {
  2600. m.app_id = nil
  2601. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2602. }
  2603. // SetTenantID sets the "tenant_id" field.
  2604. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2605. m.tenant_id = &u
  2606. m.addtenant_id = nil
  2607. }
  2608. // TenantID returns the value of the "tenant_id" field in the mutation.
  2609. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2610. v := m.tenant_id
  2611. if v == nil {
  2612. return
  2613. }
  2614. return *v, true
  2615. }
  2616. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2617. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2619. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2620. if !m.op.Is(OpUpdateOne) {
  2621. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2622. }
  2623. if m.id == nil || m.oldValue == nil {
  2624. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2625. }
  2626. oldValue, err := m.oldValue(ctx)
  2627. if err != nil {
  2628. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2629. }
  2630. return oldValue.TenantID, nil
  2631. }
  2632. // AddTenantID adds u to the "tenant_id" field.
  2633. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2634. if m.addtenant_id != nil {
  2635. *m.addtenant_id += u
  2636. } else {
  2637. m.addtenant_id = &u
  2638. }
  2639. }
  2640. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2641. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2642. v := m.addtenant_id
  2643. if v == nil {
  2644. return
  2645. }
  2646. return *v, true
  2647. }
  2648. // ResetTenantID resets all changes to the "tenant_id" field.
  2649. func (m *AliyunAvatarMutation) ResetTenantID() {
  2650. m.tenant_id = nil
  2651. m.addtenant_id = nil
  2652. }
  2653. // SetResponse sets the "response" field.
  2654. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2655. m.response = &s
  2656. }
  2657. // Response returns the value of the "response" field in the mutation.
  2658. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2659. v := m.response
  2660. if v == nil {
  2661. return
  2662. }
  2663. return *v, true
  2664. }
  2665. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2666. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2668. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2669. if !m.op.Is(OpUpdateOne) {
  2670. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2671. }
  2672. if m.id == nil || m.oldValue == nil {
  2673. return v, errors.New("OldResponse requires an ID field in the mutation")
  2674. }
  2675. oldValue, err := m.oldValue(ctx)
  2676. if err != nil {
  2677. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2678. }
  2679. return oldValue.Response, nil
  2680. }
  2681. // ResetResponse resets all changes to the "response" field.
  2682. func (m *AliyunAvatarMutation) ResetResponse() {
  2683. m.response = nil
  2684. }
  2685. // SetToken sets the "token" field.
  2686. func (m *AliyunAvatarMutation) SetToken(s string) {
  2687. m.token = &s
  2688. }
  2689. // Token returns the value of the "token" field in the mutation.
  2690. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2691. v := m.token
  2692. if v == nil {
  2693. return
  2694. }
  2695. return *v, true
  2696. }
  2697. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2698. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2700. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2701. if !m.op.Is(OpUpdateOne) {
  2702. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2703. }
  2704. if m.id == nil || m.oldValue == nil {
  2705. return v, errors.New("OldToken requires an ID field in the mutation")
  2706. }
  2707. oldValue, err := m.oldValue(ctx)
  2708. if err != nil {
  2709. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2710. }
  2711. return oldValue.Token, nil
  2712. }
  2713. // ResetToken resets all changes to the "token" field.
  2714. func (m *AliyunAvatarMutation) ResetToken() {
  2715. m.token = nil
  2716. }
  2717. // SetSessionID sets the "session_id" field.
  2718. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2719. m.session_id = &s
  2720. }
  2721. // SessionID returns the value of the "session_id" field in the mutation.
  2722. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2723. v := m.session_id
  2724. if v == nil {
  2725. return
  2726. }
  2727. return *v, true
  2728. }
  2729. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2730. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2732. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2733. if !m.op.Is(OpUpdateOne) {
  2734. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2735. }
  2736. if m.id == nil || m.oldValue == nil {
  2737. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2738. }
  2739. oldValue, err := m.oldValue(ctx)
  2740. if err != nil {
  2741. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2742. }
  2743. return oldValue.SessionID, nil
  2744. }
  2745. // ResetSessionID resets all changes to the "session_id" field.
  2746. func (m *AliyunAvatarMutation) ResetSessionID() {
  2747. m.session_id = nil
  2748. }
  2749. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2750. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2751. m.predicates = append(m.predicates, ps...)
  2752. }
  2753. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2754. // users can use type-assertion to append predicates that do not depend on any generated package.
  2755. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2756. p := make([]predicate.AliyunAvatar, len(ps))
  2757. for i := range ps {
  2758. p[i] = ps[i]
  2759. }
  2760. m.Where(p...)
  2761. }
  2762. // Op returns the operation name.
  2763. func (m *AliyunAvatarMutation) Op() Op {
  2764. return m.op
  2765. }
  2766. // SetOp allows setting the mutation operation.
  2767. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2768. m.op = op
  2769. }
  2770. // Type returns the node type of this mutation (AliyunAvatar).
  2771. func (m *AliyunAvatarMutation) Type() string {
  2772. return m.typ
  2773. }
  2774. // Fields returns all fields that were changed during this mutation. Note that in
  2775. // order to get all numeric fields that were incremented/decremented, call
  2776. // AddedFields().
  2777. func (m *AliyunAvatarMutation) Fields() []string {
  2778. fields := make([]string, 0, 12)
  2779. if m.created_at != nil {
  2780. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2781. }
  2782. if m.updated_at != nil {
  2783. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2784. }
  2785. if m.deleted_at != nil {
  2786. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2787. }
  2788. if m.user_id != nil {
  2789. fields = append(fields, aliyunavatar.FieldUserID)
  2790. }
  2791. if m.biz_id != nil {
  2792. fields = append(fields, aliyunavatar.FieldBizID)
  2793. }
  2794. if m.access_key_id != nil {
  2795. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2796. }
  2797. if m.access_key_secret != nil {
  2798. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2799. }
  2800. if m.app_id != nil {
  2801. fields = append(fields, aliyunavatar.FieldAppID)
  2802. }
  2803. if m.tenant_id != nil {
  2804. fields = append(fields, aliyunavatar.FieldTenantID)
  2805. }
  2806. if m.response != nil {
  2807. fields = append(fields, aliyunavatar.FieldResponse)
  2808. }
  2809. if m.token != nil {
  2810. fields = append(fields, aliyunavatar.FieldToken)
  2811. }
  2812. if m.session_id != nil {
  2813. fields = append(fields, aliyunavatar.FieldSessionID)
  2814. }
  2815. return fields
  2816. }
  2817. // Field returns the value of a field with the given name. The second boolean
  2818. // return value indicates that this field was not set, or was not defined in the
  2819. // schema.
  2820. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2821. switch name {
  2822. case aliyunavatar.FieldCreatedAt:
  2823. return m.CreatedAt()
  2824. case aliyunavatar.FieldUpdatedAt:
  2825. return m.UpdatedAt()
  2826. case aliyunavatar.FieldDeletedAt:
  2827. return m.DeletedAt()
  2828. case aliyunavatar.FieldUserID:
  2829. return m.UserID()
  2830. case aliyunavatar.FieldBizID:
  2831. return m.BizID()
  2832. case aliyunavatar.FieldAccessKeyID:
  2833. return m.AccessKeyID()
  2834. case aliyunavatar.FieldAccessKeySecret:
  2835. return m.AccessKeySecret()
  2836. case aliyunavatar.FieldAppID:
  2837. return m.AppID()
  2838. case aliyunavatar.FieldTenantID:
  2839. return m.TenantID()
  2840. case aliyunavatar.FieldResponse:
  2841. return m.Response()
  2842. case aliyunavatar.FieldToken:
  2843. return m.Token()
  2844. case aliyunavatar.FieldSessionID:
  2845. return m.SessionID()
  2846. }
  2847. return nil, false
  2848. }
  2849. // OldField returns the old value of the field from the database. An error is
  2850. // returned if the mutation operation is not UpdateOne, or the query to the
  2851. // database failed.
  2852. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2853. switch name {
  2854. case aliyunavatar.FieldCreatedAt:
  2855. return m.OldCreatedAt(ctx)
  2856. case aliyunavatar.FieldUpdatedAt:
  2857. return m.OldUpdatedAt(ctx)
  2858. case aliyunavatar.FieldDeletedAt:
  2859. return m.OldDeletedAt(ctx)
  2860. case aliyunavatar.FieldUserID:
  2861. return m.OldUserID(ctx)
  2862. case aliyunavatar.FieldBizID:
  2863. return m.OldBizID(ctx)
  2864. case aliyunavatar.FieldAccessKeyID:
  2865. return m.OldAccessKeyID(ctx)
  2866. case aliyunavatar.FieldAccessKeySecret:
  2867. return m.OldAccessKeySecret(ctx)
  2868. case aliyunavatar.FieldAppID:
  2869. return m.OldAppID(ctx)
  2870. case aliyunavatar.FieldTenantID:
  2871. return m.OldTenantID(ctx)
  2872. case aliyunavatar.FieldResponse:
  2873. return m.OldResponse(ctx)
  2874. case aliyunavatar.FieldToken:
  2875. return m.OldToken(ctx)
  2876. case aliyunavatar.FieldSessionID:
  2877. return m.OldSessionID(ctx)
  2878. }
  2879. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2880. }
  2881. // SetField sets the value of a field with the given name. It returns an error if
  2882. // the field is not defined in the schema, or if the type mismatched the field
  2883. // type.
  2884. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2885. switch name {
  2886. case aliyunavatar.FieldCreatedAt:
  2887. v, ok := value.(time.Time)
  2888. if !ok {
  2889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2890. }
  2891. m.SetCreatedAt(v)
  2892. return nil
  2893. case aliyunavatar.FieldUpdatedAt:
  2894. v, ok := value.(time.Time)
  2895. if !ok {
  2896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2897. }
  2898. m.SetUpdatedAt(v)
  2899. return nil
  2900. case aliyunavatar.FieldDeletedAt:
  2901. v, ok := value.(time.Time)
  2902. if !ok {
  2903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2904. }
  2905. m.SetDeletedAt(v)
  2906. return nil
  2907. case aliyunavatar.FieldUserID:
  2908. v, ok := value.(uint64)
  2909. if !ok {
  2910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2911. }
  2912. m.SetUserID(v)
  2913. return nil
  2914. case aliyunavatar.FieldBizID:
  2915. v, ok := value.(string)
  2916. if !ok {
  2917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2918. }
  2919. m.SetBizID(v)
  2920. return nil
  2921. case aliyunavatar.FieldAccessKeyID:
  2922. v, ok := value.(string)
  2923. if !ok {
  2924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2925. }
  2926. m.SetAccessKeyID(v)
  2927. return nil
  2928. case aliyunavatar.FieldAccessKeySecret:
  2929. v, ok := value.(string)
  2930. if !ok {
  2931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2932. }
  2933. m.SetAccessKeySecret(v)
  2934. return nil
  2935. case aliyunavatar.FieldAppID:
  2936. v, ok := value.(string)
  2937. if !ok {
  2938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2939. }
  2940. m.SetAppID(v)
  2941. return nil
  2942. case aliyunavatar.FieldTenantID:
  2943. v, ok := value.(uint64)
  2944. if !ok {
  2945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2946. }
  2947. m.SetTenantID(v)
  2948. return nil
  2949. case aliyunavatar.FieldResponse:
  2950. v, ok := value.(string)
  2951. if !ok {
  2952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2953. }
  2954. m.SetResponse(v)
  2955. return nil
  2956. case aliyunavatar.FieldToken:
  2957. v, ok := value.(string)
  2958. if !ok {
  2959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2960. }
  2961. m.SetToken(v)
  2962. return nil
  2963. case aliyunavatar.FieldSessionID:
  2964. v, ok := value.(string)
  2965. if !ok {
  2966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2967. }
  2968. m.SetSessionID(v)
  2969. return nil
  2970. }
  2971. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2972. }
  2973. // AddedFields returns all numeric fields that were incremented/decremented during
  2974. // this mutation.
  2975. func (m *AliyunAvatarMutation) AddedFields() []string {
  2976. var fields []string
  2977. if m.adduser_id != nil {
  2978. fields = append(fields, aliyunavatar.FieldUserID)
  2979. }
  2980. if m.addtenant_id != nil {
  2981. fields = append(fields, aliyunavatar.FieldTenantID)
  2982. }
  2983. return fields
  2984. }
  2985. // AddedField returns the numeric value that was incremented/decremented on a field
  2986. // with the given name. The second boolean return value indicates that this field
  2987. // was not set, or was not defined in the schema.
  2988. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2989. switch name {
  2990. case aliyunavatar.FieldUserID:
  2991. return m.AddedUserID()
  2992. case aliyunavatar.FieldTenantID:
  2993. return m.AddedTenantID()
  2994. }
  2995. return nil, false
  2996. }
  2997. // AddField adds the value to the field with the given name. It returns an error if
  2998. // the field is not defined in the schema, or if the type mismatched the field
  2999. // type.
  3000. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3001. switch name {
  3002. case aliyunavatar.FieldUserID:
  3003. v, ok := value.(int64)
  3004. if !ok {
  3005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3006. }
  3007. m.AddUserID(v)
  3008. return nil
  3009. case aliyunavatar.FieldTenantID:
  3010. v, ok := value.(int64)
  3011. if !ok {
  3012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3013. }
  3014. m.AddTenantID(v)
  3015. return nil
  3016. }
  3017. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3018. }
  3019. // ClearedFields returns all nullable fields that were cleared during this
  3020. // mutation.
  3021. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3022. var fields []string
  3023. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3024. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3025. }
  3026. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3027. fields = append(fields, aliyunavatar.FieldAppID)
  3028. }
  3029. return fields
  3030. }
  3031. // FieldCleared returns a boolean indicating if a field with the given name was
  3032. // cleared in this mutation.
  3033. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3034. _, ok := m.clearedFields[name]
  3035. return ok
  3036. }
  3037. // ClearField clears the value of the field with the given name. It returns an
  3038. // error if the field is not defined in the schema.
  3039. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3040. switch name {
  3041. case aliyunavatar.FieldDeletedAt:
  3042. m.ClearDeletedAt()
  3043. return nil
  3044. case aliyunavatar.FieldAppID:
  3045. m.ClearAppID()
  3046. return nil
  3047. }
  3048. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3049. }
  3050. // ResetField resets all changes in the mutation for the field with the given name.
  3051. // It returns an error if the field is not defined in the schema.
  3052. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3053. switch name {
  3054. case aliyunavatar.FieldCreatedAt:
  3055. m.ResetCreatedAt()
  3056. return nil
  3057. case aliyunavatar.FieldUpdatedAt:
  3058. m.ResetUpdatedAt()
  3059. return nil
  3060. case aliyunavatar.FieldDeletedAt:
  3061. m.ResetDeletedAt()
  3062. return nil
  3063. case aliyunavatar.FieldUserID:
  3064. m.ResetUserID()
  3065. return nil
  3066. case aliyunavatar.FieldBizID:
  3067. m.ResetBizID()
  3068. return nil
  3069. case aliyunavatar.FieldAccessKeyID:
  3070. m.ResetAccessKeyID()
  3071. return nil
  3072. case aliyunavatar.FieldAccessKeySecret:
  3073. m.ResetAccessKeySecret()
  3074. return nil
  3075. case aliyunavatar.FieldAppID:
  3076. m.ResetAppID()
  3077. return nil
  3078. case aliyunavatar.FieldTenantID:
  3079. m.ResetTenantID()
  3080. return nil
  3081. case aliyunavatar.FieldResponse:
  3082. m.ResetResponse()
  3083. return nil
  3084. case aliyunavatar.FieldToken:
  3085. m.ResetToken()
  3086. return nil
  3087. case aliyunavatar.FieldSessionID:
  3088. m.ResetSessionID()
  3089. return nil
  3090. }
  3091. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3092. }
  3093. // AddedEdges returns all edge names that were set/added in this mutation.
  3094. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3095. edges := make([]string, 0, 0)
  3096. return edges
  3097. }
  3098. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3099. // name in this mutation.
  3100. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3101. return nil
  3102. }
  3103. // RemovedEdges returns all edge names that were removed in this mutation.
  3104. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3105. edges := make([]string, 0, 0)
  3106. return edges
  3107. }
  3108. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3109. // the given name in this mutation.
  3110. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3111. return nil
  3112. }
  3113. // ClearedEdges returns all edge names that were cleared in this mutation.
  3114. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3115. edges := make([]string, 0, 0)
  3116. return edges
  3117. }
  3118. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3119. // was cleared in this mutation.
  3120. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3121. return false
  3122. }
  3123. // ClearEdge clears the value of the edge with the given name. It returns an error
  3124. // if that edge is not defined in the schema.
  3125. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3126. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3127. }
  3128. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3129. // It returns an error if the edge is not defined in the schema.
  3130. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3131. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3132. }
  3133. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3134. type AllocAgentMutation struct {
  3135. config
  3136. op Op
  3137. typ string
  3138. id *uint64
  3139. created_at *time.Time
  3140. updated_at *time.Time
  3141. deleted_at *time.Time
  3142. user_id *string
  3143. organization_id *uint64
  3144. addorganization_id *int64
  3145. agents *[]uint64
  3146. appendagents []uint64
  3147. status *int
  3148. addstatus *int
  3149. clearedFields map[string]struct{}
  3150. done bool
  3151. oldValue func(context.Context) (*AllocAgent, error)
  3152. predicates []predicate.AllocAgent
  3153. }
  3154. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3155. // allocagentOption allows management of the mutation configuration using functional options.
  3156. type allocagentOption func(*AllocAgentMutation)
  3157. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3158. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3159. m := &AllocAgentMutation{
  3160. config: c,
  3161. op: op,
  3162. typ: TypeAllocAgent,
  3163. clearedFields: make(map[string]struct{}),
  3164. }
  3165. for _, opt := range opts {
  3166. opt(m)
  3167. }
  3168. return m
  3169. }
  3170. // withAllocAgentID sets the ID field of the mutation.
  3171. func withAllocAgentID(id uint64) allocagentOption {
  3172. return func(m *AllocAgentMutation) {
  3173. var (
  3174. err error
  3175. once sync.Once
  3176. value *AllocAgent
  3177. )
  3178. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3179. once.Do(func() {
  3180. if m.done {
  3181. err = errors.New("querying old values post mutation is not allowed")
  3182. } else {
  3183. value, err = m.Client().AllocAgent.Get(ctx, id)
  3184. }
  3185. })
  3186. return value, err
  3187. }
  3188. m.id = &id
  3189. }
  3190. }
  3191. // withAllocAgent sets the old AllocAgent of the mutation.
  3192. func withAllocAgent(node *AllocAgent) allocagentOption {
  3193. return func(m *AllocAgentMutation) {
  3194. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3195. return node, nil
  3196. }
  3197. m.id = &node.ID
  3198. }
  3199. }
  3200. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3201. // executed in a transaction (ent.Tx), a transactional client is returned.
  3202. func (m AllocAgentMutation) Client() *Client {
  3203. client := &Client{config: m.config}
  3204. client.init()
  3205. return client
  3206. }
  3207. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3208. // it returns an error otherwise.
  3209. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3210. if _, ok := m.driver.(*txDriver); !ok {
  3211. return nil, errors.New("ent: mutation is not running in a transaction")
  3212. }
  3213. tx := &Tx{config: m.config}
  3214. tx.init()
  3215. return tx, nil
  3216. }
  3217. // SetID sets the value of the id field. Note that this
  3218. // operation is only accepted on creation of AllocAgent entities.
  3219. func (m *AllocAgentMutation) SetID(id uint64) {
  3220. m.id = &id
  3221. }
  3222. // ID returns the ID value in the mutation. Note that the ID is only available
  3223. // if it was provided to the builder or after it was returned from the database.
  3224. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3225. if m.id == nil {
  3226. return
  3227. }
  3228. return *m.id, true
  3229. }
  3230. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3231. // That means, if the mutation is applied within a transaction with an isolation level such
  3232. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3233. // or updated by the mutation.
  3234. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3235. switch {
  3236. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3237. id, exists := m.ID()
  3238. if exists {
  3239. return []uint64{id}, nil
  3240. }
  3241. fallthrough
  3242. case m.op.Is(OpUpdate | OpDelete):
  3243. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3244. default:
  3245. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3246. }
  3247. }
  3248. // SetCreatedAt sets the "created_at" field.
  3249. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3250. m.created_at = &t
  3251. }
  3252. // CreatedAt returns the value of the "created_at" field in the mutation.
  3253. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3254. v := m.created_at
  3255. if v == nil {
  3256. return
  3257. }
  3258. return *v, true
  3259. }
  3260. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3261. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3263. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3264. if !m.op.Is(OpUpdateOne) {
  3265. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3266. }
  3267. if m.id == nil || m.oldValue == nil {
  3268. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3269. }
  3270. oldValue, err := m.oldValue(ctx)
  3271. if err != nil {
  3272. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3273. }
  3274. return oldValue.CreatedAt, nil
  3275. }
  3276. // ResetCreatedAt resets all changes to the "created_at" field.
  3277. func (m *AllocAgentMutation) ResetCreatedAt() {
  3278. m.created_at = nil
  3279. }
  3280. // SetUpdatedAt sets the "updated_at" field.
  3281. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3282. m.updated_at = &t
  3283. }
  3284. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3285. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3286. v := m.updated_at
  3287. if v == nil {
  3288. return
  3289. }
  3290. return *v, true
  3291. }
  3292. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3293. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3295. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3296. if !m.op.Is(OpUpdateOne) {
  3297. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3298. }
  3299. if m.id == nil || m.oldValue == nil {
  3300. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3301. }
  3302. oldValue, err := m.oldValue(ctx)
  3303. if err != nil {
  3304. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3305. }
  3306. return oldValue.UpdatedAt, nil
  3307. }
  3308. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3309. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3310. m.updated_at = nil
  3311. }
  3312. // SetDeletedAt sets the "deleted_at" field.
  3313. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3314. m.deleted_at = &t
  3315. }
  3316. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3317. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3318. v := m.deleted_at
  3319. if v == nil {
  3320. return
  3321. }
  3322. return *v, true
  3323. }
  3324. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3325. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3327. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3328. if !m.op.Is(OpUpdateOne) {
  3329. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3330. }
  3331. if m.id == nil || m.oldValue == nil {
  3332. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3333. }
  3334. oldValue, err := m.oldValue(ctx)
  3335. if err != nil {
  3336. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3337. }
  3338. return oldValue.DeletedAt, nil
  3339. }
  3340. // ClearDeletedAt clears the value of the "deleted_at" field.
  3341. func (m *AllocAgentMutation) ClearDeletedAt() {
  3342. m.deleted_at = nil
  3343. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3344. }
  3345. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3346. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3347. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3348. return ok
  3349. }
  3350. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3351. func (m *AllocAgentMutation) ResetDeletedAt() {
  3352. m.deleted_at = nil
  3353. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3354. }
  3355. // SetUserID sets the "user_id" field.
  3356. func (m *AllocAgentMutation) SetUserID(s string) {
  3357. m.user_id = &s
  3358. }
  3359. // UserID returns the value of the "user_id" field in the mutation.
  3360. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3361. v := m.user_id
  3362. if v == nil {
  3363. return
  3364. }
  3365. return *v, true
  3366. }
  3367. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3368. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3370. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3371. if !m.op.Is(OpUpdateOne) {
  3372. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3373. }
  3374. if m.id == nil || m.oldValue == nil {
  3375. return v, errors.New("OldUserID requires an ID field in the mutation")
  3376. }
  3377. oldValue, err := m.oldValue(ctx)
  3378. if err != nil {
  3379. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3380. }
  3381. return oldValue.UserID, nil
  3382. }
  3383. // ClearUserID clears the value of the "user_id" field.
  3384. func (m *AllocAgentMutation) ClearUserID() {
  3385. m.user_id = nil
  3386. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3387. }
  3388. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3389. func (m *AllocAgentMutation) UserIDCleared() bool {
  3390. _, ok := m.clearedFields[allocagent.FieldUserID]
  3391. return ok
  3392. }
  3393. // ResetUserID resets all changes to the "user_id" field.
  3394. func (m *AllocAgentMutation) ResetUserID() {
  3395. m.user_id = nil
  3396. delete(m.clearedFields, allocagent.FieldUserID)
  3397. }
  3398. // SetOrganizationID sets the "organization_id" field.
  3399. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3400. m.organization_id = &u
  3401. m.addorganization_id = nil
  3402. }
  3403. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3404. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3405. v := m.organization_id
  3406. if v == nil {
  3407. return
  3408. }
  3409. return *v, true
  3410. }
  3411. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3412. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3414. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3415. if !m.op.Is(OpUpdateOne) {
  3416. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3417. }
  3418. if m.id == nil || m.oldValue == nil {
  3419. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3420. }
  3421. oldValue, err := m.oldValue(ctx)
  3422. if err != nil {
  3423. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3424. }
  3425. return oldValue.OrganizationID, nil
  3426. }
  3427. // AddOrganizationID adds u to the "organization_id" field.
  3428. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3429. if m.addorganization_id != nil {
  3430. *m.addorganization_id += u
  3431. } else {
  3432. m.addorganization_id = &u
  3433. }
  3434. }
  3435. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3436. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3437. v := m.addorganization_id
  3438. if v == nil {
  3439. return
  3440. }
  3441. return *v, true
  3442. }
  3443. // ClearOrganizationID clears the value of the "organization_id" field.
  3444. func (m *AllocAgentMutation) ClearOrganizationID() {
  3445. m.organization_id = nil
  3446. m.addorganization_id = nil
  3447. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3448. }
  3449. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3450. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3451. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3452. return ok
  3453. }
  3454. // ResetOrganizationID resets all changes to the "organization_id" field.
  3455. func (m *AllocAgentMutation) ResetOrganizationID() {
  3456. m.organization_id = nil
  3457. m.addorganization_id = nil
  3458. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3459. }
  3460. // SetAgents sets the "agents" field.
  3461. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3462. m.agents = &u
  3463. m.appendagents = nil
  3464. }
  3465. // Agents returns the value of the "agents" field in the mutation.
  3466. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3467. v := m.agents
  3468. if v == nil {
  3469. return
  3470. }
  3471. return *v, true
  3472. }
  3473. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3474. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3476. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3477. if !m.op.Is(OpUpdateOne) {
  3478. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3479. }
  3480. if m.id == nil || m.oldValue == nil {
  3481. return v, errors.New("OldAgents requires an ID field in the mutation")
  3482. }
  3483. oldValue, err := m.oldValue(ctx)
  3484. if err != nil {
  3485. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3486. }
  3487. return oldValue.Agents, nil
  3488. }
  3489. // AppendAgents adds u to the "agents" field.
  3490. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3491. m.appendagents = append(m.appendagents, u...)
  3492. }
  3493. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3494. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3495. if len(m.appendagents) == 0 {
  3496. return nil, false
  3497. }
  3498. return m.appendagents, true
  3499. }
  3500. // ResetAgents resets all changes to the "agents" field.
  3501. func (m *AllocAgentMutation) ResetAgents() {
  3502. m.agents = nil
  3503. m.appendagents = nil
  3504. }
  3505. // SetStatus sets the "status" field.
  3506. func (m *AllocAgentMutation) SetStatus(i int) {
  3507. m.status = &i
  3508. m.addstatus = nil
  3509. }
  3510. // Status returns the value of the "status" field in the mutation.
  3511. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3512. v := m.status
  3513. if v == nil {
  3514. return
  3515. }
  3516. return *v, true
  3517. }
  3518. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3519. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3521. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3522. if !m.op.Is(OpUpdateOne) {
  3523. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3524. }
  3525. if m.id == nil || m.oldValue == nil {
  3526. return v, errors.New("OldStatus requires an ID field in the mutation")
  3527. }
  3528. oldValue, err := m.oldValue(ctx)
  3529. if err != nil {
  3530. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3531. }
  3532. return oldValue.Status, nil
  3533. }
  3534. // AddStatus adds i to the "status" field.
  3535. func (m *AllocAgentMutation) AddStatus(i int) {
  3536. if m.addstatus != nil {
  3537. *m.addstatus += i
  3538. } else {
  3539. m.addstatus = &i
  3540. }
  3541. }
  3542. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3543. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3544. v := m.addstatus
  3545. if v == nil {
  3546. return
  3547. }
  3548. return *v, true
  3549. }
  3550. // ClearStatus clears the value of the "status" field.
  3551. func (m *AllocAgentMutation) ClearStatus() {
  3552. m.status = nil
  3553. m.addstatus = nil
  3554. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3555. }
  3556. // StatusCleared returns if the "status" field was cleared in this mutation.
  3557. func (m *AllocAgentMutation) StatusCleared() bool {
  3558. _, ok := m.clearedFields[allocagent.FieldStatus]
  3559. return ok
  3560. }
  3561. // ResetStatus resets all changes to the "status" field.
  3562. func (m *AllocAgentMutation) ResetStatus() {
  3563. m.status = nil
  3564. m.addstatus = nil
  3565. delete(m.clearedFields, allocagent.FieldStatus)
  3566. }
  3567. // Where appends a list predicates to the AllocAgentMutation builder.
  3568. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3569. m.predicates = append(m.predicates, ps...)
  3570. }
  3571. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3572. // users can use type-assertion to append predicates that do not depend on any generated package.
  3573. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3574. p := make([]predicate.AllocAgent, len(ps))
  3575. for i := range ps {
  3576. p[i] = ps[i]
  3577. }
  3578. m.Where(p...)
  3579. }
  3580. // Op returns the operation name.
  3581. func (m *AllocAgentMutation) Op() Op {
  3582. return m.op
  3583. }
  3584. // SetOp allows setting the mutation operation.
  3585. func (m *AllocAgentMutation) SetOp(op Op) {
  3586. m.op = op
  3587. }
  3588. // Type returns the node type of this mutation (AllocAgent).
  3589. func (m *AllocAgentMutation) Type() string {
  3590. return m.typ
  3591. }
  3592. // Fields returns all fields that were changed during this mutation. Note that in
  3593. // order to get all numeric fields that were incremented/decremented, call
  3594. // AddedFields().
  3595. func (m *AllocAgentMutation) Fields() []string {
  3596. fields := make([]string, 0, 7)
  3597. if m.created_at != nil {
  3598. fields = append(fields, allocagent.FieldCreatedAt)
  3599. }
  3600. if m.updated_at != nil {
  3601. fields = append(fields, allocagent.FieldUpdatedAt)
  3602. }
  3603. if m.deleted_at != nil {
  3604. fields = append(fields, allocagent.FieldDeletedAt)
  3605. }
  3606. if m.user_id != nil {
  3607. fields = append(fields, allocagent.FieldUserID)
  3608. }
  3609. if m.organization_id != nil {
  3610. fields = append(fields, allocagent.FieldOrganizationID)
  3611. }
  3612. if m.agents != nil {
  3613. fields = append(fields, allocagent.FieldAgents)
  3614. }
  3615. if m.status != nil {
  3616. fields = append(fields, allocagent.FieldStatus)
  3617. }
  3618. return fields
  3619. }
  3620. // Field returns the value of a field with the given name. The second boolean
  3621. // return value indicates that this field was not set, or was not defined in the
  3622. // schema.
  3623. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3624. switch name {
  3625. case allocagent.FieldCreatedAt:
  3626. return m.CreatedAt()
  3627. case allocagent.FieldUpdatedAt:
  3628. return m.UpdatedAt()
  3629. case allocagent.FieldDeletedAt:
  3630. return m.DeletedAt()
  3631. case allocagent.FieldUserID:
  3632. return m.UserID()
  3633. case allocagent.FieldOrganizationID:
  3634. return m.OrganizationID()
  3635. case allocagent.FieldAgents:
  3636. return m.Agents()
  3637. case allocagent.FieldStatus:
  3638. return m.Status()
  3639. }
  3640. return nil, false
  3641. }
  3642. // OldField returns the old value of the field from the database. An error is
  3643. // returned if the mutation operation is not UpdateOne, or the query to the
  3644. // database failed.
  3645. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3646. switch name {
  3647. case allocagent.FieldCreatedAt:
  3648. return m.OldCreatedAt(ctx)
  3649. case allocagent.FieldUpdatedAt:
  3650. return m.OldUpdatedAt(ctx)
  3651. case allocagent.FieldDeletedAt:
  3652. return m.OldDeletedAt(ctx)
  3653. case allocagent.FieldUserID:
  3654. return m.OldUserID(ctx)
  3655. case allocagent.FieldOrganizationID:
  3656. return m.OldOrganizationID(ctx)
  3657. case allocagent.FieldAgents:
  3658. return m.OldAgents(ctx)
  3659. case allocagent.FieldStatus:
  3660. return m.OldStatus(ctx)
  3661. }
  3662. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3663. }
  3664. // SetField sets the value of a field with the given name. It returns an error if
  3665. // the field is not defined in the schema, or if the type mismatched the field
  3666. // type.
  3667. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3668. switch name {
  3669. case allocagent.FieldCreatedAt:
  3670. v, ok := value.(time.Time)
  3671. if !ok {
  3672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3673. }
  3674. m.SetCreatedAt(v)
  3675. return nil
  3676. case allocagent.FieldUpdatedAt:
  3677. v, ok := value.(time.Time)
  3678. if !ok {
  3679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3680. }
  3681. m.SetUpdatedAt(v)
  3682. return nil
  3683. case allocagent.FieldDeletedAt:
  3684. v, ok := value.(time.Time)
  3685. if !ok {
  3686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3687. }
  3688. m.SetDeletedAt(v)
  3689. return nil
  3690. case allocagent.FieldUserID:
  3691. v, ok := value.(string)
  3692. if !ok {
  3693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3694. }
  3695. m.SetUserID(v)
  3696. return nil
  3697. case allocagent.FieldOrganizationID:
  3698. v, ok := value.(uint64)
  3699. if !ok {
  3700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3701. }
  3702. m.SetOrganizationID(v)
  3703. return nil
  3704. case allocagent.FieldAgents:
  3705. v, ok := value.([]uint64)
  3706. if !ok {
  3707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3708. }
  3709. m.SetAgents(v)
  3710. return nil
  3711. case allocagent.FieldStatus:
  3712. v, ok := value.(int)
  3713. if !ok {
  3714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3715. }
  3716. m.SetStatus(v)
  3717. return nil
  3718. }
  3719. return fmt.Errorf("unknown AllocAgent field %s", name)
  3720. }
  3721. // AddedFields returns all numeric fields that were incremented/decremented during
  3722. // this mutation.
  3723. func (m *AllocAgentMutation) AddedFields() []string {
  3724. var fields []string
  3725. if m.addorganization_id != nil {
  3726. fields = append(fields, allocagent.FieldOrganizationID)
  3727. }
  3728. if m.addstatus != nil {
  3729. fields = append(fields, allocagent.FieldStatus)
  3730. }
  3731. return fields
  3732. }
  3733. // AddedField returns the numeric value that was incremented/decremented on a field
  3734. // with the given name. The second boolean return value indicates that this field
  3735. // was not set, or was not defined in the schema.
  3736. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3737. switch name {
  3738. case allocagent.FieldOrganizationID:
  3739. return m.AddedOrganizationID()
  3740. case allocagent.FieldStatus:
  3741. return m.AddedStatus()
  3742. }
  3743. return nil, false
  3744. }
  3745. // AddField adds the value to the field with the given name. It returns an error if
  3746. // the field is not defined in the schema, or if the type mismatched the field
  3747. // type.
  3748. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3749. switch name {
  3750. case allocagent.FieldOrganizationID:
  3751. v, ok := value.(int64)
  3752. if !ok {
  3753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3754. }
  3755. m.AddOrganizationID(v)
  3756. return nil
  3757. case allocagent.FieldStatus:
  3758. v, ok := value.(int)
  3759. if !ok {
  3760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3761. }
  3762. m.AddStatus(v)
  3763. return nil
  3764. }
  3765. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3766. }
  3767. // ClearedFields returns all nullable fields that were cleared during this
  3768. // mutation.
  3769. func (m *AllocAgentMutation) ClearedFields() []string {
  3770. var fields []string
  3771. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3772. fields = append(fields, allocagent.FieldDeletedAt)
  3773. }
  3774. if m.FieldCleared(allocagent.FieldUserID) {
  3775. fields = append(fields, allocagent.FieldUserID)
  3776. }
  3777. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3778. fields = append(fields, allocagent.FieldOrganizationID)
  3779. }
  3780. if m.FieldCleared(allocagent.FieldStatus) {
  3781. fields = append(fields, allocagent.FieldStatus)
  3782. }
  3783. return fields
  3784. }
  3785. // FieldCleared returns a boolean indicating if a field with the given name was
  3786. // cleared in this mutation.
  3787. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3788. _, ok := m.clearedFields[name]
  3789. return ok
  3790. }
  3791. // ClearField clears the value of the field with the given name. It returns an
  3792. // error if the field is not defined in the schema.
  3793. func (m *AllocAgentMutation) ClearField(name string) error {
  3794. switch name {
  3795. case allocagent.FieldDeletedAt:
  3796. m.ClearDeletedAt()
  3797. return nil
  3798. case allocagent.FieldUserID:
  3799. m.ClearUserID()
  3800. return nil
  3801. case allocagent.FieldOrganizationID:
  3802. m.ClearOrganizationID()
  3803. return nil
  3804. case allocagent.FieldStatus:
  3805. m.ClearStatus()
  3806. return nil
  3807. }
  3808. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3809. }
  3810. // ResetField resets all changes in the mutation for the field with the given name.
  3811. // It returns an error if the field is not defined in the schema.
  3812. func (m *AllocAgentMutation) ResetField(name string) error {
  3813. switch name {
  3814. case allocagent.FieldCreatedAt:
  3815. m.ResetCreatedAt()
  3816. return nil
  3817. case allocagent.FieldUpdatedAt:
  3818. m.ResetUpdatedAt()
  3819. return nil
  3820. case allocagent.FieldDeletedAt:
  3821. m.ResetDeletedAt()
  3822. return nil
  3823. case allocagent.FieldUserID:
  3824. m.ResetUserID()
  3825. return nil
  3826. case allocagent.FieldOrganizationID:
  3827. m.ResetOrganizationID()
  3828. return nil
  3829. case allocagent.FieldAgents:
  3830. m.ResetAgents()
  3831. return nil
  3832. case allocagent.FieldStatus:
  3833. m.ResetStatus()
  3834. return nil
  3835. }
  3836. return fmt.Errorf("unknown AllocAgent field %s", name)
  3837. }
  3838. // AddedEdges returns all edge names that were set/added in this mutation.
  3839. func (m *AllocAgentMutation) AddedEdges() []string {
  3840. edges := make([]string, 0, 0)
  3841. return edges
  3842. }
  3843. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3844. // name in this mutation.
  3845. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3846. return nil
  3847. }
  3848. // RemovedEdges returns all edge names that were removed in this mutation.
  3849. func (m *AllocAgentMutation) RemovedEdges() []string {
  3850. edges := make([]string, 0, 0)
  3851. return edges
  3852. }
  3853. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3854. // the given name in this mutation.
  3855. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3856. return nil
  3857. }
  3858. // ClearedEdges returns all edge names that were cleared in this mutation.
  3859. func (m *AllocAgentMutation) ClearedEdges() []string {
  3860. edges := make([]string, 0, 0)
  3861. return edges
  3862. }
  3863. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3864. // was cleared in this mutation.
  3865. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3866. return false
  3867. }
  3868. // ClearEdge clears the value of the edge with the given name. It returns an error
  3869. // if that edge is not defined in the schema.
  3870. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3871. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3872. }
  3873. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3874. // It returns an error if the edge is not defined in the schema.
  3875. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3876. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3877. }
  3878. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3879. type BatchMsgMutation struct {
  3880. config
  3881. op Op
  3882. typ string
  3883. id *uint64
  3884. created_at *time.Time
  3885. updated_at *time.Time
  3886. deleted_at *time.Time
  3887. status *uint8
  3888. addstatus *int8
  3889. batch_no *string
  3890. task_name *string
  3891. fromwxid *string
  3892. msg *string
  3893. tag *string
  3894. tagids *string
  3895. total *int32
  3896. addtotal *int32
  3897. success *int32
  3898. addsuccess *int32
  3899. fail *int32
  3900. addfail *int32
  3901. start_time *time.Time
  3902. stop_time *time.Time
  3903. send_time *time.Time
  3904. _type *int32
  3905. add_type *int32
  3906. organization_id *uint64
  3907. addorganization_id *int64
  3908. clearedFields map[string]struct{}
  3909. done bool
  3910. oldValue func(context.Context) (*BatchMsg, error)
  3911. predicates []predicate.BatchMsg
  3912. }
  3913. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3914. // batchmsgOption allows management of the mutation configuration using functional options.
  3915. type batchmsgOption func(*BatchMsgMutation)
  3916. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3917. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3918. m := &BatchMsgMutation{
  3919. config: c,
  3920. op: op,
  3921. typ: TypeBatchMsg,
  3922. clearedFields: make(map[string]struct{}),
  3923. }
  3924. for _, opt := range opts {
  3925. opt(m)
  3926. }
  3927. return m
  3928. }
  3929. // withBatchMsgID sets the ID field of the mutation.
  3930. func withBatchMsgID(id uint64) batchmsgOption {
  3931. return func(m *BatchMsgMutation) {
  3932. var (
  3933. err error
  3934. once sync.Once
  3935. value *BatchMsg
  3936. )
  3937. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3938. once.Do(func() {
  3939. if m.done {
  3940. err = errors.New("querying old values post mutation is not allowed")
  3941. } else {
  3942. value, err = m.Client().BatchMsg.Get(ctx, id)
  3943. }
  3944. })
  3945. return value, err
  3946. }
  3947. m.id = &id
  3948. }
  3949. }
  3950. // withBatchMsg sets the old BatchMsg of the mutation.
  3951. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3952. return func(m *BatchMsgMutation) {
  3953. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3954. return node, nil
  3955. }
  3956. m.id = &node.ID
  3957. }
  3958. }
  3959. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3960. // executed in a transaction (ent.Tx), a transactional client is returned.
  3961. func (m BatchMsgMutation) Client() *Client {
  3962. client := &Client{config: m.config}
  3963. client.init()
  3964. return client
  3965. }
  3966. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3967. // it returns an error otherwise.
  3968. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3969. if _, ok := m.driver.(*txDriver); !ok {
  3970. return nil, errors.New("ent: mutation is not running in a transaction")
  3971. }
  3972. tx := &Tx{config: m.config}
  3973. tx.init()
  3974. return tx, nil
  3975. }
  3976. // SetID sets the value of the id field. Note that this
  3977. // operation is only accepted on creation of BatchMsg entities.
  3978. func (m *BatchMsgMutation) SetID(id uint64) {
  3979. m.id = &id
  3980. }
  3981. // ID returns the ID value in the mutation. Note that the ID is only available
  3982. // if it was provided to the builder or after it was returned from the database.
  3983. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3984. if m.id == nil {
  3985. return
  3986. }
  3987. return *m.id, true
  3988. }
  3989. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3990. // That means, if the mutation is applied within a transaction with an isolation level such
  3991. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3992. // or updated by the mutation.
  3993. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3994. switch {
  3995. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3996. id, exists := m.ID()
  3997. if exists {
  3998. return []uint64{id}, nil
  3999. }
  4000. fallthrough
  4001. case m.op.Is(OpUpdate | OpDelete):
  4002. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4003. default:
  4004. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4005. }
  4006. }
  4007. // SetCreatedAt sets the "created_at" field.
  4008. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4009. m.created_at = &t
  4010. }
  4011. // CreatedAt returns the value of the "created_at" field in the mutation.
  4012. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4013. v := m.created_at
  4014. if v == nil {
  4015. return
  4016. }
  4017. return *v, true
  4018. }
  4019. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4020. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4022. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4023. if !m.op.Is(OpUpdateOne) {
  4024. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4025. }
  4026. if m.id == nil || m.oldValue == nil {
  4027. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4028. }
  4029. oldValue, err := m.oldValue(ctx)
  4030. if err != nil {
  4031. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4032. }
  4033. return oldValue.CreatedAt, nil
  4034. }
  4035. // ResetCreatedAt resets all changes to the "created_at" field.
  4036. func (m *BatchMsgMutation) ResetCreatedAt() {
  4037. m.created_at = nil
  4038. }
  4039. // SetUpdatedAt sets the "updated_at" field.
  4040. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4041. m.updated_at = &t
  4042. }
  4043. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4044. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4045. v := m.updated_at
  4046. if v == nil {
  4047. return
  4048. }
  4049. return *v, true
  4050. }
  4051. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4052. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4054. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4055. if !m.op.Is(OpUpdateOne) {
  4056. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4057. }
  4058. if m.id == nil || m.oldValue == nil {
  4059. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4060. }
  4061. oldValue, err := m.oldValue(ctx)
  4062. if err != nil {
  4063. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4064. }
  4065. return oldValue.UpdatedAt, nil
  4066. }
  4067. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4068. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4069. m.updated_at = nil
  4070. }
  4071. // SetDeletedAt sets the "deleted_at" field.
  4072. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4073. m.deleted_at = &t
  4074. }
  4075. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4076. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4077. v := m.deleted_at
  4078. if v == nil {
  4079. return
  4080. }
  4081. return *v, true
  4082. }
  4083. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4084. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4086. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4087. if !m.op.Is(OpUpdateOne) {
  4088. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4089. }
  4090. if m.id == nil || m.oldValue == nil {
  4091. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4092. }
  4093. oldValue, err := m.oldValue(ctx)
  4094. if err != nil {
  4095. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4096. }
  4097. return oldValue.DeletedAt, nil
  4098. }
  4099. // ClearDeletedAt clears the value of the "deleted_at" field.
  4100. func (m *BatchMsgMutation) ClearDeletedAt() {
  4101. m.deleted_at = nil
  4102. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4103. }
  4104. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4105. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4106. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4107. return ok
  4108. }
  4109. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4110. func (m *BatchMsgMutation) ResetDeletedAt() {
  4111. m.deleted_at = nil
  4112. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4113. }
  4114. // SetStatus sets the "status" field.
  4115. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4116. m.status = &u
  4117. m.addstatus = nil
  4118. }
  4119. // Status returns the value of the "status" field in the mutation.
  4120. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4121. v := m.status
  4122. if v == nil {
  4123. return
  4124. }
  4125. return *v, true
  4126. }
  4127. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4128. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4130. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4131. if !m.op.Is(OpUpdateOne) {
  4132. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4133. }
  4134. if m.id == nil || m.oldValue == nil {
  4135. return v, errors.New("OldStatus requires an ID field in the mutation")
  4136. }
  4137. oldValue, err := m.oldValue(ctx)
  4138. if err != nil {
  4139. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4140. }
  4141. return oldValue.Status, nil
  4142. }
  4143. // AddStatus adds u to the "status" field.
  4144. func (m *BatchMsgMutation) AddStatus(u int8) {
  4145. if m.addstatus != nil {
  4146. *m.addstatus += u
  4147. } else {
  4148. m.addstatus = &u
  4149. }
  4150. }
  4151. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4152. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4153. v := m.addstatus
  4154. if v == nil {
  4155. return
  4156. }
  4157. return *v, true
  4158. }
  4159. // ClearStatus clears the value of the "status" field.
  4160. func (m *BatchMsgMutation) ClearStatus() {
  4161. m.status = nil
  4162. m.addstatus = nil
  4163. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4164. }
  4165. // StatusCleared returns if the "status" field was cleared in this mutation.
  4166. func (m *BatchMsgMutation) StatusCleared() bool {
  4167. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4168. return ok
  4169. }
  4170. // ResetStatus resets all changes to the "status" field.
  4171. func (m *BatchMsgMutation) ResetStatus() {
  4172. m.status = nil
  4173. m.addstatus = nil
  4174. delete(m.clearedFields, batchmsg.FieldStatus)
  4175. }
  4176. // SetBatchNo sets the "batch_no" field.
  4177. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4178. m.batch_no = &s
  4179. }
  4180. // BatchNo returns the value of the "batch_no" field in the mutation.
  4181. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4182. v := m.batch_no
  4183. if v == nil {
  4184. return
  4185. }
  4186. return *v, true
  4187. }
  4188. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4189. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4191. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4192. if !m.op.Is(OpUpdateOne) {
  4193. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4194. }
  4195. if m.id == nil || m.oldValue == nil {
  4196. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4197. }
  4198. oldValue, err := m.oldValue(ctx)
  4199. if err != nil {
  4200. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4201. }
  4202. return oldValue.BatchNo, nil
  4203. }
  4204. // ClearBatchNo clears the value of the "batch_no" field.
  4205. func (m *BatchMsgMutation) ClearBatchNo() {
  4206. m.batch_no = nil
  4207. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4208. }
  4209. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4210. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4211. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4212. return ok
  4213. }
  4214. // ResetBatchNo resets all changes to the "batch_no" field.
  4215. func (m *BatchMsgMutation) ResetBatchNo() {
  4216. m.batch_no = nil
  4217. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4218. }
  4219. // SetTaskName sets the "task_name" field.
  4220. func (m *BatchMsgMutation) SetTaskName(s string) {
  4221. m.task_name = &s
  4222. }
  4223. // TaskName returns the value of the "task_name" field in the mutation.
  4224. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4225. v := m.task_name
  4226. if v == nil {
  4227. return
  4228. }
  4229. return *v, true
  4230. }
  4231. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4232. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4234. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4235. if !m.op.Is(OpUpdateOne) {
  4236. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4237. }
  4238. if m.id == nil || m.oldValue == nil {
  4239. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4240. }
  4241. oldValue, err := m.oldValue(ctx)
  4242. if err != nil {
  4243. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4244. }
  4245. return oldValue.TaskName, nil
  4246. }
  4247. // ClearTaskName clears the value of the "task_name" field.
  4248. func (m *BatchMsgMutation) ClearTaskName() {
  4249. m.task_name = nil
  4250. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4251. }
  4252. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4253. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4254. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4255. return ok
  4256. }
  4257. // ResetTaskName resets all changes to the "task_name" field.
  4258. func (m *BatchMsgMutation) ResetTaskName() {
  4259. m.task_name = nil
  4260. delete(m.clearedFields, batchmsg.FieldTaskName)
  4261. }
  4262. // SetFromwxid sets the "fromwxid" field.
  4263. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4264. m.fromwxid = &s
  4265. }
  4266. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4267. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4268. v := m.fromwxid
  4269. if v == nil {
  4270. return
  4271. }
  4272. return *v, true
  4273. }
  4274. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4275. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4277. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4278. if !m.op.Is(OpUpdateOne) {
  4279. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4280. }
  4281. if m.id == nil || m.oldValue == nil {
  4282. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4283. }
  4284. oldValue, err := m.oldValue(ctx)
  4285. if err != nil {
  4286. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4287. }
  4288. return oldValue.Fromwxid, nil
  4289. }
  4290. // ClearFromwxid clears the value of the "fromwxid" field.
  4291. func (m *BatchMsgMutation) ClearFromwxid() {
  4292. m.fromwxid = nil
  4293. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4294. }
  4295. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4296. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4297. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4298. return ok
  4299. }
  4300. // ResetFromwxid resets all changes to the "fromwxid" field.
  4301. func (m *BatchMsgMutation) ResetFromwxid() {
  4302. m.fromwxid = nil
  4303. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4304. }
  4305. // SetMsg sets the "msg" field.
  4306. func (m *BatchMsgMutation) SetMsg(s string) {
  4307. m.msg = &s
  4308. }
  4309. // Msg returns the value of the "msg" field in the mutation.
  4310. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4311. v := m.msg
  4312. if v == nil {
  4313. return
  4314. }
  4315. return *v, true
  4316. }
  4317. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4318. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4320. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4321. if !m.op.Is(OpUpdateOne) {
  4322. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4323. }
  4324. if m.id == nil || m.oldValue == nil {
  4325. return v, errors.New("OldMsg requires an ID field in the mutation")
  4326. }
  4327. oldValue, err := m.oldValue(ctx)
  4328. if err != nil {
  4329. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4330. }
  4331. return oldValue.Msg, nil
  4332. }
  4333. // ClearMsg clears the value of the "msg" field.
  4334. func (m *BatchMsgMutation) ClearMsg() {
  4335. m.msg = nil
  4336. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4337. }
  4338. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4339. func (m *BatchMsgMutation) MsgCleared() bool {
  4340. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4341. return ok
  4342. }
  4343. // ResetMsg resets all changes to the "msg" field.
  4344. func (m *BatchMsgMutation) ResetMsg() {
  4345. m.msg = nil
  4346. delete(m.clearedFields, batchmsg.FieldMsg)
  4347. }
  4348. // SetTag sets the "tag" field.
  4349. func (m *BatchMsgMutation) SetTag(s string) {
  4350. m.tag = &s
  4351. }
  4352. // Tag returns the value of the "tag" field in the mutation.
  4353. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4354. v := m.tag
  4355. if v == nil {
  4356. return
  4357. }
  4358. return *v, true
  4359. }
  4360. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4361. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4363. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4364. if !m.op.Is(OpUpdateOne) {
  4365. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4366. }
  4367. if m.id == nil || m.oldValue == nil {
  4368. return v, errors.New("OldTag requires an ID field in the mutation")
  4369. }
  4370. oldValue, err := m.oldValue(ctx)
  4371. if err != nil {
  4372. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4373. }
  4374. return oldValue.Tag, nil
  4375. }
  4376. // ClearTag clears the value of the "tag" field.
  4377. func (m *BatchMsgMutation) ClearTag() {
  4378. m.tag = nil
  4379. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4380. }
  4381. // TagCleared returns if the "tag" field was cleared in this mutation.
  4382. func (m *BatchMsgMutation) TagCleared() bool {
  4383. _, ok := m.clearedFields[batchmsg.FieldTag]
  4384. return ok
  4385. }
  4386. // ResetTag resets all changes to the "tag" field.
  4387. func (m *BatchMsgMutation) ResetTag() {
  4388. m.tag = nil
  4389. delete(m.clearedFields, batchmsg.FieldTag)
  4390. }
  4391. // SetTagids sets the "tagids" field.
  4392. func (m *BatchMsgMutation) SetTagids(s string) {
  4393. m.tagids = &s
  4394. }
  4395. // Tagids returns the value of the "tagids" field in the mutation.
  4396. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4397. v := m.tagids
  4398. if v == nil {
  4399. return
  4400. }
  4401. return *v, true
  4402. }
  4403. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4404. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4406. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4407. if !m.op.Is(OpUpdateOne) {
  4408. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4409. }
  4410. if m.id == nil || m.oldValue == nil {
  4411. return v, errors.New("OldTagids requires an ID field in the mutation")
  4412. }
  4413. oldValue, err := m.oldValue(ctx)
  4414. if err != nil {
  4415. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4416. }
  4417. return oldValue.Tagids, nil
  4418. }
  4419. // ClearTagids clears the value of the "tagids" field.
  4420. func (m *BatchMsgMutation) ClearTagids() {
  4421. m.tagids = nil
  4422. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4423. }
  4424. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4425. func (m *BatchMsgMutation) TagidsCleared() bool {
  4426. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4427. return ok
  4428. }
  4429. // ResetTagids resets all changes to the "tagids" field.
  4430. func (m *BatchMsgMutation) ResetTagids() {
  4431. m.tagids = nil
  4432. delete(m.clearedFields, batchmsg.FieldTagids)
  4433. }
  4434. // SetTotal sets the "total" field.
  4435. func (m *BatchMsgMutation) SetTotal(i int32) {
  4436. m.total = &i
  4437. m.addtotal = nil
  4438. }
  4439. // Total returns the value of the "total" field in the mutation.
  4440. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4441. v := m.total
  4442. if v == nil {
  4443. return
  4444. }
  4445. return *v, true
  4446. }
  4447. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4448. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4450. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4451. if !m.op.Is(OpUpdateOne) {
  4452. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4453. }
  4454. if m.id == nil || m.oldValue == nil {
  4455. return v, errors.New("OldTotal requires an ID field in the mutation")
  4456. }
  4457. oldValue, err := m.oldValue(ctx)
  4458. if err != nil {
  4459. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4460. }
  4461. return oldValue.Total, nil
  4462. }
  4463. // AddTotal adds i to the "total" field.
  4464. func (m *BatchMsgMutation) AddTotal(i int32) {
  4465. if m.addtotal != nil {
  4466. *m.addtotal += i
  4467. } else {
  4468. m.addtotal = &i
  4469. }
  4470. }
  4471. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4472. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4473. v := m.addtotal
  4474. if v == nil {
  4475. return
  4476. }
  4477. return *v, true
  4478. }
  4479. // ClearTotal clears the value of the "total" field.
  4480. func (m *BatchMsgMutation) ClearTotal() {
  4481. m.total = nil
  4482. m.addtotal = nil
  4483. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4484. }
  4485. // TotalCleared returns if the "total" field was cleared in this mutation.
  4486. func (m *BatchMsgMutation) TotalCleared() bool {
  4487. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4488. return ok
  4489. }
  4490. // ResetTotal resets all changes to the "total" field.
  4491. func (m *BatchMsgMutation) ResetTotal() {
  4492. m.total = nil
  4493. m.addtotal = nil
  4494. delete(m.clearedFields, batchmsg.FieldTotal)
  4495. }
  4496. // SetSuccess sets the "success" field.
  4497. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4498. m.success = &i
  4499. m.addsuccess = nil
  4500. }
  4501. // Success returns the value of the "success" field in the mutation.
  4502. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4503. v := m.success
  4504. if v == nil {
  4505. return
  4506. }
  4507. return *v, true
  4508. }
  4509. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4510. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4512. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4513. if !m.op.Is(OpUpdateOne) {
  4514. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4515. }
  4516. if m.id == nil || m.oldValue == nil {
  4517. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4518. }
  4519. oldValue, err := m.oldValue(ctx)
  4520. if err != nil {
  4521. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4522. }
  4523. return oldValue.Success, nil
  4524. }
  4525. // AddSuccess adds i to the "success" field.
  4526. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4527. if m.addsuccess != nil {
  4528. *m.addsuccess += i
  4529. } else {
  4530. m.addsuccess = &i
  4531. }
  4532. }
  4533. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4534. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4535. v := m.addsuccess
  4536. if v == nil {
  4537. return
  4538. }
  4539. return *v, true
  4540. }
  4541. // ClearSuccess clears the value of the "success" field.
  4542. func (m *BatchMsgMutation) ClearSuccess() {
  4543. m.success = nil
  4544. m.addsuccess = nil
  4545. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4546. }
  4547. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4548. func (m *BatchMsgMutation) SuccessCleared() bool {
  4549. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4550. return ok
  4551. }
  4552. // ResetSuccess resets all changes to the "success" field.
  4553. func (m *BatchMsgMutation) ResetSuccess() {
  4554. m.success = nil
  4555. m.addsuccess = nil
  4556. delete(m.clearedFields, batchmsg.FieldSuccess)
  4557. }
  4558. // SetFail sets the "fail" field.
  4559. func (m *BatchMsgMutation) SetFail(i int32) {
  4560. m.fail = &i
  4561. m.addfail = nil
  4562. }
  4563. // Fail returns the value of the "fail" field in the mutation.
  4564. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4565. v := m.fail
  4566. if v == nil {
  4567. return
  4568. }
  4569. return *v, true
  4570. }
  4571. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4572. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4574. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4575. if !m.op.Is(OpUpdateOne) {
  4576. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4577. }
  4578. if m.id == nil || m.oldValue == nil {
  4579. return v, errors.New("OldFail requires an ID field in the mutation")
  4580. }
  4581. oldValue, err := m.oldValue(ctx)
  4582. if err != nil {
  4583. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4584. }
  4585. return oldValue.Fail, nil
  4586. }
  4587. // AddFail adds i to the "fail" field.
  4588. func (m *BatchMsgMutation) AddFail(i int32) {
  4589. if m.addfail != nil {
  4590. *m.addfail += i
  4591. } else {
  4592. m.addfail = &i
  4593. }
  4594. }
  4595. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4596. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4597. v := m.addfail
  4598. if v == nil {
  4599. return
  4600. }
  4601. return *v, true
  4602. }
  4603. // ClearFail clears the value of the "fail" field.
  4604. func (m *BatchMsgMutation) ClearFail() {
  4605. m.fail = nil
  4606. m.addfail = nil
  4607. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4608. }
  4609. // FailCleared returns if the "fail" field was cleared in this mutation.
  4610. func (m *BatchMsgMutation) FailCleared() bool {
  4611. _, ok := m.clearedFields[batchmsg.FieldFail]
  4612. return ok
  4613. }
  4614. // ResetFail resets all changes to the "fail" field.
  4615. func (m *BatchMsgMutation) ResetFail() {
  4616. m.fail = nil
  4617. m.addfail = nil
  4618. delete(m.clearedFields, batchmsg.FieldFail)
  4619. }
  4620. // SetStartTime sets the "start_time" field.
  4621. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4622. m.start_time = &t
  4623. }
  4624. // StartTime returns the value of the "start_time" field in the mutation.
  4625. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4626. v := m.start_time
  4627. if v == nil {
  4628. return
  4629. }
  4630. return *v, true
  4631. }
  4632. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4633. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4635. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4636. if !m.op.Is(OpUpdateOne) {
  4637. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4638. }
  4639. if m.id == nil || m.oldValue == nil {
  4640. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4641. }
  4642. oldValue, err := m.oldValue(ctx)
  4643. if err != nil {
  4644. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4645. }
  4646. return oldValue.StartTime, nil
  4647. }
  4648. // ClearStartTime clears the value of the "start_time" field.
  4649. func (m *BatchMsgMutation) ClearStartTime() {
  4650. m.start_time = nil
  4651. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4652. }
  4653. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4654. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4655. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4656. return ok
  4657. }
  4658. // ResetStartTime resets all changes to the "start_time" field.
  4659. func (m *BatchMsgMutation) ResetStartTime() {
  4660. m.start_time = nil
  4661. delete(m.clearedFields, batchmsg.FieldStartTime)
  4662. }
  4663. // SetStopTime sets the "stop_time" field.
  4664. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4665. m.stop_time = &t
  4666. }
  4667. // StopTime returns the value of the "stop_time" field in the mutation.
  4668. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4669. v := m.stop_time
  4670. if v == nil {
  4671. return
  4672. }
  4673. return *v, true
  4674. }
  4675. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4676. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4678. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4679. if !m.op.Is(OpUpdateOne) {
  4680. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4681. }
  4682. if m.id == nil || m.oldValue == nil {
  4683. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4684. }
  4685. oldValue, err := m.oldValue(ctx)
  4686. if err != nil {
  4687. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4688. }
  4689. return oldValue.StopTime, nil
  4690. }
  4691. // ClearStopTime clears the value of the "stop_time" field.
  4692. func (m *BatchMsgMutation) ClearStopTime() {
  4693. m.stop_time = nil
  4694. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4695. }
  4696. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4697. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4698. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4699. return ok
  4700. }
  4701. // ResetStopTime resets all changes to the "stop_time" field.
  4702. func (m *BatchMsgMutation) ResetStopTime() {
  4703. m.stop_time = nil
  4704. delete(m.clearedFields, batchmsg.FieldStopTime)
  4705. }
  4706. // SetSendTime sets the "send_time" field.
  4707. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4708. m.send_time = &t
  4709. }
  4710. // SendTime returns the value of the "send_time" field in the mutation.
  4711. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4712. v := m.send_time
  4713. if v == nil {
  4714. return
  4715. }
  4716. return *v, true
  4717. }
  4718. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4719. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4721. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4722. if !m.op.Is(OpUpdateOne) {
  4723. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4724. }
  4725. if m.id == nil || m.oldValue == nil {
  4726. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4727. }
  4728. oldValue, err := m.oldValue(ctx)
  4729. if err != nil {
  4730. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4731. }
  4732. return oldValue.SendTime, nil
  4733. }
  4734. // ClearSendTime clears the value of the "send_time" field.
  4735. func (m *BatchMsgMutation) ClearSendTime() {
  4736. m.send_time = nil
  4737. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4738. }
  4739. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4740. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4741. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4742. return ok
  4743. }
  4744. // ResetSendTime resets all changes to the "send_time" field.
  4745. func (m *BatchMsgMutation) ResetSendTime() {
  4746. m.send_time = nil
  4747. delete(m.clearedFields, batchmsg.FieldSendTime)
  4748. }
  4749. // SetType sets the "type" field.
  4750. func (m *BatchMsgMutation) SetType(i int32) {
  4751. m._type = &i
  4752. m.add_type = nil
  4753. }
  4754. // GetType returns the value of the "type" field in the mutation.
  4755. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4756. v := m._type
  4757. if v == nil {
  4758. return
  4759. }
  4760. return *v, true
  4761. }
  4762. // OldType returns the old "type" field's value of the BatchMsg entity.
  4763. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4765. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4766. if !m.op.Is(OpUpdateOne) {
  4767. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4768. }
  4769. if m.id == nil || m.oldValue == nil {
  4770. return v, errors.New("OldType requires an ID field in the mutation")
  4771. }
  4772. oldValue, err := m.oldValue(ctx)
  4773. if err != nil {
  4774. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4775. }
  4776. return oldValue.Type, nil
  4777. }
  4778. // AddType adds i to the "type" field.
  4779. func (m *BatchMsgMutation) AddType(i int32) {
  4780. if m.add_type != nil {
  4781. *m.add_type += i
  4782. } else {
  4783. m.add_type = &i
  4784. }
  4785. }
  4786. // AddedType returns the value that was added to the "type" field in this mutation.
  4787. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4788. v := m.add_type
  4789. if v == nil {
  4790. return
  4791. }
  4792. return *v, true
  4793. }
  4794. // ClearType clears the value of the "type" field.
  4795. func (m *BatchMsgMutation) ClearType() {
  4796. m._type = nil
  4797. m.add_type = nil
  4798. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4799. }
  4800. // TypeCleared returns if the "type" field was cleared in this mutation.
  4801. func (m *BatchMsgMutation) TypeCleared() bool {
  4802. _, ok := m.clearedFields[batchmsg.FieldType]
  4803. return ok
  4804. }
  4805. // ResetType resets all changes to the "type" field.
  4806. func (m *BatchMsgMutation) ResetType() {
  4807. m._type = nil
  4808. m.add_type = nil
  4809. delete(m.clearedFields, batchmsg.FieldType)
  4810. }
  4811. // SetOrganizationID sets the "organization_id" field.
  4812. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4813. m.organization_id = &u
  4814. m.addorganization_id = nil
  4815. }
  4816. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4817. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4818. v := m.organization_id
  4819. if v == nil {
  4820. return
  4821. }
  4822. return *v, true
  4823. }
  4824. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4825. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4827. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4828. if !m.op.Is(OpUpdateOne) {
  4829. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4830. }
  4831. if m.id == nil || m.oldValue == nil {
  4832. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4833. }
  4834. oldValue, err := m.oldValue(ctx)
  4835. if err != nil {
  4836. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4837. }
  4838. return oldValue.OrganizationID, nil
  4839. }
  4840. // AddOrganizationID adds u to the "organization_id" field.
  4841. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4842. if m.addorganization_id != nil {
  4843. *m.addorganization_id += u
  4844. } else {
  4845. m.addorganization_id = &u
  4846. }
  4847. }
  4848. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4849. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4850. v := m.addorganization_id
  4851. if v == nil {
  4852. return
  4853. }
  4854. return *v, true
  4855. }
  4856. // ResetOrganizationID resets all changes to the "organization_id" field.
  4857. func (m *BatchMsgMutation) ResetOrganizationID() {
  4858. m.organization_id = nil
  4859. m.addorganization_id = nil
  4860. }
  4861. // Where appends a list predicates to the BatchMsgMutation builder.
  4862. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4863. m.predicates = append(m.predicates, ps...)
  4864. }
  4865. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4866. // users can use type-assertion to append predicates that do not depend on any generated package.
  4867. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4868. p := make([]predicate.BatchMsg, len(ps))
  4869. for i := range ps {
  4870. p[i] = ps[i]
  4871. }
  4872. m.Where(p...)
  4873. }
  4874. // Op returns the operation name.
  4875. func (m *BatchMsgMutation) Op() Op {
  4876. return m.op
  4877. }
  4878. // SetOp allows setting the mutation operation.
  4879. func (m *BatchMsgMutation) SetOp(op Op) {
  4880. m.op = op
  4881. }
  4882. // Type returns the node type of this mutation (BatchMsg).
  4883. func (m *BatchMsgMutation) Type() string {
  4884. return m.typ
  4885. }
  4886. // Fields returns all fields that were changed during this mutation. Note that in
  4887. // order to get all numeric fields that were incremented/decremented, call
  4888. // AddedFields().
  4889. func (m *BatchMsgMutation) Fields() []string {
  4890. fields := make([]string, 0, 18)
  4891. if m.created_at != nil {
  4892. fields = append(fields, batchmsg.FieldCreatedAt)
  4893. }
  4894. if m.updated_at != nil {
  4895. fields = append(fields, batchmsg.FieldUpdatedAt)
  4896. }
  4897. if m.deleted_at != nil {
  4898. fields = append(fields, batchmsg.FieldDeletedAt)
  4899. }
  4900. if m.status != nil {
  4901. fields = append(fields, batchmsg.FieldStatus)
  4902. }
  4903. if m.batch_no != nil {
  4904. fields = append(fields, batchmsg.FieldBatchNo)
  4905. }
  4906. if m.task_name != nil {
  4907. fields = append(fields, batchmsg.FieldTaskName)
  4908. }
  4909. if m.fromwxid != nil {
  4910. fields = append(fields, batchmsg.FieldFromwxid)
  4911. }
  4912. if m.msg != nil {
  4913. fields = append(fields, batchmsg.FieldMsg)
  4914. }
  4915. if m.tag != nil {
  4916. fields = append(fields, batchmsg.FieldTag)
  4917. }
  4918. if m.tagids != nil {
  4919. fields = append(fields, batchmsg.FieldTagids)
  4920. }
  4921. if m.total != nil {
  4922. fields = append(fields, batchmsg.FieldTotal)
  4923. }
  4924. if m.success != nil {
  4925. fields = append(fields, batchmsg.FieldSuccess)
  4926. }
  4927. if m.fail != nil {
  4928. fields = append(fields, batchmsg.FieldFail)
  4929. }
  4930. if m.start_time != nil {
  4931. fields = append(fields, batchmsg.FieldStartTime)
  4932. }
  4933. if m.stop_time != nil {
  4934. fields = append(fields, batchmsg.FieldStopTime)
  4935. }
  4936. if m.send_time != nil {
  4937. fields = append(fields, batchmsg.FieldSendTime)
  4938. }
  4939. if m._type != nil {
  4940. fields = append(fields, batchmsg.FieldType)
  4941. }
  4942. if m.organization_id != nil {
  4943. fields = append(fields, batchmsg.FieldOrganizationID)
  4944. }
  4945. return fields
  4946. }
  4947. // Field returns the value of a field with the given name. The second boolean
  4948. // return value indicates that this field was not set, or was not defined in the
  4949. // schema.
  4950. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4951. switch name {
  4952. case batchmsg.FieldCreatedAt:
  4953. return m.CreatedAt()
  4954. case batchmsg.FieldUpdatedAt:
  4955. return m.UpdatedAt()
  4956. case batchmsg.FieldDeletedAt:
  4957. return m.DeletedAt()
  4958. case batchmsg.FieldStatus:
  4959. return m.Status()
  4960. case batchmsg.FieldBatchNo:
  4961. return m.BatchNo()
  4962. case batchmsg.FieldTaskName:
  4963. return m.TaskName()
  4964. case batchmsg.FieldFromwxid:
  4965. return m.Fromwxid()
  4966. case batchmsg.FieldMsg:
  4967. return m.Msg()
  4968. case batchmsg.FieldTag:
  4969. return m.Tag()
  4970. case batchmsg.FieldTagids:
  4971. return m.Tagids()
  4972. case batchmsg.FieldTotal:
  4973. return m.Total()
  4974. case batchmsg.FieldSuccess:
  4975. return m.Success()
  4976. case batchmsg.FieldFail:
  4977. return m.Fail()
  4978. case batchmsg.FieldStartTime:
  4979. return m.StartTime()
  4980. case batchmsg.FieldStopTime:
  4981. return m.StopTime()
  4982. case batchmsg.FieldSendTime:
  4983. return m.SendTime()
  4984. case batchmsg.FieldType:
  4985. return m.GetType()
  4986. case batchmsg.FieldOrganizationID:
  4987. return m.OrganizationID()
  4988. }
  4989. return nil, false
  4990. }
  4991. // OldField returns the old value of the field from the database. An error is
  4992. // returned if the mutation operation is not UpdateOne, or the query to the
  4993. // database failed.
  4994. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4995. switch name {
  4996. case batchmsg.FieldCreatedAt:
  4997. return m.OldCreatedAt(ctx)
  4998. case batchmsg.FieldUpdatedAt:
  4999. return m.OldUpdatedAt(ctx)
  5000. case batchmsg.FieldDeletedAt:
  5001. return m.OldDeletedAt(ctx)
  5002. case batchmsg.FieldStatus:
  5003. return m.OldStatus(ctx)
  5004. case batchmsg.FieldBatchNo:
  5005. return m.OldBatchNo(ctx)
  5006. case batchmsg.FieldTaskName:
  5007. return m.OldTaskName(ctx)
  5008. case batchmsg.FieldFromwxid:
  5009. return m.OldFromwxid(ctx)
  5010. case batchmsg.FieldMsg:
  5011. return m.OldMsg(ctx)
  5012. case batchmsg.FieldTag:
  5013. return m.OldTag(ctx)
  5014. case batchmsg.FieldTagids:
  5015. return m.OldTagids(ctx)
  5016. case batchmsg.FieldTotal:
  5017. return m.OldTotal(ctx)
  5018. case batchmsg.FieldSuccess:
  5019. return m.OldSuccess(ctx)
  5020. case batchmsg.FieldFail:
  5021. return m.OldFail(ctx)
  5022. case batchmsg.FieldStartTime:
  5023. return m.OldStartTime(ctx)
  5024. case batchmsg.FieldStopTime:
  5025. return m.OldStopTime(ctx)
  5026. case batchmsg.FieldSendTime:
  5027. return m.OldSendTime(ctx)
  5028. case batchmsg.FieldType:
  5029. return m.OldType(ctx)
  5030. case batchmsg.FieldOrganizationID:
  5031. return m.OldOrganizationID(ctx)
  5032. }
  5033. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5034. }
  5035. // SetField sets the value of a field with the given name. It returns an error if
  5036. // the field is not defined in the schema, or if the type mismatched the field
  5037. // type.
  5038. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5039. switch name {
  5040. case batchmsg.FieldCreatedAt:
  5041. v, ok := value.(time.Time)
  5042. if !ok {
  5043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5044. }
  5045. m.SetCreatedAt(v)
  5046. return nil
  5047. case batchmsg.FieldUpdatedAt:
  5048. v, ok := value.(time.Time)
  5049. if !ok {
  5050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5051. }
  5052. m.SetUpdatedAt(v)
  5053. return nil
  5054. case batchmsg.FieldDeletedAt:
  5055. v, ok := value.(time.Time)
  5056. if !ok {
  5057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5058. }
  5059. m.SetDeletedAt(v)
  5060. return nil
  5061. case batchmsg.FieldStatus:
  5062. v, ok := value.(uint8)
  5063. if !ok {
  5064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5065. }
  5066. m.SetStatus(v)
  5067. return nil
  5068. case batchmsg.FieldBatchNo:
  5069. v, ok := value.(string)
  5070. if !ok {
  5071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5072. }
  5073. m.SetBatchNo(v)
  5074. return nil
  5075. case batchmsg.FieldTaskName:
  5076. v, ok := value.(string)
  5077. if !ok {
  5078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5079. }
  5080. m.SetTaskName(v)
  5081. return nil
  5082. case batchmsg.FieldFromwxid:
  5083. v, ok := value.(string)
  5084. if !ok {
  5085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5086. }
  5087. m.SetFromwxid(v)
  5088. return nil
  5089. case batchmsg.FieldMsg:
  5090. v, ok := value.(string)
  5091. if !ok {
  5092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5093. }
  5094. m.SetMsg(v)
  5095. return nil
  5096. case batchmsg.FieldTag:
  5097. v, ok := value.(string)
  5098. if !ok {
  5099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5100. }
  5101. m.SetTag(v)
  5102. return nil
  5103. case batchmsg.FieldTagids:
  5104. v, ok := value.(string)
  5105. if !ok {
  5106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5107. }
  5108. m.SetTagids(v)
  5109. return nil
  5110. case batchmsg.FieldTotal:
  5111. v, ok := value.(int32)
  5112. if !ok {
  5113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5114. }
  5115. m.SetTotal(v)
  5116. return nil
  5117. case batchmsg.FieldSuccess:
  5118. v, ok := value.(int32)
  5119. if !ok {
  5120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5121. }
  5122. m.SetSuccess(v)
  5123. return nil
  5124. case batchmsg.FieldFail:
  5125. v, ok := value.(int32)
  5126. if !ok {
  5127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5128. }
  5129. m.SetFail(v)
  5130. return nil
  5131. case batchmsg.FieldStartTime:
  5132. v, ok := value.(time.Time)
  5133. if !ok {
  5134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5135. }
  5136. m.SetStartTime(v)
  5137. return nil
  5138. case batchmsg.FieldStopTime:
  5139. v, ok := value.(time.Time)
  5140. if !ok {
  5141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5142. }
  5143. m.SetStopTime(v)
  5144. return nil
  5145. case batchmsg.FieldSendTime:
  5146. v, ok := value.(time.Time)
  5147. if !ok {
  5148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5149. }
  5150. m.SetSendTime(v)
  5151. return nil
  5152. case batchmsg.FieldType:
  5153. v, ok := value.(int32)
  5154. if !ok {
  5155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5156. }
  5157. m.SetType(v)
  5158. return nil
  5159. case batchmsg.FieldOrganizationID:
  5160. v, ok := value.(uint64)
  5161. if !ok {
  5162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5163. }
  5164. m.SetOrganizationID(v)
  5165. return nil
  5166. }
  5167. return fmt.Errorf("unknown BatchMsg field %s", name)
  5168. }
  5169. // AddedFields returns all numeric fields that were incremented/decremented during
  5170. // this mutation.
  5171. func (m *BatchMsgMutation) AddedFields() []string {
  5172. var fields []string
  5173. if m.addstatus != nil {
  5174. fields = append(fields, batchmsg.FieldStatus)
  5175. }
  5176. if m.addtotal != nil {
  5177. fields = append(fields, batchmsg.FieldTotal)
  5178. }
  5179. if m.addsuccess != nil {
  5180. fields = append(fields, batchmsg.FieldSuccess)
  5181. }
  5182. if m.addfail != nil {
  5183. fields = append(fields, batchmsg.FieldFail)
  5184. }
  5185. if m.add_type != nil {
  5186. fields = append(fields, batchmsg.FieldType)
  5187. }
  5188. if m.addorganization_id != nil {
  5189. fields = append(fields, batchmsg.FieldOrganizationID)
  5190. }
  5191. return fields
  5192. }
  5193. // AddedField returns the numeric value that was incremented/decremented on a field
  5194. // with the given name. The second boolean return value indicates that this field
  5195. // was not set, or was not defined in the schema.
  5196. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5197. switch name {
  5198. case batchmsg.FieldStatus:
  5199. return m.AddedStatus()
  5200. case batchmsg.FieldTotal:
  5201. return m.AddedTotal()
  5202. case batchmsg.FieldSuccess:
  5203. return m.AddedSuccess()
  5204. case batchmsg.FieldFail:
  5205. return m.AddedFail()
  5206. case batchmsg.FieldType:
  5207. return m.AddedType()
  5208. case batchmsg.FieldOrganizationID:
  5209. return m.AddedOrganizationID()
  5210. }
  5211. return nil, false
  5212. }
  5213. // AddField adds the value to the field with the given name. It returns an error if
  5214. // the field is not defined in the schema, or if the type mismatched the field
  5215. // type.
  5216. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5217. switch name {
  5218. case batchmsg.FieldStatus:
  5219. v, ok := value.(int8)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.AddStatus(v)
  5224. return nil
  5225. case batchmsg.FieldTotal:
  5226. v, ok := value.(int32)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.AddTotal(v)
  5231. return nil
  5232. case batchmsg.FieldSuccess:
  5233. v, ok := value.(int32)
  5234. if !ok {
  5235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5236. }
  5237. m.AddSuccess(v)
  5238. return nil
  5239. case batchmsg.FieldFail:
  5240. v, ok := value.(int32)
  5241. if !ok {
  5242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5243. }
  5244. m.AddFail(v)
  5245. return nil
  5246. case batchmsg.FieldType:
  5247. v, ok := value.(int32)
  5248. if !ok {
  5249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5250. }
  5251. m.AddType(v)
  5252. return nil
  5253. case batchmsg.FieldOrganizationID:
  5254. v, ok := value.(int64)
  5255. if !ok {
  5256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5257. }
  5258. m.AddOrganizationID(v)
  5259. return nil
  5260. }
  5261. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5262. }
  5263. // ClearedFields returns all nullable fields that were cleared during this
  5264. // mutation.
  5265. func (m *BatchMsgMutation) ClearedFields() []string {
  5266. var fields []string
  5267. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5268. fields = append(fields, batchmsg.FieldDeletedAt)
  5269. }
  5270. if m.FieldCleared(batchmsg.FieldStatus) {
  5271. fields = append(fields, batchmsg.FieldStatus)
  5272. }
  5273. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5274. fields = append(fields, batchmsg.FieldBatchNo)
  5275. }
  5276. if m.FieldCleared(batchmsg.FieldTaskName) {
  5277. fields = append(fields, batchmsg.FieldTaskName)
  5278. }
  5279. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5280. fields = append(fields, batchmsg.FieldFromwxid)
  5281. }
  5282. if m.FieldCleared(batchmsg.FieldMsg) {
  5283. fields = append(fields, batchmsg.FieldMsg)
  5284. }
  5285. if m.FieldCleared(batchmsg.FieldTag) {
  5286. fields = append(fields, batchmsg.FieldTag)
  5287. }
  5288. if m.FieldCleared(batchmsg.FieldTagids) {
  5289. fields = append(fields, batchmsg.FieldTagids)
  5290. }
  5291. if m.FieldCleared(batchmsg.FieldTotal) {
  5292. fields = append(fields, batchmsg.FieldTotal)
  5293. }
  5294. if m.FieldCleared(batchmsg.FieldSuccess) {
  5295. fields = append(fields, batchmsg.FieldSuccess)
  5296. }
  5297. if m.FieldCleared(batchmsg.FieldFail) {
  5298. fields = append(fields, batchmsg.FieldFail)
  5299. }
  5300. if m.FieldCleared(batchmsg.FieldStartTime) {
  5301. fields = append(fields, batchmsg.FieldStartTime)
  5302. }
  5303. if m.FieldCleared(batchmsg.FieldStopTime) {
  5304. fields = append(fields, batchmsg.FieldStopTime)
  5305. }
  5306. if m.FieldCleared(batchmsg.FieldSendTime) {
  5307. fields = append(fields, batchmsg.FieldSendTime)
  5308. }
  5309. if m.FieldCleared(batchmsg.FieldType) {
  5310. fields = append(fields, batchmsg.FieldType)
  5311. }
  5312. return fields
  5313. }
  5314. // FieldCleared returns a boolean indicating if a field with the given name was
  5315. // cleared in this mutation.
  5316. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5317. _, ok := m.clearedFields[name]
  5318. return ok
  5319. }
  5320. // ClearField clears the value of the field with the given name. It returns an
  5321. // error if the field is not defined in the schema.
  5322. func (m *BatchMsgMutation) ClearField(name string) error {
  5323. switch name {
  5324. case batchmsg.FieldDeletedAt:
  5325. m.ClearDeletedAt()
  5326. return nil
  5327. case batchmsg.FieldStatus:
  5328. m.ClearStatus()
  5329. return nil
  5330. case batchmsg.FieldBatchNo:
  5331. m.ClearBatchNo()
  5332. return nil
  5333. case batchmsg.FieldTaskName:
  5334. m.ClearTaskName()
  5335. return nil
  5336. case batchmsg.FieldFromwxid:
  5337. m.ClearFromwxid()
  5338. return nil
  5339. case batchmsg.FieldMsg:
  5340. m.ClearMsg()
  5341. return nil
  5342. case batchmsg.FieldTag:
  5343. m.ClearTag()
  5344. return nil
  5345. case batchmsg.FieldTagids:
  5346. m.ClearTagids()
  5347. return nil
  5348. case batchmsg.FieldTotal:
  5349. m.ClearTotal()
  5350. return nil
  5351. case batchmsg.FieldSuccess:
  5352. m.ClearSuccess()
  5353. return nil
  5354. case batchmsg.FieldFail:
  5355. m.ClearFail()
  5356. return nil
  5357. case batchmsg.FieldStartTime:
  5358. m.ClearStartTime()
  5359. return nil
  5360. case batchmsg.FieldStopTime:
  5361. m.ClearStopTime()
  5362. return nil
  5363. case batchmsg.FieldSendTime:
  5364. m.ClearSendTime()
  5365. return nil
  5366. case batchmsg.FieldType:
  5367. m.ClearType()
  5368. return nil
  5369. }
  5370. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5371. }
  5372. // ResetField resets all changes in the mutation for the field with the given name.
  5373. // It returns an error if the field is not defined in the schema.
  5374. func (m *BatchMsgMutation) ResetField(name string) error {
  5375. switch name {
  5376. case batchmsg.FieldCreatedAt:
  5377. m.ResetCreatedAt()
  5378. return nil
  5379. case batchmsg.FieldUpdatedAt:
  5380. m.ResetUpdatedAt()
  5381. return nil
  5382. case batchmsg.FieldDeletedAt:
  5383. m.ResetDeletedAt()
  5384. return nil
  5385. case batchmsg.FieldStatus:
  5386. m.ResetStatus()
  5387. return nil
  5388. case batchmsg.FieldBatchNo:
  5389. m.ResetBatchNo()
  5390. return nil
  5391. case batchmsg.FieldTaskName:
  5392. m.ResetTaskName()
  5393. return nil
  5394. case batchmsg.FieldFromwxid:
  5395. m.ResetFromwxid()
  5396. return nil
  5397. case batchmsg.FieldMsg:
  5398. m.ResetMsg()
  5399. return nil
  5400. case batchmsg.FieldTag:
  5401. m.ResetTag()
  5402. return nil
  5403. case batchmsg.FieldTagids:
  5404. m.ResetTagids()
  5405. return nil
  5406. case batchmsg.FieldTotal:
  5407. m.ResetTotal()
  5408. return nil
  5409. case batchmsg.FieldSuccess:
  5410. m.ResetSuccess()
  5411. return nil
  5412. case batchmsg.FieldFail:
  5413. m.ResetFail()
  5414. return nil
  5415. case batchmsg.FieldStartTime:
  5416. m.ResetStartTime()
  5417. return nil
  5418. case batchmsg.FieldStopTime:
  5419. m.ResetStopTime()
  5420. return nil
  5421. case batchmsg.FieldSendTime:
  5422. m.ResetSendTime()
  5423. return nil
  5424. case batchmsg.FieldType:
  5425. m.ResetType()
  5426. return nil
  5427. case batchmsg.FieldOrganizationID:
  5428. m.ResetOrganizationID()
  5429. return nil
  5430. }
  5431. return fmt.Errorf("unknown BatchMsg field %s", name)
  5432. }
  5433. // AddedEdges returns all edge names that were set/added in this mutation.
  5434. func (m *BatchMsgMutation) AddedEdges() []string {
  5435. edges := make([]string, 0, 0)
  5436. return edges
  5437. }
  5438. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5439. // name in this mutation.
  5440. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5441. return nil
  5442. }
  5443. // RemovedEdges returns all edge names that were removed in this mutation.
  5444. func (m *BatchMsgMutation) RemovedEdges() []string {
  5445. edges := make([]string, 0, 0)
  5446. return edges
  5447. }
  5448. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5449. // the given name in this mutation.
  5450. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5451. return nil
  5452. }
  5453. // ClearedEdges returns all edge names that were cleared in this mutation.
  5454. func (m *BatchMsgMutation) ClearedEdges() []string {
  5455. edges := make([]string, 0, 0)
  5456. return edges
  5457. }
  5458. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5459. // was cleared in this mutation.
  5460. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5461. return false
  5462. }
  5463. // ClearEdge clears the value of the edge with the given name. It returns an error
  5464. // if that edge is not defined in the schema.
  5465. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5466. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5467. }
  5468. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5469. // It returns an error if the edge is not defined in the schema.
  5470. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5471. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5472. }
  5473. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5474. type CategoryMutation struct {
  5475. config
  5476. op Op
  5477. typ string
  5478. id *uint64
  5479. created_at *time.Time
  5480. updated_at *time.Time
  5481. deleted_at *time.Time
  5482. name *string
  5483. organization_id *uint64
  5484. addorganization_id *int64
  5485. clearedFields map[string]struct{}
  5486. done bool
  5487. oldValue func(context.Context) (*Category, error)
  5488. predicates []predicate.Category
  5489. }
  5490. var _ ent.Mutation = (*CategoryMutation)(nil)
  5491. // categoryOption allows management of the mutation configuration using functional options.
  5492. type categoryOption func(*CategoryMutation)
  5493. // newCategoryMutation creates new mutation for the Category entity.
  5494. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5495. m := &CategoryMutation{
  5496. config: c,
  5497. op: op,
  5498. typ: TypeCategory,
  5499. clearedFields: make(map[string]struct{}),
  5500. }
  5501. for _, opt := range opts {
  5502. opt(m)
  5503. }
  5504. return m
  5505. }
  5506. // withCategoryID sets the ID field of the mutation.
  5507. func withCategoryID(id uint64) categoryOption {
  5508. return func(m *CategoryMutation) {
  5509. var (
  5510. err error
  5511. once sync.Once
  5512. value *Category
  5513. )
  5514. m.oldValue = func(ctx context.Context) (*Category, error) {
  5515. once.Do(func() {
  5516. if m.done {
  5517. err = errors.New("querying old values post mutation is not allowed")
  5518. } else {
  5519. value, err = m.Client().Category.Get(ctx, id)
  5520. }
  5521. })
  5522. return value, err
  5523. }
  5524. m.id = &id
  5525. }
  5526. }
  5527. // withCategory sets the old Category of the mutation.
  5528. func withCategory(node *Category) categoryOption {
  5529. return func(m *CategoryMutation) {
  5530. m.oldValue = func(context.Context) (*Category, error) {
  5531. return node, nil
  5532. }
  5533. m.id = &node.ID
  5534. }
  5535. }
  5536. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5537. // executed in a transaction (ent.Tx), a transactional client is returned.
  5538. func (m CategoryMutation) Client() *Client {
  5539. client := &Client{config: m.config}
  5540. client.init()
  5541. return client
  5542. }
  5543. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5544. // it returns an error otherwise.
  5545. func (m CategoryMutation) Tx() (*Tx, error) {
  5546. if _, ok := m.driver.(*txDriver); !ok {
  5547. return nil, errors.New("ent: mutation is not running in a transaction")
  5548. }
  5549. tx := &Tx{config: m.config}
  5550. tx.init()
  5551. return tx, nil
  5552. }
  5553. // SetID sets the value of the id field. Note that this
  5554. // operation is only accepted on creation of Category entities.
  5555. func (m *CategoryMutation) SetID(id uint64) {
  5556. m.id = &id
  5557. }
  5558. // ID returns the ID value in the mutation. Note that the ID is only available
  5559. // if it was provided to the builder or after it was returned from the database.
  5560. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5561. if m.id == nil {
  5562. return
  5563. }
  5564. return *m.id, true
  5565. }
  5566. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5567. // That means, if the mutation is applied within a transaction with an isolation level such
  5568. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5569. // or updated by the mutation.
  5570. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5571. switch {
  5572. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5573. id, exists := m.ID()
  5574. if exists {
  5575. return []uint64{id}, nil
  5576. }
  5577. fallthrough
  5578. case m.op.Is(OpUpdate | OpDelete):
  5579. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5580. default:
  5581. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5582. }
  5583. }
  5584. // SetCreatedAt sets the "created_at" field.
  5585. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5586. m.created_at = &t
  5587. }
  5588. // CreatedAt returns the value of the "created_at" field in the mutation.
  5589. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5590. v := m.created_at
  5591. if v == nil {
  5592. return
  5593. }
  5594. return *v, true
  5595. }
  5596. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5597. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5599. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5600. if !m.op.Is(OpUpdateOne) {
  5601. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5602. }
  5603. if m.id == nil || m.oldValue == nil {
  5604. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5605. }
  5606. oldValue, err := m.oldValue(ctx)
  5607. if err != nil {
  5608. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5609. }
  5610. return oldValue.CreatedAt, nil
  5611. }
  5612. // ResetCreatedAt resets all changes to the "created_at" field.
  5613. func (m *CategoryMutation) ResetCreatedAt() {
  5614. m.created_at = nil
  5615. }
  5616. // SetUpdatedAt sets the "updated_at" field.
  5617. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5618. m.updated_at = &t
  5619. }
  5620. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5621. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5622. v := m.updated_at
  5623. if v == nil {
  5624. return
  5625. }
  5626. return *v, true
  5627. }
  5628. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5629. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5631. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5632. if !m.op.Is(OpUpdateOne) {
  5633. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5634. }
  5635. if m.id == nil || m.oldValue == nil {
  5636. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5637. }
  5638. oldValue, err := m.oldValue(ctx)
  5639. if err != nil {
  5640. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5641. }
  5642. return oldValue.UpdatedAt, nil
  5643. }
  5644. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5645. func (m *CategoryMutation) ResetUpdatedAt() {
  5646. m.updated_at = nil
  5647. }
  5648. // SetDeletedAt sets the "deleted_at" field.
  5649. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5650. m.deleted_at = &t
  5651. }
  5652. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5653. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5654. v := m.deleted_at
  5655. if v == nil {
  5656. return
  5657. }
  5658. return *v, true
  5659. }
  5660. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5661. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5663. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5664. if !m.op.Is(OpUpdateOne) {
  5665. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5666. }
  5667. if m.id == nil || m.oldValue == nil {
  5668. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5669. }
  5670. oldValue, err := m.oldValue(ctx)
  5671. if err != nil {
  5672. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5673. }
  5674. return oldValue.DeletedAt, nil
  5675. }
  5676. // ClearDeletedAt clears the value of the "deleted_at" field.
  5677. func (m *CategoryMutation) ClearDeletedAt() {
  5678. m.deleted_at = nil
  5679. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5680. }
  5681. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5682. func (m *CategoryMutation) DeletedAtCleared() bool {
  5683. _, ok := m.clearedFields[category.FieldDeletedAt]
  5684. return ok
  5685. }
  5686. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5687. func (m *CategoryMutation) ResetDeletedAt() {
  5688. m.deleted_at = nil
  5689. delete(m.clearedFields, category.FieldDeletedAt)
  5690. }
  5691. // SetName sets the "name" field.
  5692. func (m *CategoryMutation) SetName(s string) {
  5693. m.name = &s
  5694. }
  5695. // Name returns the value of the "name" field in the mutation.
  5696. func (m *CategoryMutation) Name() (r string, exists bool) {
  5697. v := m.name
  5698. if v == nil {
  5699. return
  5700. }
  5701. return *v, true
  5702. }
  5703. // OldName returns the old "name" field's value of the Category entity.
  5704. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5706. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5707. if !m.op.Is(OpUpdateOne) {
  5708. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5709. }
  5710. if m.id == nil || m.oldValue == nil {
  5711. return v, errors.New("OldName requires an ID field in the mutation")
  5712. }
  5713. oldValue, err := m.oldValue(ctx)
  5714. if err != nil {
  5715. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5716. }
  5717. return oldValue.Name, nil
  5718. }
  5719. // ResetName resets all changes to the "name" field.
  5720. func (m *CategoryMutation) ResetName() {
  5721. m.name = nil
  5722. }
  5723. // SetOrganizationID sets the "organization_id" field.
  5724. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5725. m.organization_id = &u
  5726. m.addorganization_id = nil
  5727. }
  5728. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5729. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5730. v := m.organization_id
  5731. if v == nil {
  5732. return
  5733. }
  5734. return *v, true
  5735. }
  5736. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5737. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5739. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5740. if !m.op.Is(OpUpdateOne) {
  5741. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5742. }
  5743. if m.id == nil || m.oldValue == nil {
  5744. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5745. }
  5746. oldValue, err := m.oldValue(ctx)
  5747. if err != nil {
  5748. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5749. }
  5750. return oldValue.OrganizationID, nil
  5751. }
  5752. // AddOrganizationID adds u to the "organization_id" field.
  5753. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5754. if m.addorganization_id != nil {
  5755. *m.addorganization_id += u
  5756. } else {
  5757. m.addorganization_id = &u
  5758. }
  5759. }
  5760. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5761. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5762. v := m.addorganization_id
  5763. if v == nil {
  5764. return
  5765. }
  5766. return *v, true
  5767. }
  5768. // ResetOrganizationID resets all changes to the "organization_id" field.
  5769. func (m *CategoryMutation) ResetOrganizationID() {
  5770. m.organization_id = nil
  5771. m.addorganization_id = nil
  5772. }
  5773. // Where appends a list predicates to the CategoryMutation builder.
  5774. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5775. m.predicates = append(m.predicates, ps...)
  5776. }
  5777. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5778. // users can use type-assertion to append predicates that do not depend on any generated package.
  5779. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5780. p := make([]predicate.Category, len(ps))
  5781. for i := range ps {
  5782. p[i] = ps[i]
  5783. }
  5784. m.Where(p...)
  5785. }
  5786. // Op returns the operation name.
  5787. func (m *CategoryMutation) Op() Op {
  5788. return m.op
  5789. }
  5790. // SetOp allows setting the mutation operation.
  5791. func (m *CategoryMutation) SetOp(op Op) {
  5792. m.op = op
  5793. }
  5794. // Type returns the node type of this mutation (Category).
  5795. func (m *CategoryMutation) Type() string {
  5796. return m.typ
  5797. }
  5798. // Fields returns all fields that were changed during this mutation. Note that in
  5799. // order to get all numeric fields that were incremented/decremented, call
  5800. // AddedFields().
  5801. func (m *CategoryMutation) Fields() []string {
  5802. fields := make([]string, 0, 5)
  5803. if m.created_at != nil {
  5804. fields = append(fields, category.FieldCreatedAt)
  5805. }
  5806. if m.updated_at != nil {
  5807. fields = append(fields, category.FieldUpdatedAt)
  5808. }
  5809. if m.deleted_at != nil {
  5810. fields = append(fields, category.FieldDeletedAt)
  5811. }
  5812. if m.name != nil {
  5813. fields = append(fields, category.FieldName)
  5814. }
  5815. if m.organization_id != nil {
  5816. fields = append(fields, category.FieldOrganizationID)
  5817. }
  5818. return fields
  5819. }
  5820. // Field returns the value of a field with the given name. The second boolean
  5821. // return value indicates that this field was not set, or was not defined in the
  5822. // schema.
  5823. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5824. switch name {
  5825. case category.FieldCreatedAt:
  5826. return m.CreatedAt()
  5827. case category.FieldUpdatedAt:
  5828. return m.UpdatedAt()
  5829. case category.FieldDeletedAt:
  5830. return m.DeletedAt()
  5831. case category.FieldName:
  5832. return m.Name()
  5833. case category.FieldOrganizationID:
  5834. return m.OrganizationID()
  5835. }
  5836. return nil, false
  5837. }
  5838. // OldField returns the old value of the field from the database. An error is
  5839. // returned if the mutation operation is not UpdateOne, or the query to the
  5840. // database failed.
  5841. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5842. switch name {
  5843. case category.FieldCreatedAt:
  5844. return m.OldCreatedAt(ctx)
  5845. case category.FieldUpdatedAt:
  5846. return m.OldUpdatedAt(ctx)
  5847. case category.FieldDeletedAt:
  5848. return m.OldDeletedAt(ctx)
  5849. case category.FieldName:
  5850. return m.OldName(ctx)
  5851. case category.FieldOrganizationID:
  5852. return m.OldOrganizationID(ctx)
  5853. }
  5854. return nil, fmt.Errorf("unknown Category field %s", name)
  5855. }
  5856. // SetField sets the value of a field with the given name. It returns an error if
  5857. // the field is not defined in the schema, or if the type mismatched the field
  5858. // type.
  5859. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5860. switch name {
  5861. case category.FieldCreatedAt:
  5862. v, ok := value.(time.Time)
  5863. if !ok {
  5864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5865. }
  5866. m.SetCreatedAt(v)
  5867. return nil
  5868. case category.FieldUpdatedAt:
  5869. v, ok := value.(time.Time)
  5870. if !ok {
  5871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5872. }
  5873. m.SetUpdatedAt(v)
  5874. return nil
  5875. case category.FieldDeletedAt:
  5876. v, ok := value.(time.Time)
  5877. if !ok {
  5878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5879. }
  5880. m.SetDeletedAt(v)
  5881. return nil
  5882. case category.FieldName:
  5883. v, ok := value.(string)
  5884. if !ok {
  5885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5886. }
  5887. m.SetName(v)
  5888. return nil
  5889. case category.FieldOrganizationID:
  5890. v, ok := value.(uint64)
  5891. if !ok {
  5892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5893. }
  5894. m.SetOrganizationID(v)
  5895. return nil
  5896. }
  5897. return fmt.Errorf("unknown Category field %s", name)
  5898. }
  5899. // AddedFields returns all numeric fields that were incremented/decremented during
  5900. // this mutation.
  5901. func (m *CategoryMutation) AddedFields() []string {
  5902. var fields []string
  5903. if m.addorganization_id != nil {
  5904. fields = append(fields, category.FieldOrganizationID)
  5905. }
  5906. return fields
  5907. }
  5908. // AddedField returns the numeric value that was incremented/decremented on a field
  5909. // with the given name. The second boolean return value indicates that this field
  5910. // was not set, or was not defined in the schema.
  5911. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5912. switch name {
  5913. case category.FieldOrganizationID:
  5914. return m.AddedOrganizationID()
  5915. }
  5916. return nil, false
  5917. }
  5918. // AddField adds the value to the field with the given name. It returns an error if
  5919. // the field is not defined in the schema, or if the type mismatched the field
  5920. // type.
  5921. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5922. switch name {
  5923. case category.FieldOrganizationID:
  5924. v, ok := value.(int64)
  5925. if !ok {
  5926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5927. }
  5928. m.AddOrganizationID(v)
  5929. return nil
  5930. }
  5931. return fmt.Errorf("unknown Category numeric field %s", name)
  5932. }
  5933. // ClearedFields returns all nullable fields that were cleared during this
  5934. // mutation.
  5935. func (m *CategoryMutation) ClearedFields() []string {
  5936. var fields []string
  5937. if m.FieldCleared(category.FieldDeletedAt) {
  5938. fields = append(fields, category.FieldDeletedAt)
  5939. }
  5940. return fields
  5941. }
  5942. // FieldCleared returns a boolean indicating if a field with the given name was
  5943. // cleared in this mutation.
  5944. func (m *CategoryMutation) FieldCleared(name string) bool {
  5945. _, ok := m.clearedFields[name]
  5946. return ok
  5947. }
  5948. // ClearField clears the value of the field with the given name. It returns an
  5949. // error if the field is not defined in the schema.
  5950. func (m *CategoryMutation) ClearField(name string) error {
  5951. switch name {
  5952. case category.FieldDeletedAt:
  5953. m.ClearDeletedAt()
  5954. return nil
  5955. }
  5956. return fmt.Errorf("unknown Category nullable field %s", name)
  5957. }
  5958. // ResetField resets all changes in the mutation for the field with the given name.
  5959. // It returns an error if the field is not defined in the schema.
  5960. func (m *CategoryMutation) ResetField(name string) error {
  5961. switch name {
  5962. case category.FieldCreatedAt:
  5963. m.ResetCreatedAt()
  5964. return nil
  5965. case category.FieldUpdatedAt:
  5966. m.ResetUpdatedAt()
  5967. return nil
  5968. case category.FieldDeletedAt:
  5969. m.ResetDeletedAt()
  5970. return nil
  5971. case category.FieldName:
  5972. m.ResetName()
  5973. return nil
  5974. case category.FieldOrganizationID:
  5975. m.ResetOrganizationID()
  5976. return nil
  5977. }
  5978. return fmt.Errorf("unknown Category field %s", name)
  5979. }
  5980. // AddedEdges returns all edge names that were set/added in this mutation.
  5981. func (m *CategoryMutation) AddedEdges() []string {
  5982. edges := make([]string, 0, 0)
  5983. return edges
  5984. }
  5985. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5986. // name in this mutation.
  5987. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5988. return nil
  5989. }
  5990. // RemovedEdges returns all edge names that were removed in this mutation.
  5991. func (m *CategoryMutation) RemovedEdges() []string {
  5992. edges := make([]string, 0, 0)
  5993. return edges
  5994. }
  5995. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5996. // the given name in this mutation.
  5997. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5998. return nil
  5999. }
  6000. // ClearedEdges returns all edge names that were cleared in this mutation.
  6001. func (m *CategoryMutation) ClearedEdges() []string {
  6002. edges := make([]string, 0, 0)
  6003. return edges
  6004. }
  6005. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6006. // was cleared in this mutation.
  6007. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6008. return false
  6009. }
  6010. // ClearEdge clears the value of the edge with the given name. It returns an error
  6011. // if that edge is not defined in the schema.
  6012. func (m *CategoryMutation) ClearEdge(name string) error {
  6013. return fmt.Errorf("unknown Category unique edge %s", name)
  6014. }
  6015. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6016. // It returns an error if the edge is not defined in the schema.
  6017. func (m *CategoryMutation) ResetEdge(name string) error {
  6018. return fmt.Errorf("unknown Category edge %s", name)
  6019. }
  6020. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6021. type ChatRecordsMutation struct {
  6022. config
  6023. op Op
  6024. typ string
  6025. id *uint64
  6026. created_at *time.Time
  6027. updated_at *time.Time
  6028. deleted_at *time.Time
  6029. content *string
  6030. content_type *uint8
  6031. addcontent_type *int8
  6032. session_id *uint64
  6033. addsession_id *int64
  6034. user_id *uint64
  6035. adduser_id *int64
  6036. bot_id *uint64
  6037. addbot_id *int64
  6038. bot_type *uint8
  6039. addbot_type *int8
  6040. clearedFields map[string]struct{}
  6041. done bool
  6042. oldValue func(context.Context) (*ChatRecords, error)
  6043. predicates []predicate.ChatRecords
  6044. }
  6045. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6046. // chatrecordsOption allows management of the mutation configuration using functional options.
  6047. type chatrecordsOption func(*ChatRecordsMutation)
  6048. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6049. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6050. m := &ChatRecordsMutation{
  6051. config: c,
  6052. op: op,
  6053. typ: TypeChatRecords,
  6054. clearedFields: make(map[string]struct{}),
  6055. }
  6056. for _, opt := range opts {
  6057. opt(m)
  6058. }
  6059. return m
  6060. }
  6061. // withChatRecordsID sets the ID field of the mutation.
  6062. func withChatRecordsID(id uint64) chatrecordsOption {
  6063. return func(m *ChatRecordsMutation) {
  6064. var (
  6065. err error
  6066. once sync.Once
  6067. value *ChatRecords
  6068. )
  6069. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6070. once.Do(func() {
  6071. if m.done {
  6072. err = errors.New("querying old values post mutation is not allowed")
  6073. } else {
  6074. value, err = m.Client().ChatRecords.Get(ctx, id)
  6075. }
  6076. })
  6077. return value, err
  6078. }
  6079. m.id = &id
  6080. }
  6081. }
  6082. // withChatRecords sets the old ChatRecords of the mutation.
  6083. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6084. return func(m *ChatRecordsMutation) {
  6085. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6086. return node, nil
  6087. }
  6088. m.id = &node.ID
  6089. }
  6090. }
  6091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6092. // executed in a transaction (ent.Tx), a transactional client is returned.
  6093. func (m ChatRecordsMutation) Client() *Client {
  6094. client := &Client{config: m.config}
  6095. client.init()
  6096. return client
  6097. }
  6098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6099. // it returns an error otherwise.
  6100. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6101. if _, ok := m.driver.(*txDriver); !ok {
  6102. return nil, errors.New("ent: mutation is not running in a transaction")
  6103. }
  6104. tx := &Tx{config: m.config}
  6105. tx.init()
  6106. return tx, nil
  6107. }
  6108. // SetID sets the value of the id field. Note that this
  6109. // operation is only accepted on creation of ChatRecords entities.
  6110. func (m *ChatRecordsMutation) SetID(id uint64) {
  6111. m.id = &id
  6112. }
  6113. // ID returns the ID value in the mutation. Note that the ID is only available
  6114. // if it was provided to the builder or after it was returned from the database.
  6115. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6116. if m.id == nil {
  6117. return
  6118. }
  6119. return *m.id, true
  6120. }
  6121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6122. // That means, if the mutation is applied within a transaction with an isolation level such
  6123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6124. // or updated by the mutation.
  6125. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6126. switch {
  6127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6128. id, exists := m.ID()
  6129. if exists {
  6130. return []uint64{id}, nil
  6131. }
  6132. fallthrough
  6133. case m.op.Is(OpUpdate | OpDelete):
  6134. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6135. default:
  6136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6137. }
  6138. }
  6139. // SetCreatedAt sets the "created_at" field.
  6140. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6141. m.created_at = &t
  6142. }
  6143. // CreatedAt returns the value of the "created_at" field in the mutation.
  6144. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6145. v := m.created_at
  6146. if v == nil {
  6147. return
  6148. }
  6149. return *v, true
  6150. }
  6151. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6152. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6154. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6155. if !m.op.Is(OpUpdateOne) {
  6156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6157. }
  6158. if m.id == nil || m.oldValue == nil {
  6159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6160. }
  6161. oldValue, err := m.oldValue(ctx)
  6162. if err != nil {
  6163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6164. }
  6165. return oldValue.CreatedAt, nil
  6166. }
  6167. // ResetCreatedAt resets all changes to the "created_at" field.
  6168. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6169. m.created_at = nil
  6170. }
  6171. // SetUpdatedAt sets the "updated_at" field.
  6172. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6173. m.updated_at = &t
  6174. }
  6175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6176. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6177. v := m.updated_at
  6178. if v == nil {
  6179. return
  6180. }
  6181. return *v, true
  6182. }
  6183. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6184. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6186. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6187. if !m.op.Is(OpUpdateOne) {
  6188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6189. }
  6190. if m.id == nil || m.oldValue == nil {
  6191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6192. }
  6193. oldValue, err := m.oldValue(ctx)
  6194. if err != nil {
  6195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6196. }
  6197. return oldValue.UpdatedAt, nil
  6198. }
  6199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6200. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6201. m.updated_at = nil
  6202. }
  6203. // SetDeletedAt sets the "deleted_at" field.
  6204. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6205. m.deleted_at = &t
  6206. }
  6207. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6208. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6209. v := m.deleted_at
  6210. if v == nil {
  6211. return
  6212. }
  6213. return *v, true
  6214. }
  6215. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6216. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6218. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6219. if !m.op.Is(OpUpdateOne) {
  6220. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6221. }
  6222. if m.id == nil || m.oldValue == nil {
  6223. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6224. }
  6225. oldValue, err := m.oldValue(ctx)
  6226. if err != nil {
  6227. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6228. }
  6229. return oldValue.DeletedAt, nil
  6230. }
  6231. // ClearDeletedAt clears the value of the "deleted_at" field.
  6232. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6233. m.deleted_at = nil
  6234. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6235. }
  6236. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6237. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6238. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6239. return ok
  6240. }
  6241. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6242. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6243. m.deleted_at = nil
  6244. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6245. }
  6246. // SetContent sets the "content" field.
  6247. func (m *ChatRecordsMutation) SetContent(s string) {
  6248. m.content = &s
  6249. }
  6250. // Content returns the value of the "content" field in the mutation.
  6251. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6252. v := m.content
  6253. if v == nil {
  6254. return
  6255. }
  6256. return *v, true
  6257. }
  6258. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6259. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6261. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6262. if !m.op.Is(OpUpdateOne) {
  6263. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6264. }
  6265. if m.id == nil || m.oldValue == nil {
  6266. return v, errors.New("OldContent requires an ID field in the mutation")
  6267. }
  6268. oldValue, err := m.oldValue(ctx)
  6269. if err != nil {
  6270. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6271. }
  6272. return oldValue.Content, nil
  6273. }
  6274. // ResetContent resets all changes to the "content" field.
  6275. func (m *ChatRecordsMutation) ResetContent() {
  6276. m.content = nil
  6277. }
  6278. // SetContentType sets the "content_type" field.
  6279. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6280. m.content_type = &u
  6281. m.addcontent_type = nil
  6282. }
  6283. // ContentType returns the value of the "content_type" field in the mutation.
  6284. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6285. v := m.content_type
  6286. if v == nil {
  6287. return
  6288. }
  6289. return *v, true
  6290. }
  6291. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6292. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6294. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6295. if !m.op.Is(OpUpdateOne) {
  6296. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6297. }
  6298. if m.id == nil || m.oldValue == nil {
  6299. return v, errors.New("OldContentType requires an ID field in the mutation")
  6300. }
  6301. oldValue, err := m.oldValue(ctx)
  6302. if err != nil {
  6303. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6304. }
  6305. return oldValue.ContentType, nil
  6306. }
  6307. // AddContentType adds u to the "content_type" field.
  6308. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6309. if m.addcontent_type != nil {
  6310. *m.addcontent_type += u
  6311. } else {
  6312. m.addcontent_type = &u
  6313. }
  6314. }
  6315. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6316. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6317. v := m.addcontent_type
  6318. if v == nil {
  6319. return
  6320. }
  6321. return *v, true
  6322. }
  6323. // ResetContentType resets all changes to the "content_type" field.
  6324. func (m *ChatRecordsMutation) ResetContentType() {
  6325. m.content_type = nil
  6326. m.addcontent_type = nil
  6327. }
  6328. // SetSessionID sets the "session_id" field.
  6329. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6330. m.session_id = &u
  6331. m.addsession_id = nil
  6332. }
  6333. // SessionID returns the value of the "session_id" field in the mutation.
  6334. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6335. v := m.session_id
  6336. if v == nil {
  6337. return
  6338. }
  6339. return *v, true
  6340. }
  6341. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6342. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6344. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6345. if !m.op.Is(OpUpdateOne) {
  6346. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6347. }
  6348. if m.id == nil || m.oldValue == nil {
  6349. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6350. }
  6351. oldValue, err := m.oldValue(ctx)
  6352. if err != nil {
  6353. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6354. }
  6355. return oldValue.SessionID, nil
  6356. }
  6357. // AddSessionID adds u to the "session_id" field.
  6358. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6359. if m.addsession_id != nil {
  6360. *m.addsession_id += u
  6361. } else {
  6362. m.addsession_id = &u
  6363. }
  6364. }
  6365. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6366. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6367. v := m.addsession_id
  6368. if v == nil {
  6369. return
  6370. }
  6371. return *v, true
  6372. }
  6373. // ResetSessionID resets all changes to the "session_id" field.
  6374. func (m *ChatRecordsMutation) ResetSessionID() {
  6375. m.session_id = nil
  6376. m.addsession_id = nil
  6377. }
  6378. // SetUserID sets the "user_id" field.
  6379. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6380. m.user_id = &u
  6381. m.adduser_id = nil
  6382. }
  6383. // UserID returns the value of the "user_id" field in the mutation.
  6384. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6385. v := m.user_id
  6386. if v == nil {
  6387. return
  6388. }
  6389. return *v, true
  6390. }
  6391. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6392. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6394. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6395. if !m.op.Is(OpUpdateOne) {
  6396. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6397. }
  6398. if m.id == nil || m.oldValue == nil {
  6399. return v, errors.New("OldUserID requires an ID field in the mutation")
  6400. }
  6401. oldValue, err := m.oldValue(ctx)
  6402. if err != nil {
  6403. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6404. }
  6405. return oldValue.UserID, nil
  6406. }
  6407. // AddUserID adds u to the "user_id" field.
  6408. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6409. if m.adduser_id != nil {
  6410. *m.adduser_id += u
  6411. } else {
  6412. m.adduser_id = &u
  6413. }
  6414. }
  6415. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6416. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6417. v := m.adduser_id
  6418. if v == nil {
  6419. return
  6420. }
  6421. return *v, true
  6422. }
  6423. // ResetUserID resets all changes to the "user_id" field.
  6424. func (m *ChatRecordsMutation) ResetUserID() {
  6425. m.user_id = nil
  6426. m.adduser_id = nil
  6427. }
  6428. // SetBotID sets the "bot_id" field.
  6429. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6430. m.bot_id = &u
  6431. m.addbot_id = nil
  6432. }
  6433. // BotID returns the value of the "bot_id" field in the mutation.
  6434. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6435. v := m.bot_id
  6436. if v == nil {
  6437. return
  6438. }
  6439. return *v, true
  6440. }
  6441. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6442. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6444. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6445. if !m.op.Is(OpUpdateOne) {
  6446. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6447. }
  6448. if m.id == nil || m.oldValue == nil {
  6449. return v, errors.New("OldBotID requires an ID field in the mutation")
  6450. }
  6451. oldValue, err := m.oldValue(ctx)
  6452. if err != nil {
  6453. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6454. }
  6455. return oldValue.BotID, nil
  6456. }
  6457. // AddBotID adds u to the "bot_id" field.
  6458. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6459. if m.addbot_id != nil {
  6460. *m.addbot_id += u
  6461. } else {
  6462. m.addbot_id = &u
  6463. }
  6464. }
  6465. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6466. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6467. v := m.addbot_id
  6468. if v == nil {
  6469. return
  6470. }
  6471. return *v, true
  6472. }
  6473. // ResetBotID resets all changes to the "bot_id" field.
  6474. func (m *ChatRecordsMutation) ResetBotID() {
  6475. m.bot_id = nil
  6476. m.addbot_id = nil
  6477. }
  6478. // SetBotType sets the "bot_type" field.
  6479. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6480. m.bot_type = &u
  6481. m.addbot_type = nil
  6482. }
  6483. // BotType returns the value of the "bot_type" field in the mutation.
  6484. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6485. v := m.bot_type
  6486. if v == nil {
  6487. return
  6488. }
  6489. return *v, true
  6490. }
  6491. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6492. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6494. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6495. if !m.op.Is(OpUpdateOne) {
  6496. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6497. }
  6498. if m.id == nil || m.oldValue == nil {
  6499. return v, errors.New("OldBotType requires an ID field in the mutation")
  6500. }
  6501. oldValue, err := m.oldValue(ctx)
  6502. if err != nil {
  6503. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6504. }
  6505. return oldValue.BotType, nil
  6506. }
  6507. // AddBotType adds u to the "bot_type" field.
  6508. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6509. if m.addbot_type != nil {
  6510. *m.addbot_type += u
  6511. } else {
  6512. m.addbot_type = &u
  6513. }
  6514. }
  6515. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6516. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6517. v := m.addbot_type
  6518. if v == nil {
  6519. return
  6520. }
  6521. return *v, true
  6522. }
  6523. // ResetBotType resets all changes to the "bot_type" field.
  6524. func (m *ChatRecordsMutation) ResetBotType() {
  6525. m.bot_type = nil
  6526. m.addbot_type = nil
  6527. }
  6528. // Where appends a list predicates to the ChatRecordsMutation builder.
  6529. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6530. m.predicates = append(m.predicates, ps...)
  6531. }
  6532. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6533. // users can use type-assertion to append predicates that do not depend on any generated package.
  6534. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6535. p := make([]predicate.ChatRecords, len(ps))
  6536. for i := range ps {
  6537. p[i] = ps[i]
  6538. }
  6539. m.Where(p...)
  6540. }
  6541. // Op returns the operation name.
  6542. func (m *ChatRecordsMutation) Op() Op {
  6543. return m.op
  6544. }
  6545. // SetOp allows setting the mutation operation.
  6546. func (m *ChatRecordsMutation) SetOp(op Op) {
  6547. m.op = op
  6548. }
  6549. // Type returns the node type of this mutation (ChatRecords).
  6550. func (m *ChatRecordsMutation) Type() string {
  6551. return m.typ
  6552. }
  6553. // Fields returns all fields that were changed during this mutation. Note that in
  6554. // order to get all numeric fields that were incremented/decremented, call
  6555. // AddedFields().
  6556. func (m *ChatRecordsMutation) Fields() []string {
  6557. fields := make([]string, 0, 9)
  6558. if m.created_at != nil {
  6559. fields = append(fields, chatrecords.FieldCreatedAt)
  6560. }
  6561. if m.updated_at != nil {
  6562. fields = append(fields, chatrecords.FieldUpdatedAt)
  6563. }
  6564. if m.deleted_at != nil {
  6565. fields = append(fields, chatrecords.FieldDeletedAt)
  6566. }
  6567. if m.content != nil {
  6568. fields = append(fields, chatrecords.FieldContent)
  6569. }
  6570. if m.content_type != nil {
  6571. fields = append(fields, chatrecords.FieldContentType)
  6572. }
  6573. if m.session_id != nil {
  6574. fields = append(fields, chatrecords.FieldSessionID)
  6575. }
  6576. if m.user_id != nil {
  6577. fields = append(fields, chatrecords.FieldUserID)
  6578. }
  6579. if m.bot_id != nil {
  6580. fields = append(fields, chatrecords.FieldBotID)
  6581. }
  6582. if m.bot_type != nil {
  6583. fields = append(fields, chatrecords.FieldBotType)
  6584. }
  6585. return fields
  6586. }
  6587. // Field returns the value of a field with the given name. The second boolean
  6588. // return value indicates that this field was not set, or was not defined in the
  6589. // schema.
  6590. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6591. switch name {
  6592. case chatrecords.FieldCreatedAt:
  6593. return m.CreatedAt()
  6594. case chatrecords.FieldUpdatedAt:
  6595. return m.UpdatedAt()
  6596. case chatrecords.FieldDeletedAt:
  6597. return m.DeletedAt()
  6598. case chatrecords.FieldContent:
  6599. return m.Content()
  6600. case chatrecords.FieldContentType:
  6601. return m.ContentType()
  6602. case chatrecords.FieldSessionID:
  6603. return m.SessionID()
  6604. case chatrecords.FieldUserID:
  6605. return m.UserID()
  6606. case chatrecords.FieldBotID:
  6607. return m.BotID()
  6608. case chatrecords.FieldBotType:
  6609. return m.BotType()
  6610. }
  6611. return nil, false
  6612. }
  6613. // OldField returns the old value of the field from the database. An error is
  6614. // returned if the mutation operation is not UpdateOne, or the query to the
  6615. // database failed.
  6616. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6617. switch name {
  6618. case chatrecords.FieldCreatedAt:
  6619. return m.OldCreatedAt(ctx)
  6620. case chatrecords.FieldUpdatedAt:
  6621. return m.OldUpdatedAt(ctx)
  6622. case chatrecords.FieldDeletedAt:
  6623. return m.OldDeletedAt(ctx)
  6624. case chatrecords.FieldContent:
  6625. return m.OldContent(ctx)
  6626. case chatrecords.FieldContentType:
  6627. return m.OldContentType(ctx)
  6628. case chatrecords.FieldSessionID:
  6629. return m.OldSessionID(ctx)
  6630. case chatrecords.FieldUserID:
  6631. return m.OldUserID(ctx)
  6632. case chatrecords.FieldBotID:
  6633. return m.OldBotID(ctx)
  6634. case chatrecords.FieldBotType:
  6635. return m.OldBotType(ctx)
  6636. }
  6637. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6638. }
  6639. // SetField sets the value of a field with the given name. It returns an error if
  6640. // the field is not defined in the schema, or if the type mismatched the field
  6641. // type.
  6642. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6643. switch name {
  6644. case chatrecords.FieldCreatedAt:
  6645. v, ok := value.(time.Time)
  6646. if !ok {
  6647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6648. }
  6649. m.SetCreatedAt(v)
  6650. return nil
  6651. case chatrecords.FieldUpdatedAt:
  6652. v, ok := value.(time.Time)
  6653. if !ok {
  6654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6655. }
  6656. m.SetUpdatedAt(v)
  6657. return nil
  6658. case chatrecords.FieldDeletedAt:
  6659. v, ok := value.(time.Time)
  6660. if !ok {
  6661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6662. }
  6663. m.SetDeletedAt(v)
  6664. return nil
  6665. case chatrecords.FieldContent:
  6666. v, ok := value.(string)
  6667. if !ok {
  6668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6669. }
  6670. m.SetContent(v)
  6671. return nil
  6672. case chatrecords.FieldContentType:
  6673. v, ok := value.(uint8)
  6674. if !ok {
  6675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6676. }
  6677. m.SetContentType(v)
  6678. return nil
  6679. case chatrecords.FieldSessionID:
  6680. v, ok := value.(uint64)
  6681. if !ok {
  6682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6683. }
  6684. m.SetSessionID(v)
  6685. return nil
  6686. case chatrecords.FieldUserID:
  6687. v, ok := value.(uint64)
  6688. if !ok {
  6689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6690. }
  6691. m.SetUserID(v)
  6692. return nil
  6693. case chatrecords.FieldBotID:
  6694. v, ok := value.(uint64)
  6695. if !ok {
  6696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6697. }
  6698. m.SetBotID(v)
  6699. return nil
  6700. case chatrecords.FieldBotType:
  6701. v, ok := value.(uint8)
  6702. if !ok {
  6703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6704. }
  6705. m.SetBotType(v)
  6706. return nil
  6707. }
  6708. return fmt.Errorf("unknown ChatRecords field %s", name)
  6709. }
  6710. // AddedFields returns all numeric fields that were incremented/decremented during
  6711. // this mutation.
  6712. func (m *ChatRecordsMutation) AddedFields() []string {
  6713. var fields []string
  6714. if m.addcontent_type != nil {
  6715. fields = append(fields, chatrecords.FieldContentType)
  6716. }
  6717. if m.addsession_id != nil {
  6718. fields = append(fields, chatrecords.FieldSessionID)
  6719. }
  6720. if m.adduser_id != nil {
  6721. fields = append(fields, chatrecords.FieldUserID)
  6722. }
  6723. if m.addbot_id != nil {
  6724. fields = append(fields, chatrecords.FieldBotID)
  6725. }
  6726. if m.addbot_type != nil {
  6727. fields = append(fields, chatrecords.FieldBotType)
  6728. }
  6729. return fields
  6730. }
  6731. // AddedField returns the numeric value that was incremented/decremented on a field
  6732. // with the given name. The second boolean return value indicates that this field
  6733. // was not set, or was not defined in the schema.
  6734. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6735. switch name {
  6736. case chatrecords.FieldContentType:
  6737. return m.AddedContentType()
  6738. case chatrecords.FieldSessionID:
  6739. return m.AddedSessionID()
  6740. case chatrecords.FieldUserID:
  6741. return m.AddedUserID()
  6742. case chatrecords.FieldBotID:
  6743. return m.AddedBotID()
  6744. case chatrecords.FieldBotType:
  6745. return m.AddedBotType()
  6746. }
  6747. return nil, false
  6748. }
  6749. // AddField adds the value to the field with the given name. It returns an error if
  6750. // the field is not defined in the schema, or if the type mismatched the field
  6751. // type.
  6752. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6753. switch name {
  6754. case chatrecords.FieldContentType:
  6755. v, ok := value.(int8)
  6756. if !ok {
  6757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6758. }
  6759. m.AddContentType(v)
  6760. return nil
  6761. case chatrecords.FieldSessionID:
  6762. v, ok := value.(int64)
  6763. if !ok {
  6764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6765. }
  6766. m.AddSessionID(v)
  6767. return nil
  6768. case chatrecords.FieldUserID:
  6769. v, ok := value.(int64)
  6770. if !ok {
  6771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6772. }
  6773. m.AddUserID(v)
  6774. return nil
  6775. case chatrecords.FieldBotID:
  6776. v, ok := value.(int64)
  6777. if !ok {
  6778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6779. }
  6780. m.AddBotID(v)
  6781. return nil
  6782. case chatrecords.FieldBotType:
  6783. v, ok := value.(int8)
  6784. if !ok {
  6785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6786. }
  6787. m.AddBotType(v)
  6788. return nil
  6789. }
  6790. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6791. }
  6792. // ClearedFields returns all nullable fields that were cleared during this
  6793. // mutation.
  6794. func (m *ChatRecordsMutation) ClearedFields() []string {
  6795. var fields []string
  6796. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6797. fields = append(fields, chatrecords.FieldDeletedAt)
  6798. }
  6799. return fields
  6800. }
  6801. // FieldCleared returns a boolean indicating if a field with the given name was
  6802. // cleared in this mutation.
  6803. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6804. _, ok := m.clearedFields[name]
  6805. return ok
  6806. }
  6807. // ClearField clears the value of the field with the given name. It returns an
  6808. // error if the field is not defined in the schema.
  6809. func (m *ChatRecordsMutation) ClearField(name string) error {
  6810. switch name {
  6811. case chatrecords.FieldDeletedAt:
  6812. m.ClearDeletedAt()
  6813. return nil
  6814. }
  6815. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6816. }
  6817. // ResetField resets all changes in the mutation for the field with the given name.
  6818. // It returns an error if the field is not defined in the schema.
  6819. func (m *ChatRecordsMutation) ResetField(name string) error {
  6820. switch name {
  6821. case chatrecords.FieldCreatedAt:
  6822. m.ResetCreatedAt()
  6823. return nil
  6824. case chatrecords.FieldUpdatedAt:
  6825. m.ResetUpdatedAt()
  6826. return nil
  6827. case chatrecords.FieldDeletedAt:
  6828. m.ResetDeletedAt()
  6829. return nil
  6830. case chatrecords.FieldContent:
  6831. m.ResetContent()
  6832. return nil
  6833. case chatrecords.FieldContentType:
  6834. m.ResetContentType()
  6835. return nil
  6836. case chatrecords.FieldSessionID:
  6837. m.ResetSessionID()
  6838. return nil
  6839. case chatrecords.FieldUserID:
  6840. m.ResetUserID()
  6841. return nil
  6842. case chatrecords.FieldBotID:
  6843. m.ResetBotID()
  6844. return nil
  6845. case chatrecords.FieldBotType:
  6846. m.ResetBotType()
  6847. return nil
  6848. }
  6849. return fmt.Errorf("unknown ChatRecords field %s", name)
  6850. }
  6851. // AddedEdges returns all edge names that were set/added in this mutation.
  6852. func (m *ChatRecordsMutation) AddedEdges() []string {
  6853. edges := make([]string, 0, 0)
  6854. return edges
  6855. }
  6856. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6857. // name in this mutation.
  6858. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6859. return nil
  6860. }
  6861. // RemovedEdges returns all edge names that were removed in this mutation.
  6862. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6863. edges := make([]string, 0, 0)
  6864. return edges
  6865. }
  6866. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6867. // the given name in this mutation.
  6868. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6869. return nil
  6870. }
  6871. // ClearedEdges returns all edge names that were cleared in this mutation.
  6872. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6873. edges := make([]string, 0, 0)
  6874. return edges
  6875. }
  6876. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6877. // was cleared in this mutation.
  6878. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6879. return false
  6880. }
  6881. // ClearEdge clears the value of the edge with the given name. It returns an error
  6882. // if that edge is not defined in the schema.
  6883. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6884. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6885. }
  6886. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6887. // It returns an error if the edge is not defined in the schema.
  6888. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6889. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6890. }
  6891. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6892. type ChatSessionMutation struct {
  6893. config
  6894. op Op
  6895. typ string
  6896. id *uint64
  6897. created_at *time.Time
  6898. updated_at *time.Time
  6899. deleted_at *time.Time
  6900. name *string
  6901. user_id *uint64
  6902. adduser_id *int64
  6903. bot_id *uint64
  6904. addbot_id *int64
  6905. bot_type *uint8
  6906. addbot_type *int8
  6907. clearedFields map[string]struct{}
  6908. done bool
  6909. oldValue func(context.Context) (*ChatSession, error)
  6910. predicates []predicate.ChatSession
  6911. }
  6912. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6913. // chatsessionOption allows management of the mutation configuration using functional options.
  6914. type chatsessionOption func(*ChatSessionMutation)
  6915. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6916. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6917. m := &ChatSessionMutation{
  6918. config: c,
  6919. op: op,
  6920. typ: TypeChatSession,
  6921. clearedFields: make(map[string]struct{}),
  6922. }
  6923. for _, opt := range opts {
  6924. opt(m)
  6925. }
  6926. return m
  6927. }
  6928. // withChatSessionID sets the ID field of the mutation.
  6929. func withChatSessionID(id uint64) chatsessionOption {
  6930. return func(m *ChatSessionMutation) {
  6931. var (
  6932. err error
  6933. once sync.Once
  6934. value *ChatSession
  6935. )
  6936. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6937. once.Do(func() {
  6938. if m.done {
  6939. err = errors.New("querying old values post mutation is not allowed")
  6940. } else {
  6941. value, err = m.Client().ChatSession.Get(ctx, id)
  6942. }
  6943. })
  6944. return value, err
  6945. }
  6946. m.id = &id
  6947. }
  6948. }
  6949. // withChatSession sets the old ChatSession of the mutation.
  6950. func withChatSession(node *ChatSession) chatsessionOption {
  6951. return func(m *ChatSessionMutation) {
  6952. m.oldValue = func(context.Context) (*ChatSession, error) {
  6953. return node, nil
  6954. }
  6955. m.id = &node.ID
  6956. }
  6957. }
  6958. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6959. // executed in a transaction (ent.Tx), a transactional client is returned.
  6960. func (m ChatSessionMutation) Client() *Client {
  6961. client := &Client{config: m.config}
  6962. client.init()
  6963. return client
  6964. }
  6965. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6966. // it returns an error otherwise.
  6967. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6968. if _, ok := m.driver.(*txDriver); !ok {
  6969. return nil, errors.New("ent: mutation is not running in a transaction")
  6970. }
  6971. tx := &Tx{config: m.config}
  6972. tx.init()
  6973. return tx, nil
  6974. }
  6975. // SetID sets the value of the id field. Note that this
  6976. // operation is only accepted on creation of ChatSession entities.
  6977. func (m *ChatSessionMutation) SetID(id uint64) {
  6978. m.id = &id
  6979. }
  6980. // ID returns the ID value in the mutation. Note that the ID is only available
  6981. // if it was provided to the builder or after it was returned from the database.
  6982. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6983. if m.id == nil {
  6984. return
  6985. }
  6986. return *m.id, true
  6987. }
  6988. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6989. // That means, if the mutation is applied within a transaction with an isolation level such
  6990. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6991. // or updated by the mutation.
  6992. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6993. switch {
  6994. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6995. id, exists := m.ID()
  6996. if exists {
  6997. return []uint64{id}, nil
  6998. }
  6999. fallthrough
  7000. case m.op.Is(OpUpdate | OpDelete):
  7001. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7002. default:
  7003. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7004. }
  7005. }
  7006. // SetCreatedAt sets the "created_at" field.
  7007. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7008. m.created_at = &t
  7009. }
  7010. // CreatedAt returns the value of the "created_at" field in the mutation.
  7011. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7012. v := m.created_at
  7013. if v == nil {
  7014. return
  7015. }
  7016. return *v, true
  7017. }
  7018. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7019. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7021. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7022. if !m.op.Is(OpUpdateOne) {
  7023. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7024. }
  7025. if m.id == nil || m.oldValue == nil {
  7026. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7027. }
  7028. oldValue, err := m.oldValue(ctx)
  7029. if err != nil {
  7030. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7031. }
  7032. return oldValue.CreatedAt, nil
  7033. }
  7034. // ResetCreatedAt resets all changes to the "created_at" field.
  7035. func (m *ChatSessionMutation) ResetCreatedAt() {
  7036. m.created_at = nil
  7037. }
  7038. // SetUpdatedAt sets the "updated_at" field.
  7039. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7040. m.updated_at = &t
  7041. }
  7042. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7043. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7044. v := m.updated_at
  7045. if v == nil {
  7046. return
  7047. }
  7048. return *v, true
  7049. }
  7050. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7051. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7053. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7054. if !m.op.Is(OpUpdateOne) {
  7055. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7056. }
  7057. if m.id == nil || m.oldValue == nil {
  7058. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7059. }
  7060. oldValue, err := m.oldValue(ctx)
  7061. if err != nil {
  7062. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7063. }
  7064. return oldValue.UpdatedAt, nil
  7065. }
  7066. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7067. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7068. m.updated_at = nil
  7069. }
  7070. // SetDeletedAt sets the "deleted_at" field.
  7071. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7072. m.deleted_at = &t
  7073. }
  7074. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7075. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7076. v := m.deleted_at
  7077. if v == nil {
  7078. return
  7079. }
  7080. return *v, true
  7081. }
  7082. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7083. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7085. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7086. if !m.op.Is(OpUpdateOne) {
  7087. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7088. }
  7089. if m.id == nil || m.oldValue == nil {
  7090. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7091. }
  7092. oldValue, err := m.oldValue(ctx)
  7093. if err != nil {
  7094. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7095. }
  7096. return oldValue.DeletedAt, nil
  7097. }
  7098. // ClearDeletedAt clears the value of the "deleted_at" field.
  7099. func (m *ChatSessionMutation) ClearDeletedAt() {
  7100. m.deleted_at = nil
  7101. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7102. }
  7103. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7104. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7105. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7106. return ok
  7107. }
  7108. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7109. func (m *ChatSessionMutation) ResetDeletedAt() {
  7110. m.deleted_at = nil
  7111. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7112. }
  7113. // SetName sets the "name" field.
  7114. func (m *ChatSessionMutation) SetName(s string) {
  7115. m.name = &s
  7116. }
  7117. // Name returns the value of the "name" field in the mutation.
  7118. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7119. v := m.name
  7120. if v == nil {
  7121. return
  7122. }
  7123. return *v, true
  7124. }
  7125. // OldName returns the old "name" field's value of the ChatSession entity.
  7126. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7128. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7129. if !m.op.Is(OpUpdateOne) {
  7130. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7131. }
  7132. if m.id == nil || m.oldValue == nil {
  7133. return v, errors.New("OldName requires an ID field in the mutation")
  7134. }
  7135. oldValue, err := m.oldValue(ctx)
  7136. if err != nil {
  7137. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7138. }
  7139. return oldValue.Name, nil
  7140. }
  7141. // ResetName resets all changes to the "name" field.
  7142. func (m *ChatSessionMutation) ResetName() {
  7143. m.name = nil
  7144. }
  7145. // SetUserID sets the "user_id" field.
  7146. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7147. m.user_id = &u
  7148. m.adduser_id = nil
  7149. }
  7150. // UserID returns the value of the "user_id" field in the mutation.
  7151. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7152. v := m.user_id
  7153. if v == nil {
  7154. return
  7155. }
  7156. return *v, true
  7157. }
  7158. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7159. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7161. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7162. if !m.op.Is(OpUpdateOne) {
  7163. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7164. }
  7165. if m.id == nil || m.oldValue == nil {
  7166. return v, errors.New("OldUserID requires an ID field in the mutation")
  7167. }
  7168. oldValue, err := m.oldValue(ctx)
  7169. if err != nil {
  7170. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7171. }
  7172. return oldValue.UserID, nil
  7173. }
  7174. // AddUserID adds u to the "user_id" field.
  7175. func (m *ChatSessionMutation) AddUserID(u int64) {
  7176. if m.adduser_id != nil {
  7177. *m.adduser_id += u
  7178. } else {
  7179. m.adduser_id = &u
  7180. }
  7181. }
  7182. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7183. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7184. v := m.adduser_id
  7185. if v == nil {
  7186. return
  7187. }
  7188. return *v, true
  7189. }
  7190. // ResetUserID resets all changes to the "user_id" field.
  7191. func (m *ChatSessionMutation) ResetUserID() {
  7192. m.user_id = nil
  7193. m.adduser_id = nil
  7194. }
  7195. // SetBotID sets the "bot_id" field.
  7196. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7197. m.bot_id = &u
  7198. m.addbot_id = nil
  7199. }
  7200. // BotID returns the value of the "bot_id" field in the mutation.
  7201. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7202. v := m.bot_id
  7203. if v == nil {
  7204. return
  7205. }
  7206. return *v, true
  7207. }
  7208. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7209. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7211. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7212. if !m.op.Is(OpUpdateOne) {
  7213. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7214. }
  7215. if m.id == nil || m.oldValue == nil {
  7216. return v, errors.New("OldBotID requires an ID field in the mutation")
  7217. }
  7218. oldValue, err := m.oldValue(ctx)
  7219. if err != nil {
  7220. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7221. }
  7222. return oldValue.BotID, nil
  7223. }
  7224. // AddBotID adds u to the "bot_id" field.
  7225. func (m *ChatSessionMutation) AddBotID(u int64) {
  7226. if m.addbot_id != nil {
  7227. *m.addbot_id += u
  7228. } else {
  7229. m.addbot_id = &u
  7230. }
  7231. }
  7232. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7233. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7234. v := m.addbot_id
  7235. if v == nil {
  7236. return
  7237. }
  7238. return *v, true
  7239. }
  7240. // ResetBotID resets all changes to the "bot_id" field.
  7241. func (m *ChatSessionMutation) ResetBotID() {
  7242. m.bot_id = nil
  7243. m.addbot_id = nil
  7244. }
  7245. // SetBotType sets the "bot_type" field.
  7246. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7247. m.bot_type = &u
  7248. m.addbot_type = nil
  7249. }
  7250. // BotType returns the value of the "bot_type" field in the mutation.
  7251. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7252. v := m.bot_type
  7253. if v == nil {
  7254. return
  7255. }
  7256. return *v, true
  7257. }
  7258. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7259. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7261. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7262. if !m.op.Is(OpUpdateOne) {
  7263. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7264. }
  7265. if m.id == nil || m.oldValue == nil {
  7266. return v, errors.New("OldBotType requires an ID field in the mutation")
  7267. }
  7268. oldValue, err := m.oldValue(ctx)
  7269. if err != nil {
  7270. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7271. }
  7272. return oldValue.BotType, nil
  7273. }
  7274. // AddBotType adds u to the "bot_type" field.
  7275. func (m *ChatSessionMutation) AddBotType(u int8) {
  7276. if m.addbot_type != nil {
  7277. *m.addbot_type += u
  7278. } else {
  7279. m.addbot_type = &u
  7280. }
  7281. }
  7282. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7283. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7284. v := m.addbot_type
  7285. if v == nil {
  7286. return
  7287. }
  7288. return *v, true
  7289. }
  7290. // ResetBotType resets all changes to the "bot_type" field.
  7291. func (m *ChatSessionMutation) ResetBotType() {
  7292. m.bot_type = nil
  7293. m.addbot_type = nil
  7294. }
  7295. // Where appends a list predicates to the ChatSessionMutation builder.
  7296. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7297. m.predicates = append(m.predicates, ps...)
  7298. }
  7299. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7300. // users can use type-assertion to append predicates that do not depend on any generated package.
  7301. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7302. p := make([]predicate.ChatSession, len(ps))
  7303. for i := range ps {
  7304. p[i] = ps[i]
  7305. }
  7306. m.Where(p...)
  7307. }
  7308. // Op returns the operation name.
  7309. func (m *ChatSessionMutation) Op() Op {
  7310. return m.op
  7311. }
  7312. // SetOp allows setting the mutation operation.
  7313. func (m *ChatSessionMutation) SetOp(op Op) {
  7314. m.op = op
  7315. }
  7316. // Type returns the node type of this mutation (ChatSession).
  7317. func (m *ChatSessionMutation) Type() string {
  7318. return m.typ
  7319. }
  7320. // Fields returns all fields that were changed during this mutation. Note that in
  7321. // order to get all numeric fields that were incremented/decremented, call
  7322. // AddedFields().
  7323. func (m *ChatSessionMutation) Fields() []string {
  7324. fields := make([]string, 0, 7)
  7325. if m.created_at != nil {
  7326. fields = append(fields, chatsession.FieldCreatedAt)
  7327. }
  7328. if m.updated_at != nil {
  7329. fields = append(fields, chatsession.FieldUpdatedAt)
  7330. }
  7331. if m.deleted_at != nil {
  7332. fields = append(fields, chatsession.FieldDeletedAt)
  7333. }
  7334. if m.name != nil {
  7335. fields = append(fields, chatsession.FieldName)
  7336. }
  7337. if m.user_id != nil {
  7338. fields = append(fields, chatsession.FieldUserID)
  7339. }
  7340. if m.bot_id != nil {
  7341. fields = append(fields, chatsession.FieldBotID)
  7342. }
  7343. if m.bot_type != nil {
  7344. fields = append(fields, chatsession.FieldBotType)
  7345. }
  7346. return fields
  7347. }
  7348. // Field returns the value of a field with the given name. The second boolean
  7349. // return value indicates that this field was not set, or was not defined in the
  7350. // schema.
  7351. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7352. switch name {
  7353. case chatsession.FieldCreatedAt:
  7354. return m.CreatedAt()
  7355. case chatsession.FieldUpdatedAt:
  7356. return m.UpdatedAt()
  7357. case chatsession.FieldDeletedAt:
  7358. return m.DeletedAt()
  7359. case chatsession.FieldName:
  7360. return m.Name()
  7361. case chatsession.FieldUserID:
  7362. return m.UserID()
  7363. case chatsession.FieldBotID:
  7364. return m.BotID()
  7365. case chatsession.FieldBotType:
  7366. return m.BotType()
  7367. }
  7368. return nil, false
  7369. }
  7370. // OldField returns the old value of the field from the database. An error is
  7371. // returned if the mutation operation is not UpdateOne, or the query to the
  7372. // database failed.
  7373. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7374. switch name {
  7375. case chatsession.FieldCreatedAt:
  7376. return m.OldCreatedAt(ctx)
  7377. case chatsession.FieldUpdatedAt:
  7378. return m.OldUpdatedAt(ctx)
  7379. case chatsession.FieldDeletedAt:
  7380. return m.OldDeletedAt(ctx)
  7381. case chatsession.FieldName:
  7382. return m.OldName(ctx)
  7383. case chatsession.FieldUserID:
  7384. return m.OldUserID(ctx)
  7385. case chatsession.FieldBotID:
  7386. return m.OldBotID(ctx)
  7387. case chatsession.FieldBotType:
  7388. return m.OldBotType(ctx)
  7389. }
  7390. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7391. }
  7392. // SetField sets the value of a field with the given name. It returns an error if
  7393. // the field is not defined in the schema, or if the type mismatched the field
  7394. // type.
  7395. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7396. switch name {
  7397. case chatsession.FieldCreatedAt:
  7398. v, ok := value.(time.Time)
  7399. if !ok {
  7400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7401. }
  7402. m.SetCreatedAt(v)
  7403. return nil
  7404. case chatsession.FieldUpdatedAt:
  7405. v, ok := value.(time.Time)
  7406. if !ok {
  7407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7408. }
  7409. m.SetUpdatedAt(v)
  7410. return nil
  7411. case chatsession.FieldDeletedAt:
  7412. v, ok := value.(time.Time)
  7413. if !ok {
  7414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7415. }
  7416. m.SetDeletedAt(v)
  7417. return nil
  7418. case chatsession.FieldName:
  7419. v, ok := value.(string)
  7420. if !ok {
  7421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7422. }
  7423. m.SetName(v)
  7424. return nil
  7425. case chatsession.FieldUserID:
  7426. v, ok := value.(uint64)
  7427. if !ok {
  7428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7429. }
  7430. m.SetUserID(v)
  7431. return nil
  7432. case chatsession.FieldBotID:
  7433. v, ok := value.(uint64)
  7434. if !ok {
  7435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7436. }
  7437. m.SetBotID(v)
  7438. return nil
  7439. case chatsession.FieldBotType:
  7440. v, ok := value.(uint8)
  7441. if !ok {
  7442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7443. }
  7444. m.SetBotType(v)
  7445. return nil
  7446. }
  7447. return fmt.Errorf("unknown ChatSession field %s", name)
  7448. }
  7449. // AddedFields returns all numeric fields that were incremented/decremented during
  7450. // this mutation.
  7451. func (m *ChatSessionMutation) AddedFields() []string {
  7452. var fields []string
  7453. if m.adduser_id != nil {
  7454. fields = append(fields, chatsession.FieldUserID)
  7455. }
  7456. if m.addbot_id != nil {
  7457. fields = append(fields, chatsession.FieldBotID)
  7458. }
  7459. if m.addbot_type != nil {
  7460. fields = append(fields, chatsession.FieldBotType)
  7461. }
  7462. return fields
  7463. }
  7464. // AddedField returns the numeric value that was incremented/decremented on a field
  7465. // with the given name. The second boolean return value indicates that this field
  7466. // was not set, or was not defined in the schema.
  7467. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7468. switch name {
  7469. case chatsession.FieldUserID:
  7470. return m.AddedUserID()
  7471. case chatsession.FieldBotID:
  7472. return m.AddedBotID()
  7473. case chatsession.FieldBotType:
  7474. return m.AddedBotType()
  7475. }
  7476. return nil, false
  7477. }
  7478. // AddField adds the value to the field with the given name. It returns an error if
  7479. // the field is not defined in the schema, or if the type mismatched the field
  7480. // type.
  7481. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7482. switch name {
  7483. case chatsession.FieldUserID:
  7484. v, ok := value.(int64)
  7485. if !ok {
  7486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7487. }
  7488. m.AddUserID(v)
  7489. return nil
  7490. case chatsession.FieldBotID:
  7491. v, ok := value.(int64)
  7492. if !ok {
  7493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7494. }
  7495. m.AddBotID(v)
  7496. return nil
  7497. case chatsession.FieldBotType:
  7498. v, ok := value.(int8)
  7499. if !ok {
  7500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7501. }
  7502. m.AddBotType(v)
  7503. return nil
  7504. }
  7505. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7506. }
  7507. // ClearedFields returns all nullable fields that were cleared during this
  7508. // mutation.
  7509. func (m *ChatSessionMutation) ClearedFields() []string {
  7510. var fields []string
  7511. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7512. fields = append(fields, chatsession.FieldDeletedAt)
  7513. }
  7514. return fields
  7515. }
  7516. // FieldCleared returns a boolean indicating if a field with the given name was
  7517. // cleared in this mutation.
  7518. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7519. _, ok := m.clearedFields[name]
  7520. return ok
  7521. }
  7522. // ClearField clears the value of the field with the given name. It returns an
  7523. // error if the field is not defined in the schema.
  7524. func (m *ChatSessionMutation) ClearField(name string) error {
  7525. switch name {
  7526. case chatsession.FieldDeletedAt:
  7527. m.ClearDeletedAt()
  7528. return nil
  7529. }
  7530. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7531. }
  7532. // ResetField resets all changes in the mutation for the field with the given name.
  7533. // It returns an error if the field is not defined in the schema.
  7534. func (m *ChatSessionMutation) ResetField(name string) error {
  7535. switch name {
  7536. case chatsession.FieldCreatedAt:
  7537. m.ResetCreatedAt()
  7538. return nil
  7539. case chatsession.FieldUpdatedAt:
  7540. m.ResetUpdatedAt()
  7541. return nil
  7542. case chatsession.FieldDeletedAt:
  7543. m.ResetDeletedAt()
  7544. return nil
  7545. case chatsession.FieldName:
  7546. m.ResetName()
  7547. return nil
  7548. case chatsession.FieldUserID:
  7549. m.ResetUserID()
  7550. return nil
  7551. case chatsession.FieldBotID:
  7552. m.ResetBotID()
  7553. return nil
  7554. case chatsession.FieldBotType:
  7555. m.ResetBotType()
  7556. return nil
  7557. }
  7558. return fmt.Errorf("unknown ChatSession field %s", name)
  7559. }
  7560. // AddedEdges returns all edge names that were set/added in this mutation.
  7561. func (m *ChatSessionMutation) AddedEdges() []string {
  7562. edges := make([]string, 0, 0)
  7563. return edges
  7564. }
  7565. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7566. // name in this mutation.
  7567. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7568. return nil
  7569. }
  7570. // RemovedEdges returns all edge names that were removed in this mutation.
  7571. func (m *ChatSessionMutation) RemovedEdges() []string {
  7572. edges := make([]string, 0, 0)
  7573. return edges
  7574. }
  7575. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7576. // the given name in this mutation.
  7577. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7578. return nil
  7579. }
  7580. // ClearedEdges returns all edge names that were cleared in this mutation.
  7581. func (m *ChatSessionMutation) ClearedEdges() []string {
  7582. edges := make([]string, 0, 0)
  7583. return edges
  7584. }
  7585. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7586. // was cleared in this mutation.
  7587. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7588. return false
  7589. }
  7590. // ClearEdge clears the value of the edge with the given name. It returns an error
  7591. // if that edge is not defined in the schema.
  7592. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7593. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7594. }
  7595. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7596. // It returns an error if the edge is not defined in the schema.
  7597. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7598. return fmt.Errorf("unknown ChatSession edge %s", name)
  7599. }
  7600. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7601. type ContactMutation struct {
  7602. config
  7603. op Op
  7604. typ string
  7605. id *uint64
  7606. created_at *time.Time
  7607. updated_at *time.Time
  7608. status *uint8
  7609. addstatus *int8
  7610. deleted_at *time.Time
  7611. wx_wxid *string
  7612. _type *int
  7613. add_type *int
  7614. wxid *string
  7615. account *string
  7616. nickname *string
  7617. markname *string
  7618. headimg *string
  7619. sex *int
  7620. addsex *int
  7621. starrole *string
  7622. dontseeit *int
  7623. adddontseeit *int
  7624. dontseeme *int
  7625. adddontseeme *int
  7626. lag *string
  7627. gid *string
  7628. gname *string
  7629. v3 *string
  7630. organization_id *uint64
  7631. addorganization_id *int64
  7632. clearedFields map[string]struct{}
  7633. contact_relationships map[uint64]struct{}
  7634. removedcontact_relationships map[uint64]struct{}
  7635. clearedcontact_relationships bool
  7636. contact_messages map[uint64]struct{}
  7637. removedcontact_messages map[uint64]struct{}
  7638. clearedcontact_messages bool
  7639. done bool
  7640. oldValue func(context.Context) (*Contact, error)
  7641. predicates []predicate.Contact
  7642. }
  7643. var _ ent.Mutation = (*ContactMutation)(nil)
  7644. // contactOption allows management of the mutation configuration using functional options.
  7645. type contactOption func(*ContactMutation)
  7646. // newContactMutation creates new mutation for the Contact entity.
  7647. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7648. m := &ContactMutation{
  7649. config: c,
  7650. op: op,
  7651. typ: TypeContact,
  7652. clearedFields: make(map[string]struct{}),
  7653. }
  7654. for _, opt := range opts {
  7655. opt(m)
  7656. }
  7657. return m
  7658. }
  7659. // withContactID sets the ID field of the mutation.
  7660. func withContactID(id uint64) contactOption {
  7661. return func(m *ContactMutation) {
  7662. var (
  7663. err error
  7664. once sync.Once
  7665. value *Contact
  7666. )
  7667. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7668. once.Do(func() {
  7669. if m.done {
  7670. err = errors.New("querying old values post mutation is not allowed")
  7671. } else {
  7672. value, err = m.Client().Contact.Get(ctx, id)
  7673. }
  7674. })
  7675. return value, err
  7676. }
  7677. m.id = &id
  7678. }
  7679. }
  7680. // withContact sets the old Contact of the mutation.
  7681. func withContact(node *Contact) contactOption {
  7682. return func(m *ContactMutation) {
  7683. m.oldValue = func(context.Context) (*Contact, error) {
  7684. return node, nil
  7685. }
  7686. m.id = &node.ID
  7687. }
  7688. }
  7689. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7690. // executed in a transaction (ent.Tx), a transactional client is returned.
  7691. func (m ContactMutation) Client() *Client {
  7692. client := &Client{config: m.config}
  7693. client.init()
  7694. return client
  7695. }
  7696. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7697. // it returns an error otherwise.
  7698. func (m ContactMutation) Tx() (*Tx, error) {
  7699. if _, ok := m.driver.(*txDriver); !ok {
  7700. return nil, errors.New("ent: mutation is not running in a transaction")
  7701. }
  7702. tx := &Tx{config: m.config}
  7703. tx.init()
  7704. return tx, nil
  7705. }
  7706. // SetID sets the value of the id field. Note that this
  7707. // operation is only accepted on creation of Contact entities.
  7708. func (m *ContactMutation) SetID(id uint64) {
  7709. m.id = &id
  7710. }
  7711. // ID returns the ID value in the mutation. Note that the ID is only available
  7712. // if it was provided to the builder or after it was returned from the database.
  7713. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7714. if m.id == nil {
  7715. return
  7716. }
  7717. return *m.id, true
  7718. }
  7719. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7720. // That means, if the mutation is applied within a transaction with an isolation level such
  7721. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7722. // or updated by the mutation.
  7723. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7724. switch {
  7725. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7726. id, exists := m.ID()
  7727. if exists {
  7728. return []uint64{id}, nil
  7729. }
  7730. fallthrough
  7731. case m.op.Is(OpUpdate | OpDelete):
  7732. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7733. default:
  7734. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7735. }
  7736. }
  7737. // SetCreatedAt sets the "created_at" field.
  7738. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7739. m.created_at = &t
  7740. }
  7741. // CreatedAt returns the value of the "created_at" field in the mutation.
  7742. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7743. v := m.created_at
  7744. if v == nil {
  7745. return
  7746. }
  7747. return *v, true
  7748. }
  7749. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7750. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7752. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7753. if !m.op.Is(OpUpdateOne) {
  7754. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7755. }
  7756. if m.id == nil || m.oldValue == nil {
  7757. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7758. }
  7759. oldValue, err := m.oldValue(ctx)
  7760. if err != nil {
  7761. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7762. }
  7763. return oldValue.CreatedAt, nil
  7764. }
  7765. // ResetCreatedAt resets all changes to the "created_at" field.
  7766. func (m *ContactMutation) ResetCreatedAt() {
  7767. m.created_at = nil
  7768. }
  7769. // SetUpdatedAt sets the "updated_at" field.
  7770. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7771. m.updated_at = &t
  7772. }
  7773. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7774. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7775. v := m.updated_at
  7776. if v == nil {
  7777. return
  7778. }
  7779. return *v, true
  7780. }
  7781. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7782. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7784. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7785. if !m.op.Is(OpUpdateOne) {
  7786. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7787. }
  7788. if m.id == nil || m.oldValue == nil {
  7789. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7790. }
  7791. oldValue, err := m.oldValue(ctx)
  7792. if err != nil {
  7793. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7794. }
  7795. return oldValue.UpdatedAt, nil
  7796. }
  7797. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7798. func (m *ContactMutation) ResetUpdatedAt() {
  7799. m.updated_at = nil
  7800. }
  7801. // SetStatus sets the "status" field.
  7802. func (m *ContactMutation) SetStatus(u uint8) {
  7803. m.status = &u
  7804. m.addstatus = nil
  7805. }
  7806. // Status returns the value of the "status" field in the mutation.
  7807. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7808. v := m.status
  7809. if v == nil {
  7810. return
  7811. }
  7812. return *v, true
  7813. }
  7814. // OldStatus returns the old "status" field's value of the Contact entity.
  7815. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7817. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7818. if !m.op.Is(OpUpdateOne) {
  7819. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7820. }
  7821. if m.id == nil || m.oldValue == nil {
  7822. return v, errors.New("OldStatus requires an ID field in the mutation")
  7823. }
  7824. oldValue, err := m.oldValue(ctx)
  7825. if err != nil {
  7826. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7827. }
  7828. return oldValue.Status, nil
  7829. }
  7830. // AddStatus adds u to the "status" field.
  7831. func (m *ContactMutation) AddStatus(u int8) {
  7832. if m.addstatus != nil {
  7833. *m.addstatus += u
  7834. } else {
  7835. m.addstatus = &u
  7836. }
  7837. }
  7838. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7839. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7840. v := m.addstatus
  7841. if v == nil {
  7842. return
  7843. }
  7844. return *v, true
  7845. }
  7846. // ClearStatus clears the value of the "status" field.
  7847. func (m *ContactMutation) ClearStatus() {
  7848. m.status = nil
  7849. m.addstatus = nil
  7850. m.clearedFields[contact.FieldStatus] = struct{}{}
  7851. }
  7852. // StatusCleared returns if the "status" field was cleared in this mutation.
  7853. func (m *ContactMutation) StatusCleared() bool {
  7854. _, ok := m.clearedFields[contact.FieldStatus]
  7855. return ok
  7856. }
  7857. // ResetStatus resets all changes to the "status" field.
  7858. func (m *ContactMutation) ResetStatus() {
  7859. m.status = nil
  7860. m.addstatus = nil
  7861. delete(m.clearedFields, contact.FieldStatus)
  7862. }
  7863. // SetDeletedAt sets the "deleted_at" field.
  7864. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7865. m.deleted_at = &t
  7866. }
  7867. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7868. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7869. v := m.deleted_at
  7870. if v == nil {
  7871. return
  7872. }
  7873. return *v, true
  7874. }
  7875. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7876. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7878. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7879. if !m.op.Is(OpUpdateOne) {
  7880. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7881. }
  7882. if m.id == nil || m.oldValue == nil {
  7883. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7884. }
  7885. oldValue, err := m.oldValue(ctx)
  7886. if err != nil {
  7887. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7888. }
  7889. return oldValue.DeletedAt, nil
  7890. }
  7891. // ClearDeletedAt clears the value of the "deleted_at" field.
  7892. func (m *ContactMutation) ClearDeletedAt() {
  7893. m.deleted_at = nil
  7894. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7895. }
  7896. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7897. func (m *ContactMutation) DeletedAtCleared() bool {
  7898. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7899. return ok
  7900. }
  7901. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7902. func (m *ContactMutation) ResetDeletedAt() {
  7903. m.deleted_at = nil
  7904. delete(m.clearedFields, contact.FieldDeletedAt)
  7905. }
  7906. // SetWxWxid sets the "wx_wxid" field.
  7907. func (m *ContactMutation) SetWxWxid(s string) {
  7908. m.wx_wxid = &s
  7909. }
  7910. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7911. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7912. v := m.wx_wxid
  7913. if v == nil {
  7914. return
  7915. }
  7916. return *v, true
  7917. }
  7918. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7919. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7921. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7922. if !m.op.Is(OpUpdateOne) {
  7923. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7924. }
  7925. if m.id == nil || m.oldValue == nil {
  7926. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7927. }
  7928. oldValue, err := m.oldValue(ctx)
  7929. if err != nil {
  7930. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7931. }
  7932. return oldValue.WxWxid, nil
  7933. }
  7934. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7935. func (m *ContactMutation) ResetWxWxid() {
  7936. m.wx_wxid = nil
  7937. }
  7938. // SetType sets the "type" field.
  7939. func (m *ContactMutation) SetType(i int) {
  7940. m._type = &i
  7941. m.add_type = nil
  7942. }
  7943. // GetType returns the value of the "type" field in the mutation.
  7944. func (m *ContactMutation) GetType() (r int, exists bool) {
  7945. v := m._type
  7946. if v == nil {
  7947. return
  7948. }
  7949. return *v, true
  7950. }
  7951. // OldType returns the old "type" field's value of the Contact entity.
  7952. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7954. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7955. if !m.op.Is(OpUpdateOne) {
  7956. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7957. }
  7958. if m.id == nil || m.oldValue == nil {
  7959. return v, errors.New("OldType requires an ID field in the mutation")
  7960. }
  7961. oldValue, err := m.oldValue(ctx)
  7962. if err != nil {
  7963. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7964. }
  7965. return oldValue.Type, nil
  7966. }
  7967. // AddType adds i to the "type" field.
  7968. func (m *ContactMutation) AddType(i int) {
  7969. if m.add_type != nil {
  7970. *m.add_type += i
  7971. } else {
  7972. m.add_type = &i
  7973. }
  7974. }
  7975. // AddedType returns the value that was added to the "type" field in this mutation.
  7976. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7977. v := m.add_type
  7978. if v == nil {
  7979. return
  7980. }
  7981. return *v, true
  7982. }
  7983. // ClearType clears the value of the "type" field.
  7984. func (m *ContactMutation) ClearType() {
  7985. m._type = nil
  7986. m.add_type = nil
  7987. m.clearedFields[contact.FieldType] = struct{}{}
  7988. }
  7989. // TypeCleared returns if the "type" field was cleared in this mutation.
  7990. func (m *ContactMutation) TypeCleared() bool {
  7991. _, ok := m.clearedFields[contact.FieldType]
  7992. return ok
  7993. }
  7994. // ResetType resets all changes to the "type" field.
  7995. func (m *ContactMutation) ResetType() {
  7996. m._type = nil
  7997. m.add_type = nil
  7998. delete(m.clearedFields, contact.FieldType)
  7999. }
  8000. // SetWxid sets the "wxid" field.
  8001. func (m *ContactMutation) SetWxid(s string) {
  8002. m.wxid = &s
  8003. }
  8004. // Wxid returns the value of the "wxid" field in the mutation.
  8005. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8006. v := m.wxid
  8007. if v == nil {
  8008. return
  8009. }
  8010. return *v, true
  8011. }
  8012. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8013. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8015. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8016. if !m.op.Is(OpUpdateOne) {
  8017. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8018. }
  8019. if m.id == nil || m.oldValue == nil {
  8020. return v, errors.New("OldWxid requires an ID field in the mutation")
  8021. }
  8022. oldValue, err := m.oldValue(ctx)
  8023. if err != nil {
  8024. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8025. }
  8026. return oldValue.Wxid, nil
  8027. }
  8028. // ResetWxid resets all changes to the "wxid" field.
  8029. func (m *ContactMutation) ResetWxid() {
  8030. m.wxid = nil
  8031. }
  8032. // SetAccount sets the "account" field.
  8033. func (m *ContactMutation) SetAccount(s string) {
  8034. m.account = &s
  8035. }
  8036. // Account returns the value of the "account" field in the mutation.
  8037. func (m *ContactMutation) Account() (r string, exists bool) {
  8038. v := m.account
  8039. if v == nil {
  8040. return
  8041. }
  8042. return *v, true
  8043. }
  8044. // OldAccount returns the old "account" field's value of the Contact entity.
  8045. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8047. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8048. if !m.op.Is(OpUpdateOne) {
  8049. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8050. }
  8051. if m.id == nil || m.oldValue == nil {
  8052. return v, errors.New("OldAccount requires an ID field in the mutation")
  8053. }
  8054. oldValue, err := m.oldValue(ctx)
  8055. if err != nil {
  8056. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8057. }
  8058. return oldValue.Account, nil
  8059. }
  8060. // ResetAccount resets all changes to the "account" field.
  8061. func (m *ContactMutation) ResetAccount() {
  8062. m.account = nil
  8063. }
  8064. // SetNickname sets the "nickname" field.
  8065. func (m *ContactMutation) SetNickname(s string) {
  8066. m.nickname = &s
  8067. }
  8068. // Nickname returns the value of the "nickname" field in the mutation.
  8069. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8070. v := m.nickname
  8071. if v == nil {
  8072. return
  8073. }
  8074. return *v, true
  8075. }
  8076. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8077. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8079. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8080. if !m.op.Is(OpUpdateOne) {
  8081. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8082. }
  8083. if m.id == nil || m.oldValue == nil {
  8084. return v, errors.New("OldNickname requires an ID field in the mutation")
  8085. }
  8086. oldValue, err := m.oldValue(ctx)
  8087. if err != nil {
  8088. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8089. }
  8090. return oldValue.Nickname, nil
  8091. }
  8092. // ResetNickname resets all changes to the "nickname" field.
  8093. func (m *ContactMutation) ResetNickname() {
  8094. m.nickname = nil
  8095. }
  8096. // SetMarkname sets the "markname" field.
  8097. func (m *ContactMutation) SetMarkname(s string) {
  8098. m.markname = &s
  8099. }
  8100. // Markname returns the value of the "markname" field in the mutation.
  8101. func (m *ContactMutation) Markname() (r string, exists bool) {
  8102. v := m.markname
  8103. if v == nil {
  8104. return
  8105. }
  8106. return *v, true
  8107. }
  8108. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8109. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8111. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8112. if !m.op.Is(OpUpdateOne) {
  8113. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8114. }
  8115. if m.id == nil || m.oldValue == nil {
  8116. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8117. }
  8118. oldValue, err := m.oldValue(ctx)
  8119. if err != nil {
  8120. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8121. }
  8122. return oldValue.Markname, nil
  8123. }
  8124. // ResetMarkname resets all changes to the "markname" field.
  8125. func (m *ContactMutation) ResetMarkname() {
  8126. m.markname = nil
  8127. }
  8128. // SetHeadimg sets the "headimg" field.
  8129. func (m *ContactMutation) SetHeadimg(s string) {
  8130. m.headimg = &s
  8131. }
  8132. // Headimg returns the value of the "headimg" field in the mutation.
  8133. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8134. v := m.headimg
  8135. if v == nil {
  8136. return
  8137. }
  8138. return *v, true
  8139. }
  8140. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8141. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8143. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8144. if !m.op.Is(OpUpdateOne) {
  8145. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8146. }
  8147. if m.id == nil || m.oldValue == nil {
  8148. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8149. }
  8150. oldValue, err := m.oldValue(ctx)
  8151. if err != nil {
  8152. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8153. }
  8154. return oldValue.Headimg, nil
  8155. }
  8156. // ResetHeadimg resets all changes to the "headimg" field.
  8157. func (m *ContactMutation) ResetHeadimg() {
  8158. m.headimg = nil
  8159. }
  8160. // SetSex sets the "sex" field.
  8161. func (m *ContactMutation) SetSex(i int) {
  8162. m.sex = &i
  8163. m.addsex = nil
  8164. }
  8165. // Sex returns the value of the "sex" field in the mutation.
  8166. func (m *ContactMutation) Sex() (r int, exists bool) {
  8167. v := m.sex
  8168. if v == nil {
  8169. return
  8170. }
  8171. return *v, true
  8172. }
  8173. // OldSex returns the old "sex" field's value of the Contact entity.
  8174. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8176. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8177. if !m.op.Is(OpUpdateOne) {
  8178. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8179. }
  8180. if m.id == nil || m.oldValue == nil {
  8181. return v, errors.New("OldSex requires an ID field in the mutation")
  8182. }
  8183. oldValue, err := m.oldValue(ctx)
  8184. if err != nil {
  8185. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8186. }
  8187. return oldValue.Sex, nil
  8188. }
  8189. // AddSex adds i to the "sex" field.
  8190. func (m *ContactMutation) AddSex(i int) {
  8191. if m.addsex != nil {
  8192. *m.addsex += i
  8193. } else {
  8194. m.addsex = &i
  8195. }
  8196. }
  8197. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8198. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8199. v := m.addsex
  8200. if v == nil {
  8201. return
  8202. }
  8203. return *v, true
  8204. }
  8205. // ResetSex resets all changes to the "sex" field.
  8206. func (m *ContactMutation) ResetSex() {
  8207. m.sex = nil
  8208. m.addsex = nil
  8209. }
  8210. // SetStarrole sets the "starrole" field.
  8211. func (m *ContactMutation) SetStarrole(s string) {
  8212. m.starrole = &s
  8213. }
  8214. // Starrole returns the value of the "starrole" field in the mutation.
  8215. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8216. v := m.starrole
  8217. if v == nil {
  8218. return
  8219. }
  8220. return *v, true
  8221. }
  8222. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8223. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8225. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8226. if !m.op.Is(OpUpdateOne) {
  8227. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8228. }
  8229. if m.id == nil || m.oldValue == nil {
  8230. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8231. }
  8232. oldValue, err := m.oldValue(ctx)
  8233. if err != nil {
  8234. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8235. }
  8236. return oldValue.Starrole, nil
  8237. }
  8238. // ResetStarrole resets all changes to the "starrole" field.
  8239. func (m *ContactMutation) ResetStarrole() {
  8240. m.starrole = nil
  8241. }
  8242. // SetDontseeit sets the "dontseeit" field.
  8243. func (m *ContactMutation) SetDontseeit(i int) {
  8244. m.dontseeit = &i
  8245. m.adddontseeit = nil
  8246. }
  8247. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8248. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8249. v := m.dontseeit
  8250. if v == nil {
  8251. return
  8252. }
  8253. return *v, true
  8254. }
  8255. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8256. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8258. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8259. if !m.op.Is(OpUpdateOne) {
  8260. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8261. }
  8262. if m.id == nil || m.oldValue == nil {
  8263. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8264. }
  8265. oldValue, err := m.oldValue(ctx)
  8266. if err != nil {
  8267. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8268. }
  8269. return oldValue.Dontseeit, nil
  8270. }
  8271. // AddDontseeit adds i to the "dontseeit" field.
  8272. func (m *ContactMutation) AddDontseeit(i int) {
  8273. if m.adddontseeit != nil {
  8274. *m.adddontseeit += i
  8275. } else {
  8276. m.adddontseeit = &i
  8277. }
  8278. }
  8279. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8280. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8281. v := m.adddontseeit
  8282. if v == nil {
  8283. return
  8284. }
  8285. return *v, true
  8286. }
  8287. // ResetDontseeit resets all changes to the "dontseeit" field.
  8288. func (m *ContactMutation) ResetDontseeit() {
  8289. m.dontseeit = nil
  8290. m.adddontseeit = nil
  8291. }
  8292. // SetDontseeme sets the "dontseeme" field.
  8293. func (m *ContactMutation) SetDontseeme(i int) {
  8294. m.dontseeme = &i
  8295. m.adddontseeme = nil
  8296. }
  8297. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8298. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8299. v := m.dontseeme
  8300. if v == nil {
  8301. return
  8302. }
  8303. return *v, true
  8304. }
  8305. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8306. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8308. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8309. if !m.op.Is(OpUpdateOne) {
  8310. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8311. }
  8312. if m.id == nil || m.oldValue == nil {
  8313. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8314. }
  8315. oldValue, err := m.oldValue(ctx)
  8316. if err != nil {
  8317. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8318. }
  8319. return oldValue.Dontseeme, nil
  8320. }
  8321. // AddDontseeme adds i to the "dontseeme" field.
  8322. func (m *ContactMutation) AddDontseeme(i int) {
  8323. if m.adddontseeme != nil {
  8324. *m.adddontseeme += i
  8325. } else {
  8326. m.adddontseeme = &i
  8327. }
  8328. }
  8329. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8330. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8331. v := m.adddontseeme
  8332. if v == nil {
  8333. return
  8334. }
  8335. return *v, true
  8336. }
  8337. // ResetDontseeme resets all changes to the "dontseeme" field.
  8338. func (m *ContactMutation) ResetDontseeme() {
  8339. m.dontseeme = nil
  8340. m.adddontseeme = nil
  8341. }
  8342. // SetLag sets the "lag" field.
  8343. func (m *ContactMutation) SetLag(s string) {
  8344. m.lag = &s
  8345. }
  8346. // Lag returns the value of the "lag" field in the mutation.
  8347. func (m *ContactMutation) Lag() (r string, exists bool) {
  8348. v := m.lag
  8349. if v == nil {
  8350. return
  8351. }
  8352. return *v, true
  8353. }
  8354. // OldLag returns the old "lag" field's value of the Contact entity.
  8355. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8357. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8358. if !m.op.Is(OpUpdateOne) {
  8359. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8360. }
  8361. if m.id == nil || m.oldValue == nil {
  8362. return v, errors.New("OldLag requires an ID field in the mutation")
  8363. }
  8364. oldValue, err := m.oldValue(ctx)
  8365. if err != nil {
  8366. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8367. }
  8368. return oldValue.Lag, nil
  8369. }
  8370. // ResetLag resets all changes to the "lag" field.
  8371. func (m *ContactMutation) ResetLag() {
  8372. m.lag = nil
  8373. }
  8374. // SetGid sets the "gid" field.
  8375. func (m *ContactMutation) SetGid(s string) {
  8376. m.gid = &s
  8377. }
  8378. // Gid returns the value of the "gid" field in the mutation.
  8379. func (m *ContactMutation) Gid() (r string, exists bool) {
  8380. v := m.gid
  8381. if v == nil {
  8382. return
  8383. }
  8384. return *v, true
  8385. }
  8386. // OldGid returns the old "gid" field's value of the Contact entity.
  8387. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8389. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8390. if !m.op.Is(OpUpdateOne) {
  8391. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8392. }
  8393. if m.id == nil || m.oldValue == nil {
  8394. return v, errors.New("OldGid requires an ID field in the mutation")
  8395. }
  8396. oldValue, err := m.oldValue(ctx)
  8397. if err != nil {
  8398. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8399. }
  8400. return oldValue.Gid, nil
  8401. }
  8402. // ResetGid resets all changes to the "gid" field.
  8403. func (m *ContactMutation) ResetGid() {
  8404. m.gid = nil
  8405. }
  8406. // SetGname sets the "gname" field.
  8407. func (m *ContactMutation) SetGname(s string) {
  8408. m.gname = &s
  8409. }
  8410. // Gname returns the value of the "gname" field in the mutation.
  8411. func (m *ContactMutation) Gname() (r string, exists bool) {
  8412. v := m.gname
  8413. if v == nil {
  8414. return
  8415. }
  8416. return *v, true
  8417. }
  8418. // OldGname returns the old "gname" field's value of the Contact entity.
  8419. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8421. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8422. if !m.op.Is(OpUpdateOne) {
  8423. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8424. }
  8425. if m.id == nil || m.oldValue == nil {
  8426. return v, errors.New("OldGname requires an ID field in the mutation")
  8427. }
  8428. oldValue, err := m.oldValue(ctx)
  8429. if err != nil {
  8430. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8431. }
  8432. return oldValue.Gname, nil
  8433. }
  8434. // ResetGname resets all changes to the "gname" field.
  8435. func (m *ContactMutation) ResetGname() {
  8436. m.gname = nil
  8437. }
  8438. // SetV3 sets the "v3" field.
  8439. func (m *ContactMutation) SetV3(s string) {
  8440. m.v3 = &s
  8441. }
  8442. // V3 returns the value of the "v3" field in the mutation.
  8443. func (m *ContactMutation) V3() (r string, exists bool) {
  8444. v := m.v3
  8445. if v == nil {
  8446. return
  8447. }
  8448. return *v, true
  8449. }
  8450. // OldV3 returns the old "v3" field's value of the Contact entity.
  8451. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8453. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8454. if !m.op.Is(OpUpdateOne) {
  8455. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8456. }
  8457. if m.id == nil || m.oldValue == nil {
  8458. return v, errors.New("OldV3 requires an ID field in the mutation")
  8459. }
  8460. oldValue, err := m.oldValue(ctx)
  8461. if err != nil {
  8462. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8463. }
  8464. return oldValue.V3, nil
  8465. }
  8466. // ResetV3 resets all changes to the "v3" field.
  8467. func (m *ContactMutation) ResetV3() {
  8468. m.v3 = nil
  8469. }
  8470. // SetOrganizationID sets the "organization_id" field.
  8471. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8472. m.organization_id = &u
  8473. m.addorganization_id = nil
  8474. }
  8475. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8476. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8477. v := m.organization_id
  8478. if v == nil {
  8479. return
  8480. }
  8481. return *v, true
  8482. }
  8483. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8484. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8486. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8487. if !m.op.Is(OpUpdateOne) {
  8488. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8489. }
  8490. if m.id == nil || m.oldValue == nil {
  8491. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8492. }
  8493. oldValue, err := m.oldValue(ctx)
  8494. if err != nil {
  8495. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8496. }
  8497. return oldValue.OrganizationID, nil
  8498. }
  8499. // AddOrganizationID adds u to the "organization_id" field.
  8500. func (m *ContactMutation) AddOrganizationID(u int64) {
  8501. if m.addorganization_id != nil {
  8502. *m.addorganization_id += u
  8503. } else {
  8504. m.addorganization_id = &u
  8505. }
  8506. }
  8507. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8508. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8509. v := m.addorganization_id
  8510. if v == nil {
  8511. return
  8512. }
  8513. return *v, true
  8514. }
  8515. // ClearOrganizationID clears the value of the "organization_id" field.
  8516. func (m *ContactMutation) ClearOrganizationID() {
  8517. m.organization_id = nil
  8518. m.addorganization_id = nil
  8519. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8520. }
  8521. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8522. func (m *ContactMutation) OrganizationIDCleared() bool {
  8523. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8524. return ok
  8525. }
  8526. // ResetOrganizationID resets all changes to the "organization_id" field.
  8527. func (m *ContactMutation) ResetOrganizationID() {
  8528. m.organization_id = nil
  8529. m.addorganization_id = nil
  8530. delete(m.clearedFields, contact.FieldOrganizationID)
  8531. }
  8532. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8533. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8534. if m.contact_relationships == nil {
  8535. m.contact_relationships = make(map[uint64]struct{})
  8536. }
  8537. for i := range ids {
  8538. m.contact_relationships[ids[i]] = struct{}{}
  8539. }
  8540. }
  8541. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8542. func (m *ContactMutation) ClearContactRelationships() {
  8543. m.clearedcontact_relationships = true
  8544. }
  8545. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8546. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8547. return m.clearedcontact_relationships
  8548. }
  8549. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8550. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8551. if m.removedcontact_relationships == nil {
  8552. m.removedcontact_relationships = make(map[uint64]struct{})
  8553. }
  8554. for i := range ids {
  8555. delete(m.contact_relationships, ids[i])
  8556. m.removedcontact_relationships[ids[i]] = struct{}{}
  8557. }
  8558. }
  8559. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8560. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8561. for id := range m.removedcontact_relationships {
  8562. ids = append(ids, id)
  8563. }
  8564. return
  8565. }
  8566. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8567. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8568. for id := range m.contact_relationships {
  8569. ids = append(ids, id)
  8570. }
  8571. return
  8572. }
  8573. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8574. func (m *ContactMutation) ResetContactRelationships() {
  8575. m.contact_relationships = nil
  8576. m.clearedcontact_relationships = false
  8577. m.removedcontact_relationships = nil
  8578. }
  8579. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8580. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8581. if m.contact_messages == nil {
  8582. m.contact_messages = make(map[uint64]struct{})
  8583. }
  8584. for i := range ids {
  8585. m.contact_messages[ids[i]] = struct{}{}
  8586. }
  8587. }
  8588. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8589. func (m *ContactMutation) ClearContactMessages() {
  8590. m.clearedcontact_messages = true
  8591. }
  8592. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8593. func (m *ContactMutation) ContactMessagesCleared() bool {
  8594. return m.clearedcontact_messages
  8595. }
  8596. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8597. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8598. if m.removedcontact_messages == nil {
  8599. m.removedcontact_messages = make(map[uint64]struct{})
  8600. }
  8601. for i := range ids {
  8602. delete(m.contact_messages, ids[i])
  8603. m.removedcontact_messages[ids[i]] = struct{}{}
  8604. }
  8605. }
  8606. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8607. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8608. for id := range m.removedcontact_messages {
  8609. ids = append(ids, id)
  8610. }
  8611. return
  8612. }
  8613. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8614. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8615. for id := range m.contact_messages {
  8616. ids = append(ids, id)
  8617. }
  8618. return
  8619. }
  8620. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8621. func (m *ContactMutation) ResetContactMessages() {
  8622. m.contact_messages = nil
  8623. m.clearedcontact_messages = false
  8624. m.removedcontact_messages = nil
  8625. }
  8626. // Where appends a list predicates to the ContactMutation builder.
  8627. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8628. m.predicates = append(m.predicates, ps...)
  8629. }
  8630. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8631. // users can use type-assertion to append predicates that do not depend on any generated package.
  8632. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8633. p := make([]predicate.Contact, len(ps))
  8634. for i := range ps {
  8635. p[i] = ps[i]
  8636. }
  8637. m.Where(p...)
  8638. }
  8639. // Op returns the operation name.
  8640. func (m *ContactMutation) Op() Op {
  8641. return m.op
  8642. }
  8643. // SetOp allows setting the mutation operation.
  8644. func (m *ContactMutation) SetOp(op Op) {
  8645. m.op = op
  8646. }
  8647. // Type returns the node type of this mutation (Contact).
  8648. func (m *ContactMutation) Type() string {
  8649. return m.typ
  8650. }
  8651. // Fields returns all fields that were changed during this mutation. Note that in
  8652. // order to get all numeric fields that were incremented/decremented, call
  8653. // AddedFields().
  8654. func (m *ContactMutation) Fields() []string {
  8655. fields := make([]string, 0, 20)
  8656. if m.created_at != nil {
  8657. fields = append(fields, contact.FieldCreatedAt)
  8658. }
  8659. if m.updated_at != nil {
  8660. fields = append(fields, contact.FieldUpdatedAt)
  8661. }
  8662. if m.status != nil {
  8663. fields = append(fields, contact.FieldStatus)
  8664. }
  8665. if m.deleted_at != nil {
  8666. fields = append(fields, contact.FieldDeletedAt)
  8667. }
  8668. if m.wx_wxid != nil {
  8669. fields = append(fields, contact.FieldWxWxid)
  8670. }
  8671. if m._type != nil {
  8672. fields = append(fields, contact.FieldType)
  8673. }
  8674. if m.wxid != nil {
  8675. fields = append(fields, contact.FieldWxid)
  8676. }
  8677. if m.account != nil {
  8678. fields = append(fields, contact.FieldAccount)
  8679. }
  8680. if m.nickname != nil {
  8681. fields = append(fields, contact.FieldNickname)
  8682. }
  8683. if m.markname != nil {
  8684. fields = append(fields, contact.FieldMarkname)
  8685. }
  8686. if m.headimg != nil {
  8687. fields = append(fields, contact.FieldHeadimg)
  8688. }
  8689. if m.sex != nil {
  8690. fields = append(fields, contact.FieldSex)
  8691. }
  8692. if m.starrole != nil {
  8693. fields = append(fields, contact.FieldStarrole)
  8694. }
  8695. if m.dontseeit != nil {
  8696. fields = append(fields, contact.FieldDontseeit)
  8697. }
  8698. if m.dontseeme != nil {
  8699. fields = append(fields, contact.FieldDontseeme)
  8700. }
  8701. if m.lag != nil {
  8702. fields = append(fields, contact.FieldLag)
  8703. }
  8704. if m.gid != nil {
  8705. fields = append(fields, contact.FieldGid)
  8706. }
  8707. if m.gname != nil {
  8708. fields = append(fields, contact.FieldGname)
  8709. }
  8710. if m.v3 != nil {
  8711. fields = append(fields, contact.FieldV3)
  8712. }
  8713. if m.organization_id != nil {
  8714. fields = append(fields, contact.FieldOrganizationID)
  8715. }
  8716. return fields
  8717. }
  8718. // Field returns the value of a field with the given name. The second boolean
  8719. // return value indicates that this field was not set, or was not defined in the
  8720. // schema.
  8721. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8722. switch name {
  8723. case contact.FieldCreatedAt:
  8724. return m.CreatedAt()
  8725. case contact.FieldUpdatedAt:
  8726. return m.UpdatedAt()
  8727. case contact.FieldStatus:
  8728. return m.Status()
  8729. case contact.FieldDeletedAt:
  8730. return m.DeletedAt()
  8731. case contact.FieldWxWxid:
  8732. return m.WxWxid()
  8733. case contact.FieldType:
  8734. return m.GetType()
  8735. case contact.FieldWxid:
  8736. return m.Wxid()
  8737. case contact.FieldAccount:
  8738. return m.Account()
  8739. case contact.FieldNickname:
  8740. return m.Nickname()
  8741. case contact.FieldMarkname:
  8742. return m.Markname()
  8743. case contact.FieldHeadimg:
  8744. return m.Headimg()
  8745. case contact.FieldSex:
  8746. return m.Sex()
  8747. case contact.FieldStarrole:
  8748. return m.Starrole()
  8749. case contact.FieldDontseeit:
  8750. return m.Dontseeit()
  8751. case contact.FieldDontseeme:
  8752. return m.Dontseeme()
  8753. case contact.FieldLag:
  8754. return m.Lag()
  8755. case contact.FieldGid:
  8756. return m.Gid()
  8757. case contact.FieldGname:
  8758. return m.Gname()
  8759. case contact.FieldV3:
  8760. return m.V3()
  8761. case contact.FieldOrganizationID:
  8762. return m.OrganizationID()
  8763. }
  8764. return nil, false
  8765. }
  8766. // OldField returns the old value of the field from the database. An error is
  8767. // returned if the mutation operation is not UpdateOne, or the query to the
  8768. // database failed.
  8769. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8770. switch name {
  8771. case contact.FieldCreatedAt:
  8772. return m.OldCreatedAt(ctx)
  8773. case contact.FieldUpdatedAt:
  8774. return m.OldUpdatedAt(ctx)
  8775. case contact.FieldStatus:
  8776. return m.OldStatus(ctx)
  8777. case contact.FieldDeletedAt:
  8778. return m.OldDeletedAt(ctx)
  8779. case contact.FieldWxWxid:
  8780. return m.OldWxWxid(ctx)
  8781. case contact.FieldType:
  8782. return m.OldType(ctx)
  8783. case contact.FieldWxid:
  8784. return m.OldWxid(ctx)
  8785. case contact.FieldAccount:
  8786. return m.OldAccount(ctx)
  8787. case contact.FieldNickname:
  8788. return m.OldNickname(ctx)
  8789. case contact.FieldMarkname:
  8790. return m.OldMarkname(ctx)
  8791. case contact.FieldHeadimg:
  8792. return m.OldHeadimg(ctx)
  8793. case contact.FieldSex:
  8794. return m.OldSex(ctx)
  8795. case contact.FieldStarrole:
  8796. return m.OldStarrole(ctx)
  8797. case contact.FieldDontseeit:
  8798. return m.OldDontseeit(ctx)
  8799. case contact.FieldDontseeme:
  8800. return m.OldDontseeme(ctx)
  8801. case contact.FieldLag:
  8802. return m.OldLag(ctx)
  8803. case contact.FieldGid:
  8804. return m.OldGid(ctx)
  8805. case contact.FieldGname:
  8806. return m.OldGname(ctx)
  8807. case contact.FieldV3:
  8808. return m.OldV3(ctx)
  8809. case contact.FieldOrganizationID:
  8810. return m.OldOrganizationID(ctx)
  8811. }
  8812. return nil, fmt.Errorf("unknown Contact field %s", name)
  8813. }
  8814. // SetField sets the value of a field with the given name. It returns an error if
  8815. // the field is not defined in the schema, or if the type mismatched the field
  8816. // type.
  8817. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8818. switch name {
  8819. case contact.FieldCreatedAt:
  8820. v, ok := value.(time.Time)
  8821. if !ok {
  8822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8823. }
  8824. m.SetCreatedAt(v)
  8825. return nil
  8826. case contact.FieldUpdatedAt:
  8827. v, ok := value.(time.Time)
  8828. if !ok {
  8829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8830. }
  8831. m.SetUpdatedAt(v)
  8832. return nil
  8833. case contact.FieldStatus:
  8834. v, ok := value.(uint8)
  8835. if !ok {
  8836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8837. }
  8838. m.SetStatus(v)
  8839. return nil
  8840. case contact.FieldDeletedAt:
  8841. v, ok := value.(time.Time)
  8842. if !ok {
  8843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8844. }
  8845. m.SetDeletedAt(v)
  8846. return nil
  8847. case contact.FieldWxWxid:
  8848. v, ok := value.(string)
  8849. if !ok {
  8850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8851. }
  8852. m.SetWxWxid(v)
  8853. return nil
  8854. case contact.FieldType:
  8855. v, ok := value.(int)
  8856. if !ok {
  8857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8858. }
  8859. m.SetType(v)
  8860. return nil
  8861. case contact.FieldWxid:
  8862. v, ok := value.(string)
  8863. if !ok {
  8864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8865. }
  8866. m.SetWxid(v)
  8867. return nil
  8868. case contact.FieldAccount:
  8869. v, ok := value.(string)
  8870. if !ok {
  8871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8872. }
  8873. m.SetAccount(v)
  8874. return nil
  8875. case contact.FieldNickname:
  8876. v, ok := value.(string)
  8877. if !ok {
  8878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8879. }
  8880. m.SetNickname(v)
  8881. return nil
  8882. case contact.FieldMarkname:
  8883. v, ok := value.(string)
  8884. if !ok {
  8885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8886. }
  8887. m.SetMarkname(v)
  8888. return nil
  8889. case contact.FieldHeadimg:
  8890. v, ok := value.(string)
  8891. if !ok {
  8892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8893. }
  8894. m.SetHeadimg(v)
  8895. return nil
  8896. case contact.FieldSex:
  8897. v, ok := value.(int)
  8898. if !ok {
  8899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8900. }
  8901. m.SetSex(v)
  8902. return nil
  8903. case contact.FieldStarrole:
  8904. v, ok := value.(string)
  8905. if !ok {
  8906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8907. }
  8908. m.SetStarrole(v)
  8909. return nil
  8910. case contact.FieldDontseeit:
  8911. v, ok := value.(int)
  8912. if !ok {
  8913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8914. }
  8915. m.SetDontseeit(v)
  8916. return nil
  8917. case contact.FieldDontseeme:
  8918. v, ok := value.(int)
  8919. if !ok {
  8920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8921. }
  8922. m.SetDontseeme(v)
  8923. return nil
  8924. case contact.FieldLag:
  8925. v, ok := value.(string)
  8926. if !ok {
  8927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8928. }
  8929. m.SetLag(v)
  8930. return nil
  8931. case contact.FieldGid:
  8932. v, ok := value.(string)
  8933. if !ok {
  8934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8935. }
  8936. m.SetGid(v)
  8937. return nil
  8938. case contact.FieldGname:
  8939. v, ok := value.(string)
  8940. if !ok {
  8941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8942. }
  8943. m.SetGname(v)
  8944. return nil
  8945. case contact.FieldV3:
  8946. v, ok := value.(string)
  8947. if !ok {
  8948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8949. }
  8950. m.SetV3(v)
  8951. return nil
  8952. case contact.FieldOrganizationID:
  8953. v, ok := value.(uint64)
  8954. if !ok {
  8955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8956. }
  8957. m.SetOrganizationID(v)
  8958. return nil
  8959. }
  8960. return fmt.Errorf("unknown Contact field %s", name)
  8961. }
  8962. // AddedFields returns all numeric fields that were incremented/decremented during
  8963. // this mutation.
  8964. func (m *ContactMutation) AddedFields() []string {
  8965. var fields []string
  8966. if m.addstatus != nil {
  8967. fields = append(fields, contact.FieldStatus)
  8968. }
  8969. if m.add_type != nil {
  8970. fields = append(fields, contact.FieldType)
  8971. }
  8972. if m.addsex != nil {
  8973. fields = append(fields, contact.FieldSex)
  8974. }
  8975. if m.adddontseeit != nil {
  8976. fields = append(fields, contact.FieldDontseeit)
  8977. }
  8978. if m.adddontseeme != nil {
  8979. fields = append(fields, contact.FieldDontseeme)
  8980. }
  8981. if m.addorganization_id != nil {
  8982. fields = append(fields, contact.FieldOrganizationID)
  8983. }
  8984. return fields
  8985. }
  8986. // AddedField returns the numeric value that was incremented/decremented on a field
  8987. // with the given name. The second boolean return value indicates that this field
  8988. // was not set, or was not defined in the schema.
  8989. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8990. switch name {
  8991. case contact.FieldStatus:
  8992. return m.AddedStatus()
  8993. case contact.FieldType:
  8994. return m.AddedType()
  8995. case contact.FieldSex:
  8996. return m.AddedSex()
  8997. case contact.FieldDontseeit:
  8998. return m.AddedDontseeit()
  8999. case contact.FieldDontseeme:
  9000. return m.AddedDontseeme()
  9001. case contact.FieldOrganizationID:
  9002. return m.AddedOrganizationID()
  9003. }
  9004. return nil, false
  9005. }
  9006. // AddField adds the value to the field with the given name. It returns an error if
  9007. // the field is not defined in the schema, or if the type mismatched the field
  9008. // type.
  9009. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9010. switch name {
  9011. case contact.FieldStatus:
  9012. v, ok := value.(int8)
  9013. if !ok {
  9014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9015. }
  9016. m.AddStatus(v)
  9017. return nil
  9018. case contact.FieldType:
  9019. v, ok := value.(int)
  9020. if !ok {
  9021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9022. }
  9023. m.AddType(v)
  9024. return nil
  9025. case contact.FieldSex:
  9026. v, ok := value.(int)
  9027. if !ok {
  9028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9029. }
  9030. m.AddSex(v)
  9031. return nil
  9032. case contact.FieldDontseeit:
  9033. v, ok := value.(int)
  9034. if !ok {
  9035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9036. }
  9037. m.AddDontseeit(v)
  9038. return nil
  9039. case contact.FieldDontseeme:
  9040. v, ok := value.(int)
  9041. if !ok {
  9042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9043. }
  9044. m.AddDontseeme(v)
  9045. return nil
  9046. case contact.FieldOrganizationID:
  9047. v, ok := value.(int64)
  9048. if !ok {
  9049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9050. }
  9051. m.AddOrganizationID(v)
  9052. return nil
  9053. }
  9054. return fmt.Errorf("unknown Contact numeric field %s", name)
  9055. }
  9056. // ClearedFields returns all nullable fields that were cleared during this
  9057. // mutation.
  9058. func (m *ContactMutation) ClearedFields() []string {
  9059. var fields []string
  9060. if m.FieldCleared(contact.FieldStatus) {
  9061. fields = append(fields, contact.FieldStatus)
  9062. }
  9063. if m.FieldCleared(contact.FieldDeletedAt) {
  9064. fields = append(fields, contact.FieldDeletedAt)
  9065. }
  9066. if m.FieldCleared(contact.FieldType) {
  9067. fields = append(fields, contact.FieldType)
  9068. }
  9069. if m.FieldCleared(contact.FieldOrganizationID) {
  9070. fields = append(fields, contact.FieldOrganizationID)
  9071. }
  9072. return fields
  9073. }
  9074. // FieldCleared returns a boolean indicating if a field with the given name was
  9075. // cleared in this mutation.
  9076. func (m *ContactMutation) FieldCleared(name string) bool {
  9077. _, ok := m.clearedFields[name]
  9078. return ok
  9079. }
  9080. // ClearField clears the value of the field with the given name. It returns an
  9081. // error if the field is not defined in the schema.
  9082. func (m *ContactMutation) ClearField(name string) error {
  9083. switch name {
  9084. case contact.FieldStatus:
  9085. m.ClearStatus()
  9086. return nil
  9087. case contact.FieldDeletedAt:
  9088. m.ClearDeletedAt()
  9089. return nil
  9090. case contact.FieldType:
  9091. m.ClearType()
  9092. return nil
  9093. case contact.FieldOrganizationID:
  9094. m.ClearOrganizationID()
  9095. return nil
  9096. }
  9097. return fmt.Errorf("unknown Contact nullable field %s", name)
  9098. }
  9099. // ResetField resets all changes in the mutation for the field with the given name.
  9100. // It returns an error if the field is not defined in the schema.
  9101. func (m *ContactMutation) ResetField(name string) error {
  9102. switch name {
  9103. case contact.FieldCreatedAt:
  9104. m.ResetCreatedAt()
  9105. return nil
  9106. case contact.FieldUpdatedAt:
  9107. m.ResetUpdatedAt()
  9108. return nil
  9109. case contact.FieldStatus:
  9110. m.ResetStatus()
  9111. return nil
  9112. case contact.FieldDeletedAt:
  9113. m.ResetDeletedAt()
  9114. return nil
  9115. case contact.FieldWxWxid:
  9116. m.ResetWxWxid()
  9117. return nil
  9118. case contact.FieldType:
  9119. m.ResetType()
  9120. return nil
  9121. case contact.FieldWxid:
  9122. m.ResetWxid()
  9123. return nil
  9124. case contact.FieldAccount:
  9125. m.ResetAccount()
  9126. return nil
  9127. case contact.FieldNickname:
  9128. m.ResetNickname()
  9129. return nil
  9130. case contact.FieldMarkname:
  9131. m.ResetMarkname()
  9132. return nil
  9133. case contact.FieldHeadimg:
  9134. m.ResetHeadimg()
  9135. return nil
  9136. case contact.FieldSex:
  9137. m.ResetSex()
  9138. return nil
  9139. case contact.FieldStarrole:
  9140. m.ResetStarrole()
  9141. return nil
  9142. case contact.FieldDontseeit:
  9143. m.ResetDontseeit()
  9144. return nil
  9145. case contact.FieldDontseeme:
  9146. m.ResetDontseeme()
  9147. return nil
  9148. case contact.FieldLag:
  9149. m.ResetLag()
  9150. return nil
  9151. case contact.FieldGid:
  9152. m.ResetGid()
  9153. return nil
  9154. case contact.FieldGname:
  9155. m.ResetGname()
  9156. return nil
  9157. case contact.FieldV3:
  9158. m.ResetV3()
  9159. return nil
  9160. case contact.FieldOrganizationID:
  9161. m.ResetOrganizationID()
  9162. return nil
  9163. }
  9164. return fmt.Errorf("unknown Contact field %s", name)
  9165. }
  9166. // AddedEdges returns all edge names that were set/added in this mutation.
  9167. func (m *ContactMutation) AddedEdges() []string {
  9168. edges := make([]string, 0, 2)
  9169. if m.contact_relationships != nil {
  9170. edges = append(edges, contact.EdgeContactRelationships)
  9171. }
  9172. if m.contact_messages != nil {
  9173. edges = append(edges, contact.EdgeContactMessages)
  9174. }
  9175. return edges
  9176. }
  9177. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9178. // name in this mutation.
  9179. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9180. switch name {
  9181. case contact.EdgeContactRelationships:
  9182. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9183. for id := range m.contact_relationships {
  9184. ids = append(ids, id)
  9185. }
  9186. return ids
  9187. case contact.EdgeContactMessages:
  9188. ids := make([]ent.Value, 0, len(m.contact_messages))
  9189. for id := range m.contact_messages {
  9190. ids = append(ids, id)
  9191. }
  9192. return ids
  9193. }
  9194. return nil
  9195. }
  9196. // RemovedEdges returns all edge names that were removed in this mutation.
  9197. func (m *ContactMutation) RemovedEdges() []string {
  9198. edges := make([]string, 0, 2)
  9199. if m.removedcontact_relationships != nil {
  9200. edges = append(edges, contact.EdgeContactRelationships)
  9201. }
  9202. if m.removedcontact_messages != nil {
  9203. edges = append(edges, contact.EdgeContactMessages)
  9204. }
  9205. return edges
  9206. }
  9207. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9208. // the given name in this mutation.
  9209. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9210. switch name {
  9211. case contact.EdgeContactRelationships:
  9212. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9213. for id := range m.removedcontact_relationships {
  9214. ids = append(ids, id)
  9215. }
  9216. return ids
  9217. case contact.EdgeContactMessages:
  9218. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9219. for id := range m.removedcontact_messages {
  9220. ids = append(ids, id)
  9221. }
  9222. return ids
  9223. }
  9224. return nil
  9225. }
  9226. // ClearedEdges returns all edge names that were cleared in this mutation.
  9227. func (m *ContactMutation) ClearedEdges() []string {
  9228. edges := make([]string, 0, 2)
  9229. if m.clearedcontact_relationships {
  9230. edges = append(edges, contact.EdgeContactRelationships)
  9231. }
  9232. if m.clearedcontact_messages {
  9233. edges = append(edges, contact.EdgeContactMessages)
  9234. }
  9235. return edges
  9236. }
  9237. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9238. // was cleared in this mutation.
  9239. func (m *ContactMutation) EdgeCleared(name string) bool {
  9240. switch name {
  9241. case contact.EdgeContactRelationships:
  9242. return m.clearedcontact_relationships
  9243. case contact.EdgeContactMessages:
  9244. return m.clearedcontact_messages
  9245. }
  9246. return false
  9247. }
  9248. // ClearEdge clears the value of the edge with the given name. It returns an error
  9249. // if that edge is not defined in the schema.
  9250. func (m *ContactMutation) ClearEdge(name string) error {
  9251. switch name {
  9252. }
  9253. return fmt.Errorf("unknown Contact unique edge %s", name)
  9254. }
  9255. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9256. // It returns an error if the edge is not defined in the schema.
  9257. func (m *ContactMutation) ResetEdge(name string) error {
  9258. switch name {
  9259. case contact.EdgeContactRelationships:
  9260. m.ResetContactRelationships()
  9261. return nil
  9262. case contact.EdgeContactMessages:
  9263. m.ResetContactMessages()
  9264. return nil
  9265. }
  9266. return fmt.Errorf("unknown Contact edge %s", name)
  9267. }
  9268. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9269. type CreditBalanceMutation struct {
  9270. config
  9271. op Op
  9272. typ string
  9273. id *uint64
  9274. created_at *time.Time
  9275. updated_at *time.Time
  9276. deleted_at *time.Time
  9277. user_id *string
  9278. balance *float32
  9279. addbalance *float32
  9280. status *int
  9281. addstatus *int
  9282. organization_id *uint64
  9283. addorganization_id *int64
  9284. clearedFields map[string]struct{}
  9285. done bool
  9286. oldValue func(context.Context) (*CreditBalance, error)
  9287. predicates []predicate.CreditBalance
  9288. }
  9289. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9290. // creditbalanceOption allows management of the mutation configuration using functional options.
  9291. type creditbalanceOption func(*CreditBalanceMutation)
  9292. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9293. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9294. m := &CreditBalanceMutation{
  9295. config: c,
  9296. op: op,
  9297. typ: TypeCreditBalance,
  9298. clearedFields: make(map[string]struct{}),
  9299. }
  9300. for _, opt := range opts {
  9301. opt(m)
  9302. }
  9303. return m
  9304. }
  9305. // withCreditBalanceID sets the ID field of the mutation.
  9306. func withCreditBalanceID(id uint64) creditbalanceOption {
  9307. return func(m *CreditBalanceMutation) {
  9308. var (
  9309. err error
  9310. once sync.Once
  9311. value *CreditBalance
  9312. )
  9313. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9314. once.Do(func() {
  9315. if m.done {
  9316. err = errors.New("querying old values post mutation is not allowed")
  9317. } else {
  9318. value, err = m.Client().CreditBalance.Get(ctx, id)
  9319. }
  9320. })
  9321. return value, err
  9322. }
  9323. m.id = &id
  9324. }
  9325. }
  9326. // withCreditBalance sets the old CreditBalance of the mutation.
  9327. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9328. return func(m *CreditBalanceMutation) {
  9329. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9330. return node, nil
  9331. }
  9332. m.id = &node.ID
  9333. }
  9334. }
  9335. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9336. // executed in a transaction (ent.Tx), a transactional client is returned.
  9337. func (m CreditBalanceMutation) Client() *Client {
  9338. client := &Client{config: m.config}
  9339. client.init()
  9340. return client
  9341. }
  9342. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9343. // it returns an error otherwise.
  9344. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9345. if _, ok := m.driver.(*txDriver); !ok {
  9346. return nil, errors.New("ent: mutation is not running in a transaction")
  9347. }
  9348. tx := &Tx{config: m.config}
  9349. tx.init()
  9350. return tx, nil
  9351. }
  9352. // SetID sets the value of the id field. Note that this
  9353. // operation is only accepted on creation of CreditBalance entities.
  9354. func (m *CreditBalanceMutation) SetID(id uint64) {
  9355. m.id = &id
  9356. }
  9357. // ID returns the ID value in the mutation. Note that the ID is only available
  9358. // if it was provided to the builder or after it was returned from the database.
  9359. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9360. if m.id == nil {
  9361. return
  9362. }
  9363. return *m.id, true
  9364. }
  9365. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9366. // That means, if the mutation is applied within a transaction with an isolation level such
  9367. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9368. // or updated by the mutation.
  9369. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9370. switch {
  9371. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9372. id, exists := m.ID()
  9373. if exists {
  9374. return []uint64{id}, nil
  9375. }
  9376. fallthrough
  9377. case m.op.Is(OpUpdate | OpDelete):
  9378. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9379. default:
  9380. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9381. }
  9382. }
  9383. // SetCreatedAt sets the "created_at" field.
  9384. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9385. m.created_at = &t
  9386. }
  9387. // CreatedAt returns the value of the "created_at" field in the mutation.
  9388. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9389. v := m.created_at
  9390. if v == nil {
  9391. return
  9392. }
  9393. return *v, true
  9394. }
  9395. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9396. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9398. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9399. if !m.op.Is(OpUpdateOne) {
  9400. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9401. }
  9402. if m.id == nil || m.oldValue == nil {
  9403. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9404. }
  9405. oldValue, err := m.oldValue(ctx)
  9406. if err != nil {
  9407. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9408. }
  9409. return oldValue.CreatedAt, nil
  9410. }
  9411. // ResetCreatedAt resets all changes to the "created_at" field.
  9412. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9413. m.created_at = nil
  9414. }
  9415. // SetUpdatedAt sets the "updated_at" field.
  9416. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9417. m.updated_at = &t
  9418. }
  9419. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9420. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9421. v := m.updated_at
  9422. if v == nil {
  9423. return
  9424. }
  9425. return *v, true
  9426. }
  9427. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9428. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9430. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9431. if !m.op.Is(OpUpdateOne) {
  9432. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9433. }
  9434. if m.id == nil || m.oldValue == nil {
  9435. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9436. }
  9437. oldValue, err := m.oldValue(ctx)
  9438. if err != nil {
  9439. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9440. }
  9441. return oldValue.UpdatedAt, nil
  9442. }
  9443. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9444. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9445. m.updated_at = nil
  9446. }
  9447. // SetDeletedAt sets the "deleted_at" field.
  9448. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9449. m.deleted_at = &t
  9450. }
  9451. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9452. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9453. v := m.deleted_at
  9454. if v == nil {
  9455. return
  9456. }
  9457. return *v, true
  9458. }
  9459. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9460. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9462. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9463. if !m.op.Is(OpUpdateOne) {
  9464. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9465. }
  9466. if m.id == nil || m.oldValue == nil {
  9467. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9468. }
  9469. oldValue, err := m.oldValue(ctx)
  9470. if err != nil {
  9471. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9472. }
  9473. return oldValue.DeletedAt, nil
  9474. }
  9475. // ClearDeletedAt clears the value of the "deleted_at" field.
  9476. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9477. m.deleted_at = nil
  9478. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9479. }
  9480. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9481. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9482. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9483. return ok
  9484. }
  9485. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9486. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9487. m.deleted_at = nil
  9488. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9489. }
  9490. // SetUserID sets the "user_id" field.
  9491. func (m *CreditBalanceMutation) SetUserID(s string) {
  9492. m.user_id = &s
  9493. }
  9494. // UserID returns the value of the "user_id" field in the mutation.
  9495. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9496. v := m.user_id
  9497. if v == nil {
  9498. return
  9499. }
  9500. return *v, true
  9501. }
  9502. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9503. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9505. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9506. if !m.op.Is(OpUpdateOne) {
  9507. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9508. }
  9509. if m.id == nil || m.oldValue == nil {
  9510. return v, errors.New("OldUserID requires an ID field in the mutation")
  9511. }
  9512. oldValue, err := m.oldValue(ctx)
  9513. if err != nil {
  9514. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9515. }
  9516. return oldValue.UserID, nil
  9517. }
  9518. // ResetUserID resets all changes to the "user_id" field.
  9519. func (m *CreditBalanceMutation) ResetUserID() {
  9520. m.user_id = nil
  9521. }
  9522. // SetBalance sets the "balance" field.
  9523. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9524. m.balance = &f
  9525. m.addbalance = nil
  9526. }
  9527. // Balance returns the value of the "balance" field in the mutation.
  9528. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9529. v := m.balance
  9530. if v == nil {
  9531. return
  9532. }
  9533. return *v, true
  9534. }
  9535. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9536. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9538. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9539. if !m.op.Is(OpUpdateOne) {
  9540. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9541. }
  9542. if m.id == nil || m.oldValue == nil {
  9543. return v, errors.New("OldBalance requires an ID field in the mutation")
  9544. }
  9545. oldValue, err := m.oldValue(ctx)
  9546. if err != nil {
  9547. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9548. }
  9549. return oldValue.Balance, nil
  9550. }
  9551. // AddBalance adds f to the "balance" field.
  9552. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9553. if m.addbalance != nil {
  9554. *m.addbalance += f
  9555. } else {
  9556. m.addbalance = &f
  9557. }
  9558. }
  9559. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9560. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9561. v := m.addbalance
  9562. if v == nil {
  9563. return
  9564. }
  9565. return *v, true
  9566. }
  9567. // ResetBalance resets all changes to the "balance" field.
  9568. func (m *CreditBalanceMutation) ResetBalance() {
  9569. m.balance = nil
  9570. m.addbalance = nil
  9571. }
  9572. // SetStatus sets the "status" field.
  9573. func (m *CreditBalanceMutation) SetStatus(i int) {
  9574. m.status = &i
  9575. m.addstatus = nil
  9576. }
  9577. // Status returns the value of the "status" field in the mutation.
  9578. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9579. v := m.status
  9580. if v == nil {
  9581. return
  9582. }
  9583. return *v, true
  9584. }
  9585. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9586. // If the CreditBalance 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 *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9589. if !m.op.Is(OpUpdateOne) {
  9590. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9591. }
  9592. if m.id == nil || m.oldValue == nil {
  9593. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  9598. }
  9599. return oldValue.Status, nil
  9600. }
  9601. // AddStatus adds i to the "status" field.
  9602. func (m *CreditBalanceMutation) AddStatus(i int) {
  9603. if m.addstatus != nil {
  9604. *m.addstatus += i
  9605. } else {
  9606. m.addstatus = &i
  9607. }
  9608. }
  9609. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9610. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9611. v := m.addstatus
  9612. if v == nil {
  9613. return
  9614. }
  9615. return *v, true
  9616. }
  9617. // ClearStatus clears the value of the "status" field.
  9618. func (m *CreditBalanceMutation) ClearStatus() {
  9619. m.status = nil
  9620. m.addstatus = nil
  9621. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9622. }
  9623. // StatusCleared returns if the "status" field was cleared in this mutation.
  9624. func (m *CreditBalanceMutation) StatusCleared() bool {
  9625. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9626. return ok
  9627. }
  9628. // ResetStatus resets all changes to the "status" field.
  9629. func (m *CreditBalanceMutation) ResetStatus() {
  9630. m.status = nil
  9631. m.addstatus = nil
  9632. delete(m.clearedFields, creditbalance.FieldStatus)
  9633. }
  9634. // SetOrganizationID sets the "organization_id" field.
  9635. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9636. m.organization_id = &u
  9637. m.addorganization_id = nil
  9638. }
  9639. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9640. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9641. v := m.organization_id
  9642. if v == nil {
  9643. return
  9644. }
  9645. return *v, true
  9646. }
  9647. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9648. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9650. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9651. if !m.op.Is(OpUpdateOne) {
  9652. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9653. }
  9654. if m.id == nil || m.oldValue == nil {
  9655. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9656. }
  9657. oldValue, err := m.oldValue(ctx)
  9658. if err != nil {
  9659. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9660. }
  9661. return oldValue.OrganizationID, nil
  9662. }
  9663. // AddOrganizationID adds u to the "organization_id" field.
  9664. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9665. if m.addorganization_id != nil {
  9666. *m.addorganization_id += u
  9667. } else {
  9668. m.addorganization_id = &u
  9669. }
  9670. }
  9671. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9672. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9673. v := m.addorganization_id
  9674. if v == nil {
  9675. return
  9676. }
  9677. return *v, true
  9678. }
  9679. // ResetOrganizationID resets all changes to the "organization_id" field.
  9680. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9681. m.organization_id = nil
  9682. m.addorganization_id = nil
  9683. }
  9684. // Where appends a list predicates to the CreditBalanceMutation builder.
  9685. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9686. m.predicates = append(m.predicates, ps...)
  9687. }
  9688. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9689. // users can use type-assertion to append predicates that do not depend on any generated package.
  9690. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9691. p := make([]predicate.CreditBalance, len(ps))
  9692. for i := range ps {
  9693. p[i] = ps[i]
  9694. }
  9695. m.Where(p...)
  9696. }
  9697. // Op returns the operation name.
  9698. func (m *CreditBalanceMutation) Op() Op {
  9699. return m.op
  9700. }
  9701. // SetOp allows setting the mutation operation.
  9702. func (m *CreditBalanceMutation) SetOp(op Op) {
  9703. m.op = op
  9704. }
  9705. // Type returns the node type of this mutation (CreditBalance).
  9706. func (m *CreditBalanceMutation) Type() string {
  9707. return m.typ
  9708. }
  9709. // Fields returns all fields that were changed during this mutation. Note that in
  9710. // order to get all numeric fields that were incremented/decremented, call
  9711. // AddedFields().
  9712. func (m *CreditBalanceMutation) Fields() []string {
  9713. fields := make([]string, 0, 7)
  9714. if m.created_at != nil {
  9715. fields = append(fields, creditbalance.FieldCreatedAt)
  9716. }
  9717. if m.updated_at != nil {
  9718. fields = append(fields, creditbalance.FieldUpdatedAt)
  9719. }
  9720. if m.deleted_at != nil {
  9721. fields = append(fields, creditbalance.FieldDeletedAt)
  9722. }
  9723. if m.user_id != nil {
  9724. fields = append(fields, creditbalance.FieldUserID)
  9725. }
  9726. if m.balance != nil {
  9727. fields = append(fields, creditbalance.FieldBalance)
  9728. }
  9729. if m.status != nil {
  9730. fields = append(fields, creditbalance.FieldStatus)
  9731. }
  9732. if m.organization_id != nil {
  9733. fields = append(fields, creditbalance.FieldOrganizationID)
  9734. }
  9735. return fields
  9736. }
  9737. // Field returns the value of a field with the given name. The second boolean
  9738. // return value indicates that this field was not set, or was not defined in the
  9739. // schema.
  9740. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9741. switch name {
  9742. case creditbalance.FieldCreatedAt:
  9743. return m.CreatedAt()
  9744. case creditbalance.FieldUpdatedAt:
  9745. return m.UpdatedAt()
  9746. case creditbalance.FieldDeletedAt:
  9747. return m.DeletedAt()
  9748. case creditbalance.FieldUserID:
  9749. return m.UserID()
  9750. case creditbalance.FieldBalance:
  9751. return m.Balance()
  9752. case creditbalance.FieldStatus:
  9753. return m.Status()
  9754. case creditbalance.FieldOrganizationID:
  9755. return m.OrganizationID()
  9756. }
  9757. return nil, false
  9758. }
  9759. // OldField returns the old value of the field from the database. An error is
  9760. // returned if the mutation operation is not UpdateOne, or the query to the
  9761. // database failed.
  9762. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9763. switch name {
  9764. case creditbalance.FieldCreatedAt:
  9765. return m.OldCreatedAt(ctx)
  9766. case creditbalance.FieldUpdatedAt:
  9767. return m.OldUpdatedAt(ctx)
  9768. case creditbalance.FieldDeletedAt:
  9769. return m.OldDeletedAt(ctx)
  9770. case creditbalance.FieldUserID:
  9771. return m.OldUserID(ctx)
  9772. case creditbalance.FieldBalance:
  9773. return m.OldBalance(ctx)
  9774. case creditbalance.FieldStatus:
  9775. return m.OldStatus(ctx)
  9776. case creditbalance.FieldOrganizationID:
  9777. return m.OldOrganizationID(ctx)
  9778. }
  9779. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9780. }
  9781. // SetField sets the value of a field with the given name. It returns an error if
  9782. // the field is not defined in the schema, or if the type mismatched the field
  9783. // type.
  9784. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9785. switch name {
  9786. case creditbalance.FieldCreatedAt:
  9787. v, ok := value.(time.Time)
  9788. if !ok {
  9789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9790. }
  9791. m.SetCreatedAt(v)
  9792. return nil
  9793. case creditbalance.FieldUpdatedAt:
  9794. v, ok := value.(time.Time)
  9795. if !ok {
  9796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9797. }
  9798. m.SetUpdatedAt(v)
  9799. return nil
  9800. case creditbalance.FieldDeletedAt:
  9801. v, ok := value.(time.Time)
  9802. if !ok {
  9803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9804. }
  9805. m.SetDeletedAt(v)
  9806. return nil
  9807. case creditbalance.FieldUserID:
  9808. v, ok := value.(string)
  9809. if !ok {
  9810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9811. }
  9812. m.SetUserID(v)
  9813. return nil
  9814. case creditbalance.FieldBalance:
  9815. v, ok := value.(float32)
  9816. if !ok {
  9817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9818. }
  9819. m.SetBalance(v)
  9820. return nil
  9821. case creditbalance.FieldStatus:
  9822. v, ok := value.(int)
  9823. if !ok {
  9824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9825. }
  9826. m.SetStatus(v)
  9827. return nil
  9828. case creditbalance.FieldOrganizationID:
  9829. v, ok := value.(uint64)
  9830. if !ok {
  9831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9832. }
  9833. m.SetOrganizationID(v)
  9834. return nil
  9835. }
  9836. return fmt.Errorf("unknown CreditBalance field %s", name)
  9837. }
  9838. // AddedFields returns all numeric fields that were incremented/decremented during
  9839. // this mutation.
  9840. func (m *CreditBalanceMutation) AddedFields() []string {
  9841. var fields []string
  9842. if m.addbalance != nil {
  9843. fields = append(fields, creditbalance.FieldBalance)
  9844. }
  9845. if m.addstatus != nil {
  9846. fields = append(fields, creditbalance.FieldStatus)
  9847. }
  9848. if m.addorganization_id != nil {
  9849. fields = append(fields, creditbalance.FieldOrganizationID)
  9850. }
  9851. return fields
  9852. }
  9853. // AddedField returns the numeric value that was incremented/decremented on a field
  9854. // with the given name. The second boolean return value indicates that this field
  9855. // was not set, or was not defined in the schema.
  9856. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9857. switch name {
  9858. case creditbalance.FieldBalance:
  9859. return m.AddedBalance()
  9860. case creditbalance.FieldStatus:
  9861. return m.AddedStatus()
  9862. case creditbalance.FieldOrganizationID:
  9863. return m.AddedOrganizationID()
  9864. }
  9865. return nil, false
  9866. }
  9867. // AddField adds the value to the field with the given name. It returns an error if
  9868. // the field is not defined in the schema, or if the type mismatched the field
  9869. // type.
  9870. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9871. switch name {
  9872. case creditbalance.FieldBalance:
  9873. v, ok := value.(float32)
  9874. if !ok {
  9875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9876. }
  9877. m.AddBalance(v)
  9878. return nil
  9879. case creditbalance.FieldStatus:
  9880. v, ok := value.(int)
  9881. if !ok {
  9882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9883. }
  9884. m.AddStatus(v)
  9885. return nil
  9886. case creditbalance.FieldOrganizationID:
  9887. v, ok := value.(int64)
  9888. if !ok {
  9889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9890. }
  9891. m.AddOrganizationID(v)
  9892. return nil
  9893. }
  9894. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9895. }
  9896. // ClearedFields returns all nullable fields that were cleared during this
  9897. // mutation.
  9898. func (m *CreditBalanceMutation) ClearedFields() []string {
  9899. var fields []string
  9900. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  9901. fields = append(fields, creditbalance.FieldDeletedAt)
  9902. }
  9903. if m.FieldCleared(creditbalance.FieldStatus) {
  9904. fields = append(fields, creditbalance.FieldStatus)
  9905. }
  9906. return fields
  9907. }
  9908. // FieldCleared returns a boolean indicating if a field with the given name was
  9909. // cleared in this mutation.
  9910. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  9911. _, ok := m.clearedFields[name]
  9912. return ok
  9913. }
  9914. // ClearField clears the value of the field with the given name. It returns an
  9915. // error if the field is not defined in the schema.
  9916. func (m *CreditBalanceMutation) ClearField(name string) error {
  9917. switch name {
  9918. case creditbalance.FieldDeletedAt:
  9919. m.ClearDeletedAt()
  9920. return nil
  9921. case creditbalance.FieldStatus:
  9922. m.ClearStatus()
  9923. return nil
  9924. }
  9925. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  9926. }
  9927. // ResetField resets all changes in the mutation for the field with the given name.
  9928. // It returns an error if the field is not defined in the schema.
  9929. func (m *CreditBalanceMutation) ResetField(name string) error {
  9930. switch name {
  9931. case creditbalance.FieldCreatedAt:
  9932. m.ResetCreatedAt()
  9933. return nil
  9934. case creditbalance.FieldUpdatedAt:
  9935. m.ResetUpdatedAt()
  9936. return nil
  9937. case creditbalance.FieldDeletedAt:
  9938. m.ResetDeletedAt()
  9939. return nil
  9940. case creditbalance.FieldUserID:
  9941. m.ResetUserID()
  9942. return nil
  9943. case creditbalance.FieldBalance:
  9944. m.ResetBalance()
  9945. return nil
  9946. case creditbalance.FieldStatus:
  9947. m.ResetStatus()
  9948. return nil
  9949. case creditbalance.FieldOrganizationID:
  9950. m.ResetOrganizationID()
  9951. return nil
  9952. }
  9953. return fmt.Errorf("unknown CreditBalance field %s", name)
  9954. }
  9955. // AddedEdges returns all edge names that were set/added in this mutation.
  9956. func (m *CreditBalanceMutation) AddedEdges() []string {
  9957. edges := make([]string, 0, 0)
  9958. return edges
  9959. }
  9960. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9961. // name in this mutation.
  9962. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  9963. return nil
  9964. }
  9965. // RemovedEdges returns all edge names that were removed in this mutation.
  9966. func (m *CreditBalanceMutation) RemovedEdges() []string {
  9967. edges := make([]string, 0, 0)
  9968. return edges
  9969. }
  9970. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9971. // the given name in this mutation.
  9972. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  9973. return nil
  9974. }
  9975. // ClearedEdges returns all edge names that were cleared in this mutation.
  9976. func (m *CreditBalanceMutation) ClearedEdges() []string {
  9977. edges := make([]string, 0, 0)
  9978. return edges
  9979. }
  9980. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9981. // was cleared in this mutation.
  9982. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  9983. return false
  9984. }
  9985. // ClearEdge clears the value of the edge with the given name. It returns an error
  9986. // if that edge is not defined in the schema.
  9987. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  9988. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  9989. }
  9990. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9991. // It returns an error if the edge is not defined in the schema.
  9992. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  9993. return fmt.Errorf("unknown CreditBalance edge %s", name)
  9994. }
  9995. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  9996. type CreditUsageMutation struct {
  9997. config
  9998. op Op
  9999. typ string
  10000. id *uint64
  10001. created_at *time.Time
  10002. updated_at *time.Time
  10003. deleted_at *time.Time
  10004. user_id *string
  10005. number *float32
  10006. addnumber *float32
  10007. status *int
  10008. addstatus *int
  10009. ntype *int
  10010. addntype *int
  10011. table *string
  10012. organization_id *uint64
  10013. addorganization_id *int64
  10014. nid *uint64
  10015. addnid *int64
  10016. reason *string
  10017. operator *string
  10018. clearedFields map[string]struct{}
  10019. done bool
  10020. oldValue func(context.Context) (*CreditUsage, error)
  10021. predicates []predicate.CreditUsage
  10022. }
  10023. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10024. // creditusageOption allows management of the mutation configuration using functional options.
  10025. type creditusageOption func(*CreditUsageMutation)
  10026. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10027. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10028. m := &CreditUsageMutation{
  10029. config: c,
  10030. op: op,
  10031. typ: TypeCreditUsage,
  10032. clearedFields: make(map[string]struct{}),
  10033. }
  10034. for _, opt := range opts {
  10035. opt(m)
  10036. }
  10037. return m
  10038. }
  10039. // withCreditUsageID sets the ID field of the mutation.
  10040. func withCreditUsageID(id uint64) creditusageOption {
  10041. return func(m *CreditUsageMutation) {
  10042. var (
  10043. err error
  10044. once sync.Once
  10045. value *CreditUsage
  10046. )
  10047. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10048. once.Do(func() {
  10049. if m.done {
  10050. err = errors.New("querying old values post mutation is not allowed")
  10051. } else {
  10052. value, err = m.Client().CreditUsage.Get(ctx, id)
  10053. }
  10054. })
  10055. return value, err
  10056. }
  10057. m.id = &id
  10058. }
  10059. }
  10060. // withCreditUsage sets the old CreditUsage of the mutation.
  10061. func withCreditUsage(node *CreditUsage) creditusageOption {
  10062. return func(m *CreditUsageMutation) {
  10063. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10064. return node, nil
  10065. }
  10066. m.id = &node.ID
  10067. }
  10068. }
  10069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10070. // executed in a transaction (ent.Tx), a transactional client is returned.
  10071. func (m CreditUsageMutation) Client() *Client {
  10072. client := &Client{config: m.config}
  10073. client.init()
  10074. return client
  10075. }
  10076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10077. // it returns an error otherwise.
  10078. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10079. if _, ok := m.driver.(*txDriver); !ok {
  10080. return nil, errors.New("ent: mutation is not running in a transaction")
  10081. }
  10082. tx := &Tx{config: m.config}
  10083. tx.init()
  10084. return tx, nil
  10085. }
  10086. // SetID sets the value of the id field. Note that this
  10087. // operation is only accepted on creation of CreditUsage entities.
  10088. func (m *CreditUsageMutation) SetID(id uint64) {
  10089. m.id = &id
  10090. }
  10091. // ID returns the ID value in the mutation. Note that the ID is only available
  10092. // if it was provided to the builder or after it was returned from the database.
  10093. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10094. if m.id == nil {
  10095. return
  10096. }
  10097. return *m.id, true
  10098. }
  10099. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10100. // That means, if the mutation is applied within a transaction with an isolation level such
  10101. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10102. // or updated by the mutation.
  10103. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10104. switch {
  10105. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10106. id, exists := m.ID()
  10107. if exists {
  10108. return []uint64{id}, nil
  10109. }
  10110. fallthrough
  10111. case m.op.Is(OpUpdate | OpDelete):
  10112. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10113. default:
  10114. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10115. }
  10116. }
  10117. // SetCreatedAt sets the "created_at" field.
  10118. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10119. m.created_at = &t
  10120. }
  10121. // CreatedAt returns the value of the "created_at" field in the mutation.
  10122. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10123. v := m.created_at
  10124. if v == nil {
  10125. return
  10126. }
  10127. return *v, true
  10128. }
  10129. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10130. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10132. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10133. if !m.op.Is(OpUpdateOne) {
  10134. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10135. }
  10136. if m.id == nil || m.oldValue == nil {
  10137. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10138. }
  10139. oldValue, err := m.oldValue(ctx)
  10140. if err != nil {
  10141. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10142. }
  10143. return oldValue.CreatedAt, nil
  10144. }
  10145. // ResetCreatedAt resets all changes to the "created_at" field.
  10146. func (m *CreditUsageMutation) ResetCreatedAt() {
  10147. m.created_at = nil
  10148. }
  10149. // SetUpdatedAt sets the "updated_at" field.
  10150. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10151. m.updated_at = &t
  10152. }
  10153. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10154. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10155. v := m.updated_at
  10156. if v == nil {
  10157. return
  10158. }
  10159. return *v, true
  10160. }
  10161. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10162. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10164. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10165. if !m.op.Is(OpUpdateOne) {
  10166. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10167. }
  10168. if m.id == nil || m.oldValue == nil {
  10169. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10170. }
  10171. oldValue, err := m.oldValue(ctx)
  10172. if err != nil {
  10173. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10174. }
  10175. return oldValue.UpdatedAt, nil
  10176. }
  10177. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10178. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10179. m.updated_at = nil
  10180. }
  10181. // SetDeletedAt sets the "deleted_at" field.
  10182. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10183. m.deleted_at = &t
  10184. }
  10185. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10186. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10187. v := m.deleted_at
  10188. if v == nil {
  10189. return
  10190. }
  10191. return *v, true
  10192. }
  10193. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10194. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10196. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10197. if !m.op.Is(OpUpdateOne) {
  10198. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10199. }
  10200. if m.id == nil || m.oldValue == nil {
  10201. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10202. }
  10203. oldValue, err := m.oldValue(ctx)
  10204. if err != nil {
  10205. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10206. }
  10207. return oldValue.DeletedAt, nil
  10208. }
  10209. // ClearDeletedAt clears the value of the "deleted_at" field.
  10210. func (m *CreditUsageMutation) ClearDeletedAt() {
  10211. m.deleted_at = nil
  10212. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10213. }
  10214. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10215. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10216. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10217. return ok
  10218. }
  10219. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10220. func (m *CreditUsageMutation) ResetDeletedAt() {
  10221. m.deleted_at = nil
  10222. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10223. }
  10224. // SetUserID sets the "user_id" field.
  10225. func (m *CreditUsageMutation) SetUserID(s string) {
  10226. m.user_id = &s
  10227. }
  10228. // UserID returns the value of the "user_id" field in the mutation.
  10229. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10230. v := m.user_id
  10231. if v == nil {
  10232. return
  10233. }
  10234. return *v, true
  10235. }
  10236. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10237. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10239. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10240. if !m.op.Is(OpUpdateOne) {
  10241. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10242. }
  10243. if m.id == nil || m.oldValue == nil {
  10244. return v, errors.New("OldUserID requires an ID field in the mutation")
  10245. }
  10246. oldValue, err := m.oldValue(ctx)
  10247. if err != nil {
  10248. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10249. }
  10250. return oldValue.UserID, nil
  10251. }
  10252. // ResetUserID resets all changes to the "user_id" field.
  10253. func (m *CreditUsageMutation) ResetUserID() {
  10254. m.user_id = nil
  10255. }
  10256. // SetNumber sets the "number" field.
  10257. func (m *CreditUsageMutation) SetNumber(f float32) {
  10258. m.number = &f
  10259. m.addnumber = nil
  10260. }
  10261. // Number returns the value of the "number" field in the mutation.
  10262. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10263. v := m.number
  10264. if v == nil {
  10265. return
  10266. }
  10267. return *v, true
  10268. }
  10269. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10270. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10272. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10273. if !m.op.Is(OpUpdateOne) {
  10274. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10275. }
  10276. if m.id == nil || m.oldValue == nil {
  10277. return v, errors.New("OldNumber requires an ID field in the mutation")
  10278. }
  10279. oldValue, err := m.oldValue(ctx)
  10280. if err != nil {
  10281. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10282. }
  10283. return oldValue.Number, nil
  10284. }
  10285. // AddNumber adds f to the "number" field.
  10286. func (m *CreditUsageMutation) AddNumber(f float32) {
  10287. if m.addnumber != nil {
  10288. *m.addnumber += f
  10289. } else {
  10290. m.addnumber = &f
  10291. }
  10292. }
  10293. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10294. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10295. v := m.addnumber
  10296. if v == nil {
  10297. return
  10298. }
  10299. return *v, true
  10300. }
  10301. // ResetNumber resets all changes to the "number" field.
  10302. func (m *CreditUsageMutation) ResetNumber() {
  10303. m.number = nil
  10304. m.addnumber = nil
  10305. }
  10306. // SetStatus sets the "status" field.
  10307. func (m *CreditUsageMutation) SetStatus(i int) {
  10308. m.status = &i
  10309. m.addstatus = nil
  10310. }
  10311. // Status returns the value of the "status" field in the mutation.
  10312. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10313. v := m.status
  10314. if v == nil {
  10315. return
  10316. }
  10317. return *v, true
  10318. }
  10319. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10320. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10322. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10323. if !m.op.Is(OpUpdateOne) {
  10324. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10325. }
  10326. if m.id == nil || m.oldValue == nil {
  10327. return v, errors.New("OldStatus requires an ID field in the mutation")
  10328. }
  10329. oldValue, err := m.oldValue(ctx)
  10330. if err != nil {
  10331. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10332. }
  10333. return oldValue.Status, nil
  10334. }
  10335. // AddStatus adds i to the "status" field.
  10336. func (m *CreditUsageMutation) AddStatus(i int) {
  10337. if m.addstatus != nil {
  10338. *m.addstatus += i
  10339. } else {
  10340. m.addstatus = &i
  10341. }
  10342. }
  10343. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10344. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10345. v := m.addstatus
  10346. if v == nil {
  10347. return
  10348. }
  10349. return *v, true
  10350. }
  10351. // ClearStatus clears the value of the "status" field.
  10352. func (m *CreditUsageMutation) ClearStatus() {
  10353. m.status = nil
  10354. m.addstatus = nil
  10355. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10356. }
  10357. // StatusCleared returns if the "status" field was cleared in this mutation.
  10358. func (m *CreditUsageMutation) StatusCleared() bool {
  10359. _, ok := m.clearedFields[creditusage.FieldStatus]
  10360. return ok
  10361. }
  10362. // ResetStatus resets all changes to the "status" field.
  10363. func (m *CreditUsageMutation) ResetStatus() {
  10364. m.status = nil
  10365. m.addstatus = nil
  10366. delete(m.clearedFields, creditusage.FieldStatus)
  10367. }
  10368. // SetNtype sets the "ntype" field.
  10369. func (m *CreditUsageMutation) SetNtype(i int) {
  10370. m.ntype = &i
  10371. m.addntype = nil
  10372. }
  10373. // Ntype returns the value of the "ntype" field in the mutation.
  10374. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10375. v := m.ntype
  10376. if v == nil {
  10377. return
  10378. }
  10379. return *v, true
  10380. }
  10381. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10382. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10384. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10385. if !m.op.Is(OpUpdateOne) {
  10386. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10387. }
  10388. if m.id == nil || m.oldValue == nil {
  10389. return v, errors.New("OldNtype requires an ID field in the mutation")
  10390. }
  10391. oldValue, err := m.oldValue(ctx)
  10392. if err != nil {
  10393. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10394. }
  10395. return oldValue.Ntype, nil
  10396. }
  10397. // AddNtype adds i to the "ntype" field.
  10398. func (m *CreditUsageMutation) AddNtype(i int) {
  10399. if m.addntype != nil {
  10400. *m.addntype += i
  10401. } else {
  10402. m.addntype = &i
  10403. }
  10404. }
  10405. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10406. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10407. v := m.addntype
  10408. if v == nil {
  10409. return
  10410. }
  10411. return *v, true
  10412. }
  10413. // ResetNtype resets all changes to the "ntype" field.
  10414. func (m *CreditUsageMutation) ResetNtype() {
  10415. m.ntype = nil
  10416. m.addntype = nil
  10417. }
  10418. // SetTable sets the "table" field.
  10419. func (m *CreditUsageMutation) SetTable(s string) {
  10420. m.table = &s
  10421. }
  10422. // Table returns the value of the "table" field in the mutation.
  10423. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10424. v := m.table
  10425. if v == nil {
  10426. return
  10427. }
  10428. return *v, true
  10429. }
  10430. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10431. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10433. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10434. if !m.op.Is(OpUpdateOne) {
  10435. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10436. }
  10437. if m.id == nil || m.oldValue == nil {
  10438. return v, errors.New("OldTable requires an ID field in the mutation")
  10439. }
  10440. oldValue, err := m.oldValue(ctx)
  10441. if err != nil {
  10442. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10443. }
  10444. return oldValue.Table, nil
  10445. }
  10446. // ResetTable resets all changes to the "table" field.
  10447. func (m *CreditUsageMutation) ResetTable() {
  10448. m.table = nil
  10449. }
  10450. // SetOrganizationID sets the "organization_id" field.
  10451. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10452. m.organization_id = &u
  10453. m.addorganization_id = nil
  10454. }
  10455. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10456. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10457. v := m.organization_id
  10458. if v == nil {
  10459. return
  10460. }
  10461. return *v, true
  10462. }
  10463. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10464. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10466. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10467. if !m.op.Is(OpUpdateOne) {
  10468. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10469. }
  10470. if m.id == nil || m.oldValue == nil {
  10471. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10472. }
  10473. oldValue, err := m.oldValue(ctx)
  10474. if err != nil {
  10475. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10476. }
  10477. return oldValue.OrganizationID, nil
  10478. }
  10479. // AddOrganizationID adds u to the "organization_id" field.
  10480. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10481. if m.addorganization_id != nil {
  10482. *m.addorganization_id += u
  10483. } else {
  10484. m.addorganization_id = &u
  10485. }
  10486. }
  10487. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10488. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10489. v := m.addorganization_id
  10490. if v == nil {
  10491. return
  10492. }
  10493. return *v, true
  10494. }
  10495. // ResetOrganizationID resets all changes to the "organization_id" field.
  10496. func (m *CreditUsageMutation) ResetOrganizationID() {
  10497. m.organization_id = nil
  10498. m.addorganization_id = nil
  10499. }
  10500. // SetNid sets the "nid" field.
  10501. func (m *CreditUsageMutation) SetNid(u uint64) {
  10502. m.nid = &u
  10503. m.addnid = nil
  10504. }
  10505. // Nid returns the value of the "nid" field in the mutation.
  10506. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10507. v := m.nid
  10508. if v == nil {
  10509. return
  10510. }
  10511. return *v, true
  10512. }
  10513. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10514. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10516. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10517. if !m.op.Is(OpUpdateOne) {
  10518. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10519. }
  10520. if m.id == nil || m.oldValue == nil {
  10521. return v, errors.New("OldNid requires an ID field in the mutation")
  10522. }
  10523. oldValue, err := m.oldValue(ctx)
  10524. if err != nil {
  10525. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10526. }
  10527. return oldValue.Nid, nil
  10528. }
  10529. // AddNid adds u to the "nid" field.
  10530. func (m *CreditUsageMutation) AddNid(u int64) {
  10531. if m.addnid != nil {
  10532. *m.addnid += u
  10533. } else {
  10534. m.addnid = &u
  10535. }
  10536. }
  10537. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10538. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10539. v := m.addnid
  10540. if v == nil {
  10541. return
  10542. }
  10543. return *v, true
  10544. }
  10545. // ResetNid resets all changes to the "nid" field.
  10546. func (m *CreditUsageMutation) ResetNid() {
  10547. m.nid = nil
  10548. m.addnid = nil
  10549. }
  10550. // SetReason sets the "reason" field.
  10551. func (m *CreditUsageMutation) SetReason(s string) {
  10552. m.reason = &s
  10553. }
  10554. // Reason returns the value of the "reason" field in the mutation.
  10555. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10556. v := m.reason
  10557. if v == nil {
  10558. return
  10559. }
  10560. return *v, true
  10561. }
  10562. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10563. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10565. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10566. if !m.op.Is(OpUpdateOne) {
  10567. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10568. }
  10569. if m.id == nil || m.oldValue == nil {
  10570. return v, errors.New("OldReason requires an ID field in the mutation")
  10571. }
  10572. oldValue, err := m.oldValue(ctx)
  10573. if err != nil {
  10574. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10575. }
  10576. return oldValue.Reason, nil
  10577. }
  10578. // ResetReason resets all changes to the "reason" field.
  10579. func (m *CreditUsageMutation) ResetReason() {
  10580. m.reason = nil
  10581. }
  10582. // SetOperator sets the "operator" field.
  10583. func (m *CreditUsageMutation) SetOperator(s string) {
  10584. m.operator = &s
  10585. }
  10586. // Operator returns the value of the "operator" field in the mutation.
  10587. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10588. v := m.operator
  10589. if v == nil {
  10590. return
  10591. }
  10592. return *v, true
  10593. }
  10594. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10595. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10597. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10598. if !m.op.Is(OpUpdateOne) {
  10599. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10600. }
  10601. if m.id == nil || m.oldValue == nil {
  10602. return v, errors.New("OldOperator requires an ID field in the mutation")
  10603. }
  10604. oldValue, err := m.oldValue(ctx)
  10605. if err != nil {
  10606. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10607. }
  10608. return oldValue.Operator, nil
  10609. }
  10610. // ResetOperator resets all changes to the "operator" field.
  10611. func (m *CreditUsageMutation) ResetOperator() {
  10612. m.operator = nil
  10613. }
  10614. // Where appends a list predicates to the CreditUsageMutation builder.
  10615. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10616. m.predicates = append(m.predicates, ps...)
  10617. }
  10618. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10619. // users can use type-assertion to append predicates that do not depend on any generated package.
  10620. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10621. p := make([]predicate.CreditUsage, len(ps))
  10622. for i := range ps {
  10623. p[i] = ps[i]
  10624. }
  10625. m.Where(p...)
  10626. }
  10627. // Op returns the operation name.
  10628. func (m *CreditUsageMutation) Op() Op {
  10629. return m.op
  10630. }
  10631. // SetOp allows setting the mutation operation.
  10632. func (m *CreditUsageMutation) SetOp(op Op) {
  10633. m.op = op
  10634. }
  10635. // Type returns the node type of this mutation (CreditUsage).
  10636. func (m *CreditUsageMutation) Type() string {
  10637. return m.typ
  10638. }
  10639. // Fields returns all fields that were changed during this mutation. Note that in
  10640. // order to get all numeric fields that were incremented/decremented, call
  10641. // AddedFields().
  10642. func (m *CreditUsageMutation) Fields() []string {
  10643. fields := make([]string, 0, 12)
  10644. if m.created_at != nil {
  10645. fields = append(fields, creditusage.FieldCreatedAt)
  10646. }
  10647. if m.updated_at != nil {
  10648. fields = append(fields, creditusage.FieldUpdatedAt)
  10649. }
  10650. if m.deleted_at != nil {
  10651. fields = append(fields, creditusage.FieldDeletedAt)
  10652. }
  10653. if m.user_id != nil {
  10654. fields = append(fields, creditusage.FieldUserID)
  10655. }
  10656. if m.number != nil {
  10657. fields = append(fields, creditusage.FieldNumber)
  10658. }
  10659. if m.status != nil {
  10660. fields = append(fields, creditusage.FieldStatus)
  10661. }
  10662. if m.ntype != nil {
  10663. fields = append(fields, creditusage.FieldNtype)
  10664. }
  10665. if m.table != nil {
  10666. fields = append(fields, creditusage.FieldTable)
  10667. }
  10668. if m.organization_id != nil {
  10669. fields = append(fields, creditusage.FieldOrganizationID)
  10670. }
  10671. if m.nid != nil {
  10672. fields = append(fields, creditusage.FieldNid)
  10673. }
  10674. if m.reason != nil {
  10675. fields = append(fields, creditusage.FieldReason)
  10676. }
  10677. if m.operator != nil {
  10678. fields = append(fields, creditusage.FieldOperator)
  10679. }
  10680. return fields
  10681. }
  10682. // Field returns the value of a field with the given name. The second boolean
  10683. // return value indicates that this field was not set, or was not defined in the
  10684. // schema.
  10685. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10686. switch name {
  10687. case creditusage.FieldCreatedAt:
  10688. return m.CreatedAt()
  10689. case creditusage.FieldUpdatedAt:
  10690. return m.UpdatedAt()
  10691. case creditusage.FieldDeletedAt:
  10692. return m.DeletedAt()
  10693. case creditusage.FieldUserID:
  10694. return m.UserID()
  10695. case creditusage.FieldNumber:
  10696. return m.Number()
  10697. case creditusage.FieldStatus:
  10698. return m.Status()
  10699. case creditusage.FieldNtype:
  10700. return m.Ntype()
  10701. case creditusage.FieldTable:
  10702. return m.Table()
  10703. case creditusage.FieldOrganizationID:
  10704. return m.OrganizationID()
  10705. case creditusage.FieldNid:
  10706. return m.Nid()
  10707. case creditusage.FieldReason:
  10708. return m.Reason()
  10709. case creditusage.FieldOperator:
  10710. return m.Operator()
  10711. }
  10712. return nil, false
  10713. }
  10714. // OldField returns the old value of the field from the database. An error is
  10715. // returned if the mutation operation is not UpdateOne, or the query to the
  10716. // database failed.
  10717. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10718. switch name {
  10719. case creditusage.FieldCreatedAt:
  10720. return m.OldCreatedAt(ctx)
  10721. case creditusage.FieldUpdatedAt:
  10722. return m.OldUpdatedAt(ctx)
  10723. case creditusage.FieldDeletedAt:
  10724. return m.OldDeletedAt(ctx)
  10725. case creditusage.FieldUserID:
  10726. return m.OldUserID(ctx)
  10727. case creditusage.FieldNumber:
  10728. return m.OldNumber(ctx)
  10729. case creditusage.FieldStatus:
  10730. return m.OldStatus(ctx)
  10731. case creditusage.FieldNtype:
  10732. return m.OldNtype(ctx)
  10733. case creditusage.FieldTable:
  10734. return m.OldTable(ctx)
  10735. case creditusage.FieldOrganizationID:
  10736. return m.OldOrganizationID(ctx)
  10737. case creditusage.FieldNid:
  10738. return m.OldNid(ctx)
  10739. case creditusage.FieldReason:
  10740. return m.OldReason(ctx)
  10741. case creditusage.FieldOperator:
  10742. return m.OldOperator(ctx)
  10743. }
  10744. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10745. }
  10746. // SetField sets the value of a field with the given name. It returns an error if
  10747. // the field is not defined in the schema, or if the type mismatched the field
  10748. // type.
  10749. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10750. switch name {
  10751. case creditusage.FieldCreatedAt:
  10752. v, ok := value.(time.Time)
  10753. if !ok {
  10754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10755. }
  10756. m.SetCreatedAt(v)
  10757. return nil
  10758. case creditusage.FieldUpdatedAt:
  10759. v, ok := value.(time.Time)
  10760. if !ok {
  10761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10762. }
  10763. m.SetUpdatedAt(v)
  10764. return nil
  10765. case creditusage.FieldDeletedAt:
  10766. v, ok := value.(time.Time)
  10767. if !ok {
  10768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10769. }
  10770. m.SetDeletedAt(v)
  10771. return nil
  10772. case creditusage.FieldUserID:
  10773. v, ok := value.(string)
  10774. if !ok {
  10775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10776. }
  10777. m.SetUserID(v)
  10778. return nil
  10779. case creditusage.FieldNumber:
  10780. v, ok := value.(float32)
  10781. if !ok {
  10782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10783. }
  10784. m.SetNumber(v)
  10785. return nil
  10786. case creditusage.FieldStatus:
  10787. v, ok := value.(int)
  10788. if !ok {
  10789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10790. }
  10791. m.SetStatus(v)
  10792. return nil
  10793. case creditusage.FieldNtype:
  10794. v, ok := value.(int)
  10795. if !ok {
  10796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10797. }
  10798. m.SetNtype(v)
  10799. return nil
  10800. case creditusage.FieldTable:
  10801. v, ok := value.(string)
  10802. if !ok {
  10803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10804. }
  10805. m.SetTable(v)
  10806. return nil
  10807. case creditusage.FieldOrganizationID:
  10808. v, ok := value.(uint64)
  10809. if !ok {
  10810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10811. }
  10812. m.SetOrganizationID(v)
  10813. return nil
  10814. case creditusage.FieldNid:
  10815. v, ok := value.(uint64)
  10816. if !ok {
  10817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10818. }
  10819. m.SetNid(v)
  10820. return nil
  10821. case creditusage.FieldReason:
  10822. v, ok := value.(string)
  10823. if !ok {
  10824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10825. }
  10826. m.SetReason(v)
  10827. return nil
  10828. case creditusage.FieldOperator:
  10829. v, ok := value.(string)
  10830. if !ok {
  10831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10832. }
  10833. m.SetOperator(v)
  10834. return nil
  10835. }
  10836. return fmt.Errorf("unknown CreditUsage field %s", name)
  10837. }
  10838. // AddedFields returns all numeric fields that were incremented/decremented during
  10839. // this mutation.
  10840. func (m *CreditUsageMutation) AddedFields() []string {
  10841. var fields []string
  10842. if m.addnumber != nil {
  10843. fields = append(fields, creditusage.FieldNumber)
  10844. }
  10845. if m.addstatus != nil {
  10846. fields = append(fields, creditusage.FieldStatus)
  10847. }
  10848. if m.addntype != nil {
  10849. fields = append(fields, creditusage.FieldNtype)
  10850. }
  10851. if m.addorganization_id != nil {
  10852. fields = append(fields, creditusage.FieldOrganizationID)
  10853. }
  10854. if m.addnid != nil {
  10855. fields = append(fields, creditusage.FieldNid)
  10856. }
  10857. return fields
  10858. }
  10859. // AddedField returns the numeric value that was incremented/decremented on a field
  10860. // with the given name. The second boolean return value indicates that this field
  10861. // was not set, or was not defined in the schema.
  10862. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10863. switch name {
  10864. case creditusage.FieldNumber:
  10865. return m.AddedNumber()
  10866. case creditusage.FieldStatus:
  10867. return m.AddedStatus()
  10868. case creditusage.FieldNtype:
  10869. return m.AddedNtype()
  10870. case creditusage.FieldOrganizationID:
  10871. return m.AddedOrganizationID()
  10872. case creditusage.FieldNid:
  10873. return m.AddedNid()
  10874. }
  10875. return nil, false
  10876. }
  10877. // AddField adds the value to the field with the given name. It returns an error if
  10878. // the field is not defined in the schema, or if the type mismatched the field
  10879. // type.
  10880. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  10881. switch name {
  10882. case creditusage.FieldNumber:
  10883. v, ok := value.(float32)
  10884. if !ok {
  10885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10886. }
  10887. m.AddNumber(v)
  10888. return nil
  10889. case creditusage.FieldStatus:
  10890. v, ok := value.(int)
  10891. if !ok {
  10892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10893. }
  10894. m.AddStatus(v)
  10895. return nil
  10896. case creditusage.FieldNtype:
  10897. v, ok := value.(int)
  10898. if !ok {
  10899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10900. }
  10901. m.AddNtype(v)
  10902. return nil
  10903. case creditusage.FieldOrganizationID:
  10904. v, ok := value.(int64)
  10905. if !ok {
  10906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10907. }
  10908. m.AddOrganizationID(v)
  10909. return nil
  10910. case creditusage.FieldNid:
  10911. v, ok := value.(int64)
  10912. if !ok {
  10913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10914. }
  10915. m.AddNid(v)
  10916. return nil
  10917. }
  10918. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  10919. }
  10920. // ClearedFields returns all nullable fields that were cleared during this
  10921. // mutation.
  10922. func (m *CreditUsageMutation) ClearedFields() []string {
  10923. var fields []string
  10924. if m.FieldCleared(creditusage.FieldDeletedAt) {
  10925. fields = append(fields, creditusage.FieldDeletedAt)
  10926. }
  10927. if m.FieldCleared(creditusage.FieldStatus) {
  10928. fields = append(fields, creditusage.FieldStatus)
  10929. }
  10930. return fields
  10931. }
  10932. // FieldCleared returns a boolean indicating if a field with the given name was
  10933. // cleared in this mutation.
  10934. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  10935. _, ok := m.clearedFields[name]
  10936. return ok
  10937. }
  10938. // ClearField clears the value of the field with the given name. It returns an
  10939. // error if the field is not defined in the schema.
  10940. func (m *CreditUsageMutation) ClearField(name string) error {
  10941. switch name {
  10942. case creditusage.FieldDeletedAt:
  10943. m.ClearDeletedAt()
  10944. return nil
  10945. case creditusage.FieldStatus:
  10946. m.ClearStatus()
  10947. return nil
  10948. }
  10949. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  10950. }
  10951. // ResetField resets all changes in the mutation for the field with the given name.
  10952. // It returns an error if the field is not defined in the schema.
  10953. func (m *CreditUsageMutation) ResetField(name string) error {
  10954. switch name {
  10955. case creditusage.FieldCreatedAt:
  10956. m.ResetCreatedAt()
  10957. return nil
  10958. case creditusage.FieldUpdatedAt:
  10959. m.ResetUpdatedAt()
  10960. return nil
  10961. case creditusage.FieldDeletedAt:
  10962. m.ResetDeletedAt()
  10963. return nil
  10964. case creditusage.FieldUserID:
  10965. m.ResetUserID()
  10966. return nil
  10967. case creditusage.FieldNumber:
  10968. m.ResetNumber()
  10969. return nil
  10970. case creditusage.FieldStatus:
  10971. m.ResetStatus()
  10972. return nil
  10973. case creditusage.FieldNtype:
  10974. m.ResetNtype()
  10975. return nil
  10976. case creditusage.FieldTable:
  10977. m.ResetTable()
  10978. return nil
  10979. case creditusage.FieldOrganizationID:
  10980. m.ResetOrganizationID()
  10981. return nil
  10982. case creditusage.FieldNid:
  10983. m.ResetNid()
  10984. return nil
  10985. case creditusage.FieldReason:
  10986. m.ResetReason()
  10987. return nil
  10988. case creditusage.FieldOperator:
  10989. m.ResetOperator()
  10990. return nil
  10991. }
  10992. return fmt.Errorf("unknown CreditUsage field %s", name)
  10993. }
  10994. // AddedEdges returns all edge names that were set/added in this mutation.
  10995. func (m *CreditUsageMutation) AddedEdges() []string {
  10996. edges := make([]string, 0, 0)
  10997. return edges
  10998. }
  10999. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11000. // name in this mutation.
  11001. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11002. return nil
  11003. }
  11004. // RemovedEdges returns all edge names that were removed in this mutation.
  11005. func (m *CreditUsageMutation) RemovedEdges() []string {
  11006. edges := make([]string, 0, 0)
  11007. return edges
  11008. }
  11009. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11010. // the given name in this mutation.
  11011. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11012. return nil
  11013. }
  11014. // ClearedEdges returns all edge names that were cleared in this mutation.
  11015. func (m *CreditUsageMutation) ClearedEdges() []string {
  11016. edges := make([]string, 0, 0)
  11017. return edges
  11018. }
  11019. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11020. // was cleared in this mutation.
  11021. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11022. return false
  11023. }
  11024. // ClearEdge clears the value of the edge with the given name. It returns an error
  11025. // if that edge is not defined in the schema.
  11026. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11027. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11028. }
  11029. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11030. // It returns an error if the edge is not defined in the schema.
  11031. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11032. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11033. }
  11034. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11035. type EmployeeMutation struct {
  11036. config
  11037. op Op
  11038. typ string
  11039. id *uint64
  11040. created_at *time.Time
  11041. updated_at *time.Time
  11042. deleted_at *time.Time
  11043. title *string
  11044. avatar *string
  11045. tags *string
  11046. hire_count *int
  11047. addhire_count *int
  11048. service_count *int
  11049. addservice_count *int
  11050. achievement_count *int
  11051. addachievement_count *int
  11052. intro *string
  11053. estimate *string
  11054. skill *string
  11055. ability_type *string
  11056. scene *string
  11057. switch_in *string
  11058. video_url *string
  11059. organization_id *uint64
  11060. addorganization_id *int64
  11061. category_id *uint64
  11062. addcategory_id *int64
  11063. api_base *string
  11064. api_key *string
  11065. ai_info *string
  11066. is_vip *int
  11067. addis_vip *int
  11068. chat_url *string
  11069. clearedFields map[string]struct{}
  11070. em_work_experiences map[uint64]struct{}
  11071. removedem_work_experiences map[uint64]struct{}
  11072. clearedem_work_experiences bool
  11073. em_tutorial map[uint64]struct{}
  11074. removedem_tutorial map[uint64]struct{}
  11075. clearedem_tutorial bool
  11076. done bool
  11077. oldValue func(context.Context) (*Employee, error)
  11078. predicates []predicate.Employee
  11079. }
  11080. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11081. // employeeOption allows management of the mutation configuration using functional options.
  11082. type employeeOption func(*EmployeeMutation)
  11083. // newEmployeeMutation creates new mutation for the Employee entity.
  11084. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11085. m := &EmployeeMutation{
  11086. config: c,
  11087. op: op,
  11088. typ: TypeEmployee,
  11089. clearedFields: make(map[string]struct{}),
  11090. }
  11091. for _, opt := range opts {
  11092. opt(m)
  11093. }
  11094. return m
  11095. }
  11096. // withEmployeeID sets the ID field of the mutation.
  11097. func withEmployeeID(id uint64) employeeOption {
  11098. return func(m *EmployeeMutation) {
  11099. var (
  11100. err error
  11101. once sync.Once
  11102. value *Employee
  11103. )
  11104. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11105. once.Do(func() {
  11106. if m.done {
  11107. err = errors.New("querying old values post mutation is not allowed")
  11108. } else {
  11109. value, err = m.Client().Employee.Get(ctx, id)
  11110. }
  11111. })
  11112. return value, err
  11113. }
  11114. m.id = &id
  11115. }
  11116. }
  11117. // withEmployee sets the old Employee of the mutation.
  11118. func withEmployee(node *Employee) employeeOption {
  11119. return func(m *EmployeeMutation) {
  11120. m.oldValue = func(context.Context) (*Employee, error) {
  11121. return node, nil
  11122. }
  11123. m.id = &node.ID
  11124. }
  11125. }
  11126. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11127. // executed in a transaction (ent.Tx), a transactional client is returned.
  11128. func (m EmployeeMutation) Client() *Client {
  11129. client := &Client{config: m.config}
  11130. client.init()
  11131. return client
  11132. }
  11133. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11134. // it returns an error otherwise.
  11135. func (m EmployeeMutation) Tx() (*Tx, error) {
  11136. if _, ok := m.driver.(*txDriver); !ok {
  11137. return nil, errors.New("ent: mutation is not running in a transaction")
  11138. }
  11139. tx := &Tx{config: m.config}
  11140. tx.init()
  11141. return tx, nil
  11142. }
  11143. // SetID sets the value of the id field. Note that this
  11144. // operation is only accepted on creation of Employee entities.
  11145. func (m *EmployeeMutation) SetID(id uint64) {
  11146. m.id = &id
  11147. }
  11148. // ID returns the ID value in the mutation. Note that the ID is only available
  11149. // if it was provided to the builder or after it was returned from the database.
  11150. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11151. if m.id == nil {
  11152. return
  11153. }
  11154. return *m.id, true
  11155. }
  11156. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11157. // That means, if the mutation is applied within a transaction with an isolation level such
  11158. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11159. // or updated by the mutation.
  11160. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11161. switch {
  11162. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11163. id, exists := m.ID()
  11164. if exists {
  11165. return []uint64{id}, nil
  11166. }
  11167. fallthrough
  11168. case m.op.Is(OpUpdate | OpDelete):
  11169. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11170. default:
  11171. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11172. }
  11173. }
  11174. // SetCreatedAt sets the "created_at" field.
  11175. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11176. m.created_at = &t
  11177. }
  11178. // CreatedAt returns the value of the "created_at" field in the mutation.
  11179. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11180. v := m.created_at
  11181. if v == nil {
  11182. return
  11183. }
  11184. return *v, true
  11185. }
  11186. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11187. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11189. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11190. if !m.op.Is(OpUpdateOne) {
  11191. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11192. }
  11193. if m.id == nil || m.oldValue == nil {
  11194. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11195. }
  11196. oldValue, err := m.oldValue(ctx)
  11197. if err != nil {
  11198. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11199. }
  11200. return oldValue.CreatedAt, nil
  11201. }
  11202. // ResetCreatedAt resets all changes to the "created_at" field.
  11203. func (m *EmployeeMutation) ResetCreatedAt() {
  11204. m.created_at = nil
  11205. }
  11206. // SetUpdatedAt sets the "updated_at" field.
  11207. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11208. m.updated_at = &t
  11209. }
  11210. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11211. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11212. v := m.updated_at
  11213. if v == nil {
  11214. return
  11215. }
  11216. return *v, true
  11217. }
  11218. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11219. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11221. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11222. if !m.op.Is(OpUpdateOne) {
  11223. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11224. }
  11225. if m.id == nil || m.oldValue == nil {
  11226. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11227. }
  11228. oldValue, err := m.oldValue(ctx)
  11229. if err != nil {
  11230. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11231. }
  11232. return oldValue.UpdatedAt, nil
  11233. }
  11234. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11235. func (m *EmployeeMutation) ResetUpdatedAt() {
  11236. m.updated_at = nil
  11237. }
  11238. // SetDeletedAt sets the "deleted_at" field.
  11239. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11240. m.deleted_at = &t
  11241. }
  11242. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11243. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11244. v := m.deleted_at
  11245. if v == nil {
  11246. return
  11247. }
  11248. return *v, true
  11249. }
  11250. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11251. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11253. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11254. if !m.op.Is(OpUpdateOne) {
  11255. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11256. }
  11257. if m.id == nil || m.oldValue == nil {
  11258. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11259. }
  11260. oldValue, err := m.oldValue(ctx)
  11261. if err != nil {
  11262. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11263. }
  11264. return oldValue.DeletedAt, nil
  11265. }
  11266. // ClearDeletedAt clears the value of the "deleted_at" field.
  11267. func (m *EmployeeMutation) ClearDeletedAt() {
  11268. m.deleted_at = nil
  11269. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11270. }
  11271. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11272. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11273. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11274. return ok
  11275. }
  11276. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11277. func (m *EmployeeMutation) ResetDeletedAt() {
  11278. m.deleted_at = nil
  11279. delete(m.clearedFields, employee.FieldDeletedAt)
  11280. }
  11281. // SetTitle sets the "title" field.
  11282. func (m *EmployeeMutation) SetTitle(s string) {
  11283. m.title = &s
  11284. }
  11285. // Title returns the value of the "title" field in the mutation.
  11286. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11287. v := m.title
  11288. if v == nil {
  11289. return
  11290. }
  11291. return *v, true
  11292. }
  11293. // OldTitle returns the old "title" field's value of the Employee entity.
  11294. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11296. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11297. if !m.op.Is(OpUpdateOne) {
  11298. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11299. }
  11300. if m.id == nil || m.oldValue == nil {
  11301. return v, errors.New("OldTitle requires an ID field in the mutation")
  11302. }
  11303. oldValue, err := m.oldValue(ctx)
  11304. if err != nil {
  11305. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11306. }
  11307. return oldValue.Title, nil
  11308. }
  11309. // ResetTitle resets all changes to the "title" field.
  11310. func (m *EmployeeMutation) ResetTitle() {
  11311. m.title = nil
  11312. }
  11313. // SetAvatar sets the "avatar" field.
  11314. func (m *EmployeeMutation) SetAvatar(s string) {
  11315. m.avatar = &s
  11316. }
  11317. // Avatar returns the value of the "avatar" field in the mutation.
  11318. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11319. v := m.avatar
  11320. if v == nil {
  11321. return
  11322. }
  11323. return *v, true
  11324. }
  11325. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11326. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11328. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11329. if !m.op.Is(OpUpdateOne) {
  11330. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11331. }
  11332. if m.id == nil || m.oldValue == nil {
  11333. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11334. }
  11335. oldValue, err := m.oldValue(ctx)
  11336. if err != nil {
  11337. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11338. }
  11339. return oldValue.Avatar, nil
  11340. }
  11341. // ResetAvatar resets all changes to the "avatar" field.
  11342. func (m *EmployeeMutation) ResetAvatar() {
  11343. m.avatar = nil
  11344. }
  11345. // SetTags sets the "tags" field.
  11346. func (m *EmployeeMutation) SetTags(s string) {
  11347. m.tags = &s
  11348. }
  11349. // Tags returns the value of the "tags" field in the mutation.
  11350. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11351. v := m.tags
  11352. if v == nil {
  11353. return
  11354. }
  11355. return *v, true
  11356. }
  11357. // OldTags returns the old "tags" field's value of the Employee entity.
  11358. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11360. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11361. if !m.op.Is(OpUpdateOne) {
  11362. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11363. }
  11364. if m.id == nil || m.oldValue == nil {
  11365. return v, errors.New("OldTags requires an ID field in the mutation")
  11366. }
  11367. oldValue, err := m.oldValue(ctx)
  11368. if err != nil {
  11369. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11370. }
  11371. return oldValue.Tags, nil
  11372. }
  11373. // ResetTags resets all changes to the "tags" field.
  11374. func (m *EmployeeMutation) ResetTags() {
  11375. m.tags = nil
  11376. }
  11377. // SetHireCount sets the "hire_count" field.
  11378. func (m *EmployeeMutation) SetHireCount(i int) {
  11379. m.hire_count = &i
  11380. m.addhire_count = nil
  11381. }
  11382. // HireCount returns the value of the "hire_count" field in the mutation.
  11383. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11384. v := m.hire_count
  11385. if v == nil {
  11386. return
  11387. }
  11388. return *v, true
  11389. }
  11390. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11391. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11393. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11394. if !m.op.Is(OpUpdateOne) {
  11395. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11396. }
  11397. if m.id == nil || m.oldValue == nil {
  11398. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11399. }
  11400. oldValue, err := m.oldValue(ctx)
  11401. if err != nil {
  11402. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11403. }
  11404. return oldValue.HireCount, nil
  11405. }
  11406. // AddHireCount adds i to the "hire_count" field.
  11407. func (m *EmployeeMutation) AddHireCount(i int) {
  11408. if m.addhire_count != nil {
  11409. *m.addhire_count += i
  11410. } else {
  11411. m.addhire_count = &i
  11412. }
  11413. }
  11414. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11415. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11416. v := m.addhire_count
  11417. if v == nil {
  11418. return
  11419. }
  11420. return *v, true
  11421. }
  11422. // ResetHireCount resets all changes to the "hire_count" field.
  11423. func (m *EmployeeMutation) ResetHireCount() {
  11424. m.hire_count = nil
  11425. m.addhire_count = nil
  11426. }
  11427. // SetServiceCount sets the "service_count" field.
  11428. func (m *EmployeeMutation) SetServiceCount(i int) {
  11429. m.service_count = &i
  11430. m.addservice_count = nil
  11431. }
  11432. // ServiceCount returns the value of the "service_count" field in the mutation.
  11433. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11434. v := m.service_count
  11435. if v == nil {
  11436. return
  11437. }
  11438. return *v, true
  11439. }
  11440. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11441. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11443. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11444. if !m.op.Is(OpUpdateOne) {
  11445. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11446. }
  11447. if m.id == nil || m.oldValue == nil {
  11448. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11449. }
  11450. oldValue, err := m.oldValue(ctx)
  11451. if err != nil {
  11452. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11453. }
  11454. return oldValue.ServiceCount, nil
  11455. }
  11456. // AddServiceCount adds i to the "service_count" field.
  11457. func (m *EmployeeMutation) AddServiceCount(i int) {
  11458. if m.addservice_count != nil {
  11459. *m.addservice_count += i
  11460. } else {
  11461. m.addservice_count = &i
  11462. }
  11463. }
  11464. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11465. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11466. v := m.addservice_count
  11467. if v == nil {
  11468. return
  11469. }
  11470. return *v, true
  11471. }
  11472. // ResetServiceCount resets all changes to the "service_count" field.
  11473. func (m *EmployeeMutation) ResetServiceCount() {
  11474. m.service_count = nil
  11475. m.addservice_count = nil
  11476. }
  11477. // SetAchievementCount sets the "achievement_count" field.
  11478. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11479. m.achievement_count = &i
  11480. m.addachievement_count = nil
  11481. }
  11482. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11483. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11484. v := m.achievement_count
  11485. if v == nil {
  11486. return
  11487. }
  11488. return *v, true
  11489. }
  11490. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11491. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11493. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11494. if !m.op.Is(OpUpdateOne) {
  11495. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11496. }
  11497. if m.id == nil || m.oldValue == nil {
  11498. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11499. }
  11500. oldValue, err := m.oldValue(ctx)
  11501. if err != nil {
  11502. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11503. }
  11504. return oldValue.AchievementCount, nil
  11505. }
  11506. // AddAchievementCount adds i to the "achievement_count" field.
  11507. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11508. if m.addachievement_count != nil {
  11509. *m.addachievement_count += i
  11510. } else {
  11511. m.addachievement_count = &i
  11512. }
  11513. }
  11514. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11515. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11516. v := m.addachievement_count
  11517. if v == nil {
  11518. return
  11519. }
  11520. return *v, true
  11521. }
  11522. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11523. func (m *EmployeeMutation) ResetAchievementCount() {
  11524. m.achievement_count = nil
  11525. m.addachievement_count = nil
  11526. }
  11527. // SetIntro sets the "intro" field.
  11528. func (m *EmployeeMutation) SetIntro(s string) {
  11529. m.intro = &s
  11530. }
  11531. // Intro returns the value of the "intro" field in the mutation.
  11532. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11533. v := m.intro
  11534. if v == nil {
  11535. return
  11536. }
  11537. return *v, true
  11538. }
  11539. // OldIntro returns the old "intro" field's value of the Employee entity.
  11540. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11542. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11543. if !m.op.Is(OpUpdateOne) {
  11544. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11545. }
  11546. if m.id == nil || m.oldValue == nil {
  11547. return v, errors.New("OldIntro requires an ID field in the mutation")
  11548. }
  11549. oldValue, err := m.oldValue(ctx)
  11550. if err != nil {
  11551. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11552. }
  11553. return oldValue.Intro, nil
  11554. }
  11555. // ResetIntro resets all changes to the "intro" field.
  11556. func (m *EmployeeMutation) ResetIntro() {
  11557. m.intro = nil
  11558. }
  11559. // SetEstimate sets the "estimate" field.
  11560. func (m *EmployeeMutation) SetEstimate(s string) {
  11561. m.estimate = &s
  11562. }
  11563. // Estimate returns the value of the "estimate" field in the mutation.
  11564. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11565. v := m.estimate
  11566. if v == nil {
  11567. return
  11568. }
  11569. return *v, true
  11570. }
  11571. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11572. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11574. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11575. if !m.op.Is(OpUpdateOne) {
  11576. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11577. }
  11578. if m.id == nil || m.oldValue == nil {
  11579. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11580. }
  11581. oldValue, err := m.oldValue(ctx)
  11582. if err != nil {
  11583. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11584. }
  11585. return oldValue.Estimate, nil
  11586. }
  11587. // ResetEstimate resets all changes to the "estimate" field.
  11588. func (m *EmployeeMutation) ResetEstimate() {
  11589. m.estimate = nil
  11590. }
  11591. // SetSkill sets the "skill" field.
  11592. func (m *EmployeeMutation) SetSkill(s string) {
  11593. m.skill = &s
  11594. }
  11595. // Skill returns the value of the "skill" field in the mutation.
  11596. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11597. v := m.skill
  11598. if v == nil {
  11599. return
  11600. }
  11601. return *v, true
  11602. }
  11603. // OldSkill returns the old "skill" field's value of the Employee entity.
  11604. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11606. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11607. if !m.op.Is(OpUpdateOne) {
  11608. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11609. }
  11610. if m.id == nil || m.oldValue == nil {
  11611. return v, errors.New("OldSkill requires an ID field in the mutation")
  11612. }
  11613. oldValue, err := m.oldValue(ctx)
  11614. if err != nil {
  11615. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11616. }
  11617. return oldValue.Skill, nil
  11618. }
  11619. // ResetSkill resets all changes to the "skill" field.
  11620. func (m *EmployeeMutation) ResetSkill() {
  11621. m.skill = nil
  11622. }
  11623. // SetAbilityType sets the "ability_type" field.
  11624. func (m *EmployeeMutation) SetAbilityType(s string) {
  11625. m.ability_type = &s
  11626. }
  11627. // AbilityType returns the value of the "ability_type" field in the mutation.
  11628. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11629. v := m.ability_type
  11630. if v == nil {
  11631. return
  11632. }
  11633. return *v, true
  11634. }
  11635. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11636. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11638. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11639. if !m.op.Is(OpUpdateOne) {
  11640. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11641. }
  11642. if m.id == nil || m.oldValue == nil {
  11643. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11644. }
  11645. oldValue, err := m.oldValue(ctx)
  11646. if err != nil {
  11647. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11648. }
  11649. return oldValue.AbilityType, nil
  11650. }
  11651. // ResetAbilityType resets all changes to the "ability_type" field.
  11652. func (m *EmployeeMutation) ResetAbilityType() {
  11653. m.ability_type = nil
  11654. }
  11655. // SetScene sets the "scene" field.
  11656. func (m *EmployeeMutation) SetScene(s string) {
  11657. m.scene = &s
  11658. }
  11659. // Scene returns the value of the "scene" field in the mutation.
  11660. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11661. v := m.scene
  11662. if v == nil {
  11663. return
  11664. }
  11665. return *v, true
  11666. }
  11667. // OldScene returns the old "scene" field's value of the Employee entity.
  11668. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11670. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11671. if !m.op.Is(OpUpdateOne) {
  11672. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11673. }
  11674. if m.id == nil || m.oldValue == nil {
  11675. return v, errors.New("OldScene requires an ID field in the mutation")
  11676. }
  11677. oldValue, err := m.oldValue(ctx)
  11678. if err != nil {
  11679. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11680. }
  11681. return oldValue.Scene, nil
  11682. }
  11683. // ResetScene resets all changes to the "scene" field.
  11684. func (m *EmployeeMutation) ResetScene() {
  11685. m.scene = nil
  11686. }
  11687. // SetSwitchIn sets the "switch_in" field.
  11688. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11689. m.switch_in = &s
  11690. }
  11691. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11692. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11693. v := m.switch_in
  11694. if v == nil {
  11695. return
  11696. }
  11697. return *v, true
  11698. }
  11699. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11700. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11702. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11703. if !m.op.Is(OpUpdateOne) {
  11704. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11705. }
  11706. if m.id == nil || m.oldValue == nil {
  11707. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11708. }
  11709. oldValue, err := m.oldValue(ctx)
  11710. if err != nil {
  11711. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11712. }
  11713. return oldValue.SwitchIn, nil
  11714. }
  11715. // ResetSwitchIn resets all changes to the "switch_in" field.
  11716. func (m *EmployeeMutation) ResetSwitchIn() {
  11717. m.switch_in = nil
  11718. }
  11719. // SetVideoURL sets the "video_url" field.
  11720. func (m *EmployeeMutation) SetVideoURL(s string) {
  11721. m.video_url = &s
  11722. }
  11723. // VideoURL returns the value of the "video_url" field in the mutation.
  11724. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11725. v := m.video_url
  11726. if v == nil {
  11727. return
  11728. }
  11729. return *v, true
  11730. }
  11731. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11734. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11735. if !m.op.Is(OpUpdateOne) {
  11736. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11737. }
  11738. if m.id == nil || m.oldValue == nil {
  11739. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11740. }
  11741. oldValue, err := m.oldValue(ctx)
  11742. if err != nil {
  11743. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11744. }
  11745. return oldValue.VideoURL, nil
  11746. }
  11747. // ResetVideoURL resets all changes to the "video_url" field.
  11748. func (m *EmployeeMutation) ResetVideoURL() {
  11749. m.video_url = nil
  11750. }
  11751. // SetOrganizationID sets the "organization_id" field.
  11752. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11753. m.organization_id = &u
  11754. m.addorganization_id = nil
  11755. }
  11756. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11757. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11758. v := m.organization_id
  11759. if v == nil {
  11760. return
  11761. }
  11762. return *v, true
  11763. }
  11764. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11765. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11767. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11768. if !m.op.Is(OpUpdateOne) {
  11769. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11770. }
  11771. if m.id == nil || m.oldValue == nil {
  11772. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11773. }
  11774. oldValue, err := m.oldValue(ctx)
  11775. if err != nil {
  11776. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11777. }
  11778. return oldValue.OrganizationID, nil
  11779. }
  11780. // AddOrganizationID adds u to the "organization_id" field.
  11781. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11782. if m.addorganization_id != nil {
  11783. *m.addorganization_id += u
  11784. } else {
  11785. m.addorganization_id = &u
  11786. }
  11787. }
  11788. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11789. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11790. v := m.addorganization_id
  11791. if v == nil {
  11792. return
  11793. }
  11794. return *v, true
  11795. }
  11796. // ResetOrganizationID resets all changes to the "organization_id" field.
  11797. func (m *EmployeeMutation) ResetOrganizationID() {
  11798. m.organization_id = nil
  11799. m.addorganization_id = nil
  11800. }
  11801. // SetCategoryID sets the "category_id" field.
  11802. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11803. m.category_id = &u
  11804. m.addcategory_id = nil
  11805. }
  11806. // CategoryID returns the value of the "category_id" field in the mutation.
  11807. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11808. v := m.category_id
  11809. if v == nil {
  11810. return
  11811. }
  11812. return *v, true
  11813. }
  11814. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11815. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11817. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11818. if !m.op.Is(OpUpdateOne) {
  11819. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11820. }
  11821. if m.id == nil || m.oldValue == nil {
  11822. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11823. }
  11824. oldValue, err := m.oldValue(ctx)
  11825. if err != nil {
  11826. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11827. }
  11828. return oldValue.CategoryID, nil
  11829. }
  11830. // AddCategoryID adds u to the "category_id" field.
  11831. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11832. if m.addcategory_id != nil {
  11833. *m.addcategory_id += u
  11834. } else {
  11835. m.addcategory_id = &u
  11836. }
  11837. }
  11838. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11839. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11840. v := m.addcategory_id
  11841. if v == nil {
  11842. return
  11843. }
  11844. return *v, true
  11845. }
  11846. // ResetCategoryID resets all changes to the "category_id" field.
  11847. func (m *EmployeeMutation) ResetCategoryID() {
  11848. m.category_id = nil
  11849. m.addcategory_id = nil
  11850. }
  11851. // SetAPIBase sets the "api_base" field.
  11852. func (m *EmployeeMutation) SetAPIBase(s string) {
  11853. m.api_base = &s
  11854. }
  11855. // APIBase returns the value of the "api_base" field in the mutation.
  11856. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11857. v := m.api_base
  11858. if v == nil {
  11859. return
  11860. }
  11861. return *v, true
  11862. }
  11863. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11864. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11866. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11867. if !m.op.Is(OpUpdateOne) {
  11868. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  11869. }
  11870. if m.id == nil || m.oldValue == nil {
  11871. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  11872. }
  11873. oldValue, err := m.oldValue(ctx)
  11874. if err != nil {
  11875. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  11876. }
  11877. return oldValue.APIBase, nil
  11878. }
  11879. // ResetAPIBase resets all changes to the "api_base" field.
  11880. func (m *EmployeeMutation) ResetAPIBase() {
  11881. m.api_base = nil
  11882. }
  11883. // SetAPIKey sets the "api_key" field.
  11884. func (m *EmployeeMutation) SetAPIKey(s string) {
  11885. m.api_key = &s
  11886. }
  11887. // APIKey returns the value of the "api_key" field in the mutation.
  11888. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  11889. v := m.api_key
  11890. if v == nil {
  11891. return
  11892. }
  11893. return *v, true
  11894. }
  11895. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  11896. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11898. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  11899. if !m.op.Is(OpUpdateOne) {
  11900. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  11901. }
  11902. if m.id == nil || m.oldValue == nil {
  11903. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  11904. }
  11905. oldValue, err := m.oldValue(ctx)
  11906. if err != nil {
  11907. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  11908. }
  11909. return oldValue.APIKey, nil
  11910. }
  11911. // ResetAPIKey resets all changes to the "api_key" field.
  11912. func (m *EmployeeMutation) ResetAPIKey() {
  11913. m.api_key = nil
  11914. }
  11915. // SetAiInfo sets the "ai_info" field.
  11916. func (m *EmployeeMutation) SetAiInfo(s string) {
  11917. m.ai_info = &s
  11918. }
  11919. // AiInfo returns the value of the "ai_info" field in the mutation.
  11920. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  11921. v := m.ai_info
  11922. if v == nil {
  11923. return
  11924. }
  11925. return *v, true
  11926. }
  11927. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  11928. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11930. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  11931. if !m.op.Is(OpUpdateOne) {
  11932. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  11933. }
  11934. if m.id == nil || m.oldValue == nil {
  11935. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  11936. }
  11937. oldValue, err := m.oldValue(ctx)
  11938. if err != nil {
  11939. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  11940. }
  11941. return oldValue.AiInfo, nil
  11942. }
  11943. // ClearAiInfo clears the value of the "ai_info" field.
  11944. func (m *EmployeeMutation) ClearAiInfo() {
  11945. m.ai_info = nil
  11946. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  11947. }
  11948. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  11949. func (m *EmployeeMutation) AiInfoCleared() bool {
  11950. _, ok := m.clearedFields[employee.FieldAiInfo]
  11951. return ok
  11952. }
  11953. // ResetAiInfo resets all changes to the "ai_info" field.
  11954. func (m *EmployeeMutation) ResetAiInfo() {
  11955. m.ai_info = nil
  11956. delete(m.clearedFields, employee.FieldAiInfo)
  11957. }
  11958. // SetIsVip sets the "is_vip" field.
  11959. func (m *EmployeeMutation) SetIsVip(i int) {
  11960. m.is_vip = &i
  11961. m.addis_vip = nil
  11962. }
  11963. // IsVip returns the value of the "is_vip" field in the mutation.
  11964. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  11965. v := m.is_vip
  11966. if v == nil {
  11967. return
  11968. }
  11969. return *v, true
  11970. }
  11971. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  11972. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11974. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  11975. if !m.op.Is(OpUpdateOne) {
  11976. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  11977. }
  11978. if m.id == nil || m.oldValue == nil {
  11979. return v, errors.New("OldIsVip requires an ID field in the mutation")
  11980. }
  11981. oldValue, err := m.oldValue(ctx)
  11982. if err != nil {
  11983. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  11984. }
  11985. return oldValue.IsVip, nil
  11986. }
  11987. // AddIsVip adds i to the "is_vip" field.
  11988. func (m *EmployeeMutation) AddIsVip(i int) {
  11989. if m.addis_vip != nil {
  11990. *m.addis_vip += i
  11991. } else {
  11992. m.addis_vip = &i
  11993. }
  11994. }
  11995. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  11996. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  11997. v := m.addis_vip
  11998. if v == nil {
  11999. return
  12000. }
  12001. return *v, true
  12002. }
  12003. // ResetIsVip resets all changes to the "is_vip" field.
  12004. func (m *EmployeeMutation) ResetIsVip() {
  12005. m.is_vip = nil
  12006. m.addis_vip = nil
  12007. }
  12008. // SetChatURL sets the "chat_url" field.
  12009. func (m *EmployeeMutation) SetChatURL(s string) {
  12010. m.chat_url = &s
  12011. }
  12012. // ChatURL returns the value of the "chat_url" field in the mutation.
  12013. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12014. v := m.chat_url
  12015. if v == nil {
  12016. return
  12017. }
  12018. return *v, true
  12019. }
  12020. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12021. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12023. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12024. if !m.op.Is(OpUpdateOne) {
  12025. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12026. }
  12027. if m.id == nil || m.oldValue == nil {
  12028. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12029. }
  12030. oldValue, err := m.oldValue(ctx)
  12031. if err != nil {
  12032. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12033. }
  12034. return oldValue.ChatURL, nil
  12035. }
  12036. // ResetChatURL resets all changes to the "chat_url" field.
  12037. func (m *EmployeeMutation) ResetChatURL() {
  12038. m.chat_url = nil
  12039. }
  12040. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12041. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12042. if m.em_work_experiences == nil {
  12043. m.em_work_experiences = make(map[uint64]struct{})
  12044. }
  12045. for i := range ids {
  12046. m.em_work_experiences[ids[i]] = struct{}{}
  12047. }
  12048. }
  12049. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12050. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12051. m.clearedem_work_experiences = true
  12052. }
  12053. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12054. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12055. return m.clearedem_work_experiences
  12056. }
  12057. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12058. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12059. if m.removedem_work_experiences == nil {
  12060. m.removedem_work_experiences = make(map[uint64]struct{})
  12061. }
  12062. for i := range ids {
  12063. delete(m.em_work_experiences, ids[i])
  12064. m.removedem_work_experiences[ids[i]] = struct{}{}
  12065. }
  12066. }
  12067. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12068. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12069. for id := range m.removedem_work_experiences {
  12070. ids = append(ids, id)
  12071. }
  12072. return
  12073. }
  12074. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12075. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12076. for id := range m.em_work_experiences {
  12077. ids = append(ids, id)
  12078. }
  12079. return
  12080. }
  12081. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12082. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12083. m.em_work_experiences = nil
  12084. m.clearedem_work_experiences = false
  12085. m.removedem_work_experiences = nil
  12086. }
  12087. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12088. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12089. if m.em_tutorial == nil {
  12090. m.em_tutorial = make(map[uint64]struct{})
  12091. }
  12092. for i := range ids {
  12093. m.em_tutorial[ids[i]] = struct{}{}
  12094. }
  12095. }
  12096. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12097. func (m *EmployeeMutation) ClearEmTutorial() {
  12098. m.clearedem_tutorial = true
  12099. }
  12100. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12101. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12102. return m.clearedem_tutorial
  12103. }
  12104. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12105. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12106. if m.removedem_tutorial == nil {
  12107. m.removedem_tutorial = make(map[uint64]struct{})
  12108. }
  12109. for i := range ids {
  12110. delete(m.em_tutorial, ids[i])
  12111. m.removedem_tutorial[ids[i]] = struct{}{}
  12112. }
  12113. }
  12114. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12115. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12116. for id := range m.removedem_tutorial {
  12117. ids = append(ids, id)
  12118. }
  12119. return
  12120. }
  12121. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12122. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12123. for id := range m.em_tutorial {
  12124. ids = append(ids, id)
  12125. }
  12126. return
  12127. }
  12128. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12129. func (m *EmployeeMutation) ResetEmTutorial() {
  12130. m.em_tutorial = nil
  12131. m.clearedem_tutorial = false
  12132. m.removedem_tutorial = nil
  12133. }
  12134. // Where appends a list predicates to the EmployeeMutation builder.
  12135. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12136. m.predicates = append(m.predicates, ps...)
  12137. }
  12138. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12139. // users can use type-assertion to append predicates that do not depend on any generated package.
  12140. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12141. p := make([]predicate.Employee, len(ps))
  12142. for i := range ps {
  12143. p[i] = ps[i]
  12144. }
  12145. m.Where(p...)
  12146. }
  12147. // Op returns the operation name.
  12148. func (m *EmployeeMutation) Op() Op {
  12149. return m.op
  12150. }
  12151. // SetOp allows setting the mutation operation.
  12152. func (m *EmployeeMutation) SetOp(op Op) {
  12153. m.op = op
  12154. }
  12155. // Type returns the node type of this mutation (Employee).
  12156. func (m *EmployeeMutation) Type() string {
  12157. return m.typ
  12158. }
  12159. // Fields returns all fields that were changed during this mutation. Note that in
  12160. // order to get all numeric fields that were incremented/decremented, call
  12161. // AddedFields().
  12162. func (m *EmployeeMutation) Fields() []string {
  12163. fields := make([]string, 0, 23)
  12164. if m.created_at != nil {
  12165. fields = append(fields, employee.FieldCreatedAt)
  12166. }
  12167. if m.updated_at != nil {
  12168. fields = append(fields, employee.FieldUpdatedAt)
  12169. }
  12170. if m.deleted_at != nil {
  12171. fields = append(fields, employee.FieldDeletedAt)
  12172. }
  12173. if m.title != nil {
  12174. fields = append(fields, employee.FieldTitle)
  12175. }
  12176. if m.avatar != nil {
  12177. fields = append(fields, employee.FieldAvatar)
  12178. }
  12179. if m.tags != nil {
  12180. fields = append(fields, employee.FieldTags)
  12181. }
  12182. if m.hire_count != nil {
  12183. fields = append(fields, employee.FieldHireCount)
  12184. }
  12185. if m.service_count != nil {
  12186. fields = append(fields, employee.FieldServiceCount)
  12187. }
  12188. if m.achievement_count != nil {
  12189. fields = append(fields, employee.FieldAchievementCount)
  12190. }
  12191. if m.intro != nil {
  12192. fields = append(fields, employee.FieldIntro)
  12193. }
  12194. if m.estimate != nil {
  12195. fields = append(fields, employee.FieldEstimate)
  12196. }
  12197. if m.skill != nil {
  12198. fields = append(fields, employee.FieldSkill)
  12199. }
  12200. if m.ability_type != nil {
  12201. fields = append(fields, employee.FieldAbilityType)
  12202. }
  12203. if m.scene != nil {
  12204. fields = append(fields, employee.FieldScene)
  12205. }
  12206. if m.switch_in != nil {
  12207. fields = append(fields, employee.FieldSwitchIn)
  12208. }
  12209. if m.video_url != nil {
  12210. fields = append(fields, employee.FieldVideoURL)
  12211. }
  12212. if m.organization_id != nil {
  12213. fields = append(fields, employee.FieldOrganizationID)
  12214. }
  12215. if m.category_id != nil {
  12216. fields = append(fields, employee.FieldCategoryID)
  12217. }
  12218. if m.api_base != nil {
  12219. fields = append(fields, employee.FieldAPIBase)
  12220. }
  12221. if m.api_key != nil {
  12222. fields = append(fields, employee.FieldAPIKey)
  12223. }
  12224. if m.ai_info != nil {
  12225. fields = append(fields, employee.FieldAiInfo)
  12226. }
  12227. if m.is_vip != nil {
  12228. fields = append(fields, employee.FieldIsVip)
  12229. }
  12230. if m.chat_url != nil {
  12231. fields = append(fields, employee.FieldChatURL)
  12232. }
  12233. return fields
  12234. }
  12235. // Field returns the value of a field with the given name. The second boolean
  12236. // return value indicates that this field was not set, or was not defined in the
  12237. // schema.
  12238. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12239. switch name {
  12240. case employee.FieldCreatedAt:
  12241. return m.CreatedAt()
  12242. case employee.FieldUpdatedAt:
  12243. return m.UpdatedAt()
  12244. case employee.FieldDeletedAt:
  12245. return m.DeletedAt()
  12246. case employee.FieldTitle:
  12247. return m.Title()
  12248. case employee.FieldAvatar:
  12249. return m.Avatar()
  12250. case employee.FieldTags:
  12251. return m.Tags()
  12252. case employee.FieldHireCount:
  12253. return m.HireCount()
  12254. case employee.FieldServiceCount:
  12255. return m.ServiceCount()
  12256. case employee.FieldAchievementCount:
  12257. return m.AchievementCount()
  12258. case employee.FieldIntro:
  12259. return m.Intro()
  12260. case employee.FieldEstimate:
  12261. return m.Estimate()
  12262. case employee.FieldSkill:
  12263. return m.Skill()
  12264. case employee.FieldAbilityType:
  12265. return m.AbilityType()
  12266. case employee.FieldScene:
  12267. return m.Scene()
  12268. case employee.FieldSwitchIn:
  12269. return m.SwitchIn()
  12270. case employee.FieldVideoURL:
  12271. return m.VideoURL()
  12272. case employee.FieldOrganizationID:
  12273. return m.OrganizationID()
  12274. case employee.FieldCategoryID:
  12275. return m.CategoryID()
  12276. case employee.FieldAPIBase:
  12277. return m.APIBase()
  12278. case employee.FieldAPIKey:
  12279. return m.APIKey()
  12280. case employee.FieldAiInfo:
  12281. return m.AiInfo()
  12282. case employee.FieldIsVip:
  12283. return m.IsVip()
  12284. case employee.FieldChatURL:
  12285. return m.ChatURL()
  12286. }
  12287. return nil, false
  12288. }
  12289. // OldField returns the old value of the field from the database. An error is
  12290. // returned if the mutation operation is not UpdateOne, or the query to the
  12291. // database failed.
  12292. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12293. switch name {
  12294. case employee.FieldCreatedAt:
  12295. return m.OldCreatedAt(ctx)
  12296. case employee.FieldUpdatedAt:
  12297. return m.OldUpdatedAt(ctx)
  12298. case employee.FieldDeletedAt:
  12299. return m.OldDeletedAt(ctx)
  12300. case employee.FieldTitle:
  12301. return m.OldTitle(ctx)
  12302. case employee.FieldAvatar:
  12303. return m.OldAvatar(ctx)
  12304. case employee.FieldTags:
  12305. return m.OldTags(ctx)
  12306. case employee.FieldHireCount:
  12307. return m.OldHireCount(ctx)
  12308. case employee.FieldServiceCount:
  12309. return m.OldServiceCount(ctx)
  12310. case employee.FieldAchievementCount:
  12311. return m.OldAchievementCount(ctx)
  12312. case employee.FieldIntro:
  12313. return m.OldIntro(ctx)
  12314. case employee.FieldEstimate:
  12315. return m.OldEstimate(ctx)
  12316. case employee.FieldSkill:
  12317. return m.OldSkill(ctx)
  12318. case employee.FieldAbilityType:
  12319. return m.OldAbilityType(ctx)
  12320. case employee.FieldScene:
  12321. return m.OldScene(ctx)
  12322. case employee.FieldSwitchIn:
  12323. return m.OldSwitchIn(ctx)
  12324. case employee.FieldVideoURL:
  12325. return m.OldVideoURL(ctx)
  12326. case employee.FieldOrganizationID:
  12327. return m.OldOrganizationID(ctx)
  12328. case employee.FieldCategoryID:
  12329. return m.OldCategoryID(ctx)
  12330. case employee.FieldAPIBase:
  12331. return m.OldAPIBase(ctx)
  12332. case employee.FieldAPIKey:
  12333. return m.OldAPIKey(ctx)
  12334. case employee.FieldAiInfo:
  12335. return m.OldAiInfo(ctx)
  12336. case employee.FieldIsVip:
  12337. return m.OldIsVip(ctx)
  12338. case employee.FieldChatURL:
  12339. return m.OldChatURL(ctx)
  12340. }
  12341. return nil, fmt.Errorf("unknown Employee field %s", name)
  12342. }
  12343. // SetField sets the value of a field with the given name. It returns an error if
  12344. // the field is not defined in the schema, or if the type mismatched the field
  12345. // type.
  12346. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12347. switch name {
  12348. case employee.FieldCreatedAt:
  12349. v, ok := value.(time.Time)
  12350. if !ok {
  12351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12352. }
  12353. m.SetCreatedAt(v)
  12354. return nil
  12355. case employee.FieldUpdatedAt:
  12356. v, ok := value.(time.Time)
  12357. if !ok {
  12358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12359. }
  12360. m.SetUpdatedAt(v)
  12361. return nil
  12362. case employee.FieldDeletedAt:
  12363. v, ok := value.(time.Time)
  12364. if !ok {
  12365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12366. }
  12367. m.SetDeletedAt(v)
  12368. return nil
  12369. case employee.FieldTitle:
  12370. v, ok := value.(string)
  12371. if !ok {
  12372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12373. }
  12374. m.SetTitle(v)
  12375. return nil
  12376. case employee.FieldAvatar:
  12377. v, ok := value.(string)
  12378. if !ok {
  12379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12380. }
  12381. m.SetAvatar(v)
  12382. return nil
  12383. case employee.FieldTags:
  12384. v, ok := value.(string)
  12385. if !ok {
  12386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12387. }
  12388. m.SetTags(v)
  12389. return nil
  12390. case employee.FieldHireCount:
  12391. v, ok := value.(int)
  12392. if !ok {
  12393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12394. }
  12395. m.SetHireCount(v)
  12396. return nil
  12397. case employee.FieldServiceCount:
  12398. v, ok := value.(int)
  12399. if !ok {
  12400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12401. }
  12402. m.SetServiceCount(v)
  12403. return nil
  12404. case employee.FieldAchievementCount:
  12405. v, ok := value.(int)
  12406. if !ok {
  12407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12408. }
  12409. m.SetAchievementCount(v)
  12410. return nil
  12411. case employee.FieldIntro:
  12412. v, ok := value.(string)
  12413. if !ok {
  12414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12415. }
  12416. m.SetIntro(v)
  12417. return nil
  12418. case employee.FieldEstimate:
  12419. v, ok := value.(string)
  12420. if !ok {
  12421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12422. }
  12423. m.SetEstimate(v)
  12424. return nil
  12425. case employee.FieldSkill:
  12426. v, ok := value.(string)
  12427. if !ok {
  12428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12429. }
  12430. m.SetSkill(v)
  12431. return nil
  12432. case employee.FieldAbilityType:
  12433. v, ok := value.(string)
  12434. if !ok {
  12435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12436. }
  12437. m.SetAbilityType(v)
  12438. return nil
  12439. case employee.FieldScene:
  12440. v, ok := value.(string)
  12441. if !ok {
  12442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12443. }
  12444. m.SetScene(v)
  12445. return nil
  12446. case employee.FieldSwitchIn:
  12447. v, ok := value.(string)
  12448. if !ok {
  12449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12450. }
  12451. m.SetSwitchIn(v)
  12452. return nil
  12453. case employee.FieldVideoURL:
  12454. v, ok := value.(string)
  12455. if !ok {
  12456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12457. }
  12458. m.SetVideoURL(v)
  12459. return nil
  12460. case employee.FieldOrganizationID:
  12461. v, ok := value.(uint64)
  12462. if !ok {
  12463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12464. }
  12465. m.SetOrganizationID(v)
  12466. return nil
  12467. case employee.FieldCategoryID:
  12468. v, ok := value.(uint64)
  12469. if !ok {
  12470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12471. }
  12472. m.SetCategoryID(v)
  12473. return nil
  12474. case employee.FieldAPIBase:
  12475. v, ok := value.(string)
  12476. if !ok {
  12477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12478. }
  12479. m.SetAPIBase(v)
  12480. return nil
  12481. case employee.FieldAPIKey:
  12482. v, ok := value.(string)
  12483. if !ok {
  12484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12485. }
  12486. m.SetAPIKey(v)
  12487. return nil
  12488. case employee.FieldAiInfo:
  12489. v, ok := value.(string)
  12490. if !ok {
  12491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12492. }
  12493. m.SetAiInfo(v)
  12494. return nil
  12495. case employee.FieldIsVip:
  12496. v, ok := value.(int)
  12497. if !ok {
  12498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12499. }
  12500. m.SetIsVip(v)
  12501. return nil
  12502. case employee.FieldChatURL:
  12503. v, ok := value.(string)
  12504. if !ok {
  12505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12506. }
  12507. m.SetChatURL(v)
  12508. return nil
  12509. }
  12510. return fmt.Errorf("unknown Employee field %s", name)
  12511. }
  12512. // AddedFields returns all numeric fields that were incremented/decremented during
  12513. // this mutation.
  12514. func (m *EmployeeMutation) AddedFields() []string {
  12515. var fields []string
  12516. if m.addhire_count != nil {
  12517. fields = append(fields, employee.FieldHireCount)
  12518. }
  12519. if m.addservice_count != nil {
  12520. fields = append(fields, employee.FieldServiceCount)
  12521. }
  12522. if m.addachievement_count != nil {
  12523. fields = append(fields, employee.FieldAchievementCount)
  12524. }
  12525. if m.addorganization_id != nil {
  12526. fields = append(fields, employee.FieldOrganizationID)
  12527. }
  12528. if m.addcategory_id != nil {
  12529. fields = append(fields, employee.FieldCategoryID)
  12530. }
  12531. if m.addis_vip != nil {
  12532. fields = append(fields, employee.FieldIsVip)
  12533. }
  12534. return fields
  12535. }
  12536. // AddedField returns the numeric value that was incremented/decremented on a field
  12537. // with the given name. The second boolean return value indicates that this field
  12538. // was not set, or was not defined in the schema.
  12539. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12540. switch name {
  12541. case employee.FieldHireCount:
  12542. return m.AddedHireCount()
  12543. case employee.FieldServiceCount:
  12544. return m.AddedServiceCount()
  12545. case employee.FieldAchievementCount:
  12546. return m.AddedAchievementCount()
  12547. case employee.FieldOrganizationID:
  12548. return m.AddedOrganizationID()
  12549. case employee.FieldCategoryID:
  12550. return m.AddedCategoryID()
  12551. case employee.FieldIsVip:
  12552. return m.AddedIsVip()
  12553. }
  12554. return nil, false
  12555. }
  12556. // AddField adds the value to the field with the given name. It returns an error if
  12557. // the field is not defined in the schema, or if the type mismatched the field
  12558. // type.
  12559. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12560. switch name {
  12561. case employee.FieldHireCount:
  12562. v, ok := value.(int)
  12563. if !ok {
  12564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12565. }
  12566. m.AddHireCount(v)
  12567. return nil
  12568. case employee.FieldServiceCount:
  12569. v, ok := value.(int)
  12570. if !ok {
  12571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12572. }
  12573. m.AddServiceCount(v)
  12574. return nil
  12575. case employee.FieldAchievementCount:
  12576. v, ok := value.(int)
  12577. if !ok {
  12578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12579. }
  12580. m.AddAchievementCount(v)
  12581. return nil
  12582. case employee.FieldOrganizationID:
  12583. v, ok := value.(int64)
  12584. if !ok {
  12585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12586. }
  12587. m.AddOrganizationID(v)
  12588. return nil
  12589. case employee.FieldCategoryID:
  12590. v, ok := value.(int64)
  12591. if !ok {
  12592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12593. }
  12594. m.AddCategoryID(v)
  12595. return nil
  12596. case employee.FieldIsVip:
  12597. v, ok := value.(int)
  12598. if !ok {
  12599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12600. }
  12601. m.AddIsVip(v)
  12602. return nil
  12603. }
  12604. return fmt.Errorf("unknown Employee numeric field %s", name)
  12605. }
  12606. // ClearedFields returns all nullable fields that were cleared during this
  12607. // mutation.
  12608. func (m *EmployeeMutation) ClearedFields() []string {
  12609. var fields []string
  12610. if m.FieldCleared(employee.FieldDeletedAt) {
  12611. fields = append(fields, employee.FieldDeletedAt)
  12612. }
  12613. if m.FieldCleared(employee.FieldAiInfo) {
  12614. fields = append(fields, employee.FieldAiInfo)
  12615. }
  12616. return fields
  12617. }
  12618. // FieldCleared returns a boolean indicating if a field with the given name was
  12619. // cleared in this mutation.
  12620. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12621. _, ok := m.clearedFields[name]
  12622. return ok
  12623. }
  12624. // ClearField clears the value of the field with the given name. It returns an
  12625. // error if the field is not defined in the schema.
  12626. func (m *EmployeeMutation) ClearField(name string) error {
  12627. switch name {
  12628. case employee.FieldDeletedAt:
  12629. m.ClearDeletedAt()
  12630. return nil
  12631. case employee.FieldAiInfo:
  12632. m.ClearAiInfo()
  12633. return nil
  12634. }
  12635. return fmt.Errorf("unknown Employee nullable field %s", name)
  12636. }
  12637. // ResetField resets all changes in the mutation for the field with the given name.
  12638. // It returns an error if the field is not defined in the schema.
  12639. func (m *EmployeeMutation) ResetField(name string) error {
  12640. switch name {
  12641. case employee.FieldCreatedAt:
  12642. m.ResetCreatedAt()
  12643. return nil
  12644. case employee.FieldUpdatedAt:
  12645. m.ResetUpdatedAt()
  12646. return nil
  12647. case employee.FieldDeletedAt:
  12648. m.ResetDeletedAt()
  12649. return nil
  12650. case employee.FieldTitle:
  12651. m.ResetTitle()
  12652. return nil
  12653. case employee.FieldAvatar:
  12654. m.ResetAvatar()
  12655. return nil
  12656. case employee.FieldTags:
  12657. m.ResetTags()
  12658. return nil
  12659. case employee.FieldHireCount:
  12660. m.ResetHireCount()
  12661. return nil
  12662. case employee.FieldServiceCount:
  12663. m.ResetServiceCount()
  12664. return nil
  12665. case employee.FieldAchievementCount:
  12666. m.ResetAchievementCount()
  12667. return nil
  12668. case employee.FieldIntro:
  12669. m.ResetIntro()
  12670. return nil
  12671. case employee.FieldEstimate:
  12672. m.ResetEstimate()
  12673. return nil
  12674. case employee.FieldSkill:
  12675. m.ResetSkill()
  12676. return nil
  12677. case employee.FieldAbilityType:
  12678. m.ResetAbilityType()
  12679. return nil
  12680. case employee.FieldScene:
  12681. m.ResetScene()
  12682. return nil
  12683. case employee.FieldSwitchIn:
  12684. m.ResetSwitchIn()
  12685. return nil
  12686. case employee.FieldVideoURL:
  12687. m.ResetVideoURL()
  12688. return nil
  12689. case employee.FieldOrganizationID:
  12690. m.ResetOrganizationID()
  12691. return nil
  12692. case employee.FieldCategoryID:
  12693. m.ResetCategoryID()
  12694. return nil
  12695. case employee.FieldAPIBase:
  12696. m.ResetAPIBase()
  12697. return nil
  12698. case employee.FieldAPIKey:
  12699. m.ResetAPIKey()
  12700. return nil
  12701. case employee.FieldAiInfo:
  12702. m.ResetAiInfo()
  12703. return nil
  12704. case employee.FieldIsVip:
  12705. m.ResetIsVip()
  12706. return nil
  12707. case employee.FieldChatURL:
  12708. m.ResetChatURL()
  12709. return nil
  12710. }
  12711. return fmt.Errorf("unknown Employee field %s", name)
  12712. }
  12713. // AddedEdges returns all edge names that were set/added in this mutation.
  12714. func (m *EmployeeMutation) AddedEdges() []string {
  12715. edges := make([]string, 0, 2)
  12716. if m.em_work_experiences != nil {
  12717. edges = append(edges, employee.EdgeEmWorkExperiences)
  12718. }
  12719. if m.em_tutorial != nil {
  12720. edges = append(edges, employee.EdgeEmTutorial)
  12721. }
  12722. return edges
  12723. }
  12724. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12725. // name in this mutation.
  12726. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12727. switch name {
  12728. case employee.EdgeEmWorkExperiences:
  12729. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12730. for id := range m.em_work_experiences {
  12731. ids = append(ids, id)
  12732. }
  12733. return ids
  12734. case employee.EdgeEmTutorial:
  12735. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12736. for id := range m.em_tutorial {
  12737. ids = append(ids, id)
  12738. }
  12739. return ids
  12740. }
  12741. return nil
  12742. }
  12743. // RemovedEdges returns all edge names that were removed in this mutation.
  12744. func (m *EmployeeMutation) RemovedEdges() []string {
  12745. edges := make([]string, 0, 2)
  12746. if m.removedem_work_experiences != nil {
  12747. edges = append(edges, employee.EdgeEmWorkExperiences)
  12748. }
  12749. if m.removedem_tutorial != nil {
  12750. edges = append(edges, employee.EdgeEmTutorial)
  12751. }
  12752. return edges
  12753. }
  12754. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12755. // the given name in this mutation.
  12756. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12757. switch name {
  12758. case employee.EdgeEmWorkExperiences:
  12759. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12760. for id := range m.removedem_work_experiences {
  12761. ids = append(ids, id)
  12762. }
  12763. return ids
  12764. case employee.EdgeEmTutorial:
  12765. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12766. for id := range m.removedem_tutorial {
  12767. ids = append(ids, id)
  12768. }
  12769. return ids
  12770. }
  12771. return nil
  12772. }
  12773. // ClearedEdges returns all edge names that were cleared in this mutation.
  12774. func (m *EmployeeMutation) ClearedEdges() []string {
  12775. edges := make([]string, 0, 2)
  12776. if m.clearedem_work_experiences {
  12777. edges = append(edges, employee.EdgeEmWorkExperiences)
  12778. }
  12779. if m.clearedem_tutorial {
  12780. edges = append(edges, employee.EdgeEmTutorial)
  12781. }
  12782. return edges
  12783. }
  12784. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12785. // was cleared in this mutation.
  12786. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12787. switch name {
  12788. case employee.EdgeEmWorkExperiences:
  12789. return m.clearedem_work_experiences
  12790. case employee.EdgeEmTutorial:
  12791. return m.clearedem_tutorial
  12792. }
  12793. return false
  12794. }
  12795. // ClearEdge clears the value of the edge with the given name. It returns an error
  12796. // if that edge is not defined in the schema.
  12797. func (m *EmployeeMutation) ClearEdge(name string) error {
  12798. switch name {
  12799. }
  12800. return fmt.Errorf("unknown Employee unique edge %s", name)
  12801. }
  12802. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12803. // It returns an error if the edge is not defined in the schema.
  12804. func (m *EmployeeMutation) ResetEdge(name string) error {
  12805. switch name {
  12806. case employee.EdgeEmWorkExperiences:
  12807. m.ResetEmWorkExperiences()
  12808. return nil
  12809. case employee.EdgeEmTutorial:
  12810. m.ResetEmTutorial()
  12811. return nil
  12812. }
  12813. return fmt.Errorf("unknown Employee edge %s", name)
  12814. }
  12815. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12816. type EmployeeConfigMutation struct {
  12817. config
  12818. op Op
  12819. typ string
  12820. id *uint64
  12821. created_at *time.Time
  12822. updated_at *time.Time
  12823. deleted_at *time.Time
  12824. stype *string
  12825. title *string
  12826. photo *string
  12827. organization_id *uint64
  12828. addorganization_id *int64
  12829. clearedFields map[string]struct{}
  12830. done bool
  12831. oldValue func(context.Context) (*EmployeeConfig, error)
  12832. predicates []predicate.EmployeeConfig
  12833. }
  12834. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12835. // employeeconfigOption allows management of the mutation configuration using functional options.
  12836. type employeeconfigOption func(*EmployeeConfigMutation)
  12837. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12838. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12839. m := &EmployeeConfigMutation{
  12840. config: c,
  12841. op: op,
  12842. typ: TypeEmployeeConfig,
  12843. clearedFields: make(map[string]struct{}),
  12844. }
  12845. for _, opt := range opts {
  12846. opt(m)
  12847. }
  12848. return m
  12849. }
  12850. // withEmployeeConfigID sets the ID field of the mutation.
  12851. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12852. return func(m *EmployeeConfigMutation) {
  12853. var (
  12854. err error
  12855. once sync.Once
  12856. value *EmployeeConfig
  12857. )
  12858. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12859. once.Do(func() {
  12860. if m.done {
  12861. err = errors.New("querying old values post mutation is not allowed")
  12862. } else {
  12863. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12864. }
  12865. })
  12866. return value, err
  12867. }
  12868. m.id = &id
  12869. }
  12870. }
  12871. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  12872. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  12873. return func(m *EmployeeConfigMutation) {
  12874. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  12875. return node, nil
  12876. }
  12877. m.id = &node.ID
  12878. }
  12879. }
  12880. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12881. // executed in a transaction (ent.Tx), a transactional client is returned.
  12882. func (m EmployeeConfigMutation) Client() *Client {
  12883. client := &Client{config: m.config}
  12884. client.init()
  12885. return client
  12886. }
  12887. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12888. // it returns an error otherwise.
  12889. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  12890. if _, ok := m.driver.(*txDriver); !ok {
  12891. return nil, errors.New("ent: mutation is not running in a transaction")
  12892. }
  12893. tx := &Tx{config: m.config}
  12894. tx.init()
  12895. return tx, nil
  12896. }
  12897. // SetID sets the value of the id field. Note that this
  12898. // operation is only accepted on creation of EmployeeConfig entities.
  12899. func (m *EmployeeConfigMutation) SetID(id uint64) {
  12900. m.id = &id
  12901. }
  12902. // ID returns the ID value in the mutation. Note that the ID is only available
  12903. // if it was provided to the builder or after it was returned from the database.
  12904. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  12905. if m.id == nil {
  12906. return
  12907. }
  12908. return *m.id, true
  12909. }
  12910. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12911. // That means, if the mutation is applied within a transaction with an isolation level such
  12912. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12913. // or updated by the mutation.
  12914. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  12915. switch {
  12916. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12917. id, exists := m.ID()
  12918. if exists {
  12919. return []uint64{id}, nil
  12920. }
  12921. fallthrough
  12922. case m.op.Is(OpUpdate | OpDelete):
  12923. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  12924. default:
  12925. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12926. }
  12927. }
  12928. // SetCreatedAt sets the "created_at" field.
  12929. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  12930. m.created_at = &t
  12931. }
  12932. // CreatedAt returns the value of the "created_at" field in the mutation.
  12933. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  12934. v := m.created_at
  12935. if v == nil {
  12936. return
  12937. }
  12938. return *v, true
  12939. }
  12940. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  12941. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12943. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12944. if !m.op.Is(OpUpdateOne) {
  12945. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12946. }
  12947. if m.id == nil || m.oldValue == nil {
  12948. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12949. }
  12950. oldValue, err := m.oldValue(ctx)
  12951. if err != nil {
  12952. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12953. }
  12954. return oldValue.CreatedAt, nil
  12955. }
  12956. // ResetCreatedAt resets all changes to the "created_at" field.
  12957. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  12958. m.created_at = nil
  12959. }
  12960. // SetUpdatedAt sets the "updated_at" field.
  12961. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  12962. m.updated_at = &t
  12963. }
  12964. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12965. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  12966. v := m.updated_at
  12967. if v == nil {
  12968. return
  12969. }
  12970. return *v, true
  12971. }
  12972. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  12973. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12975. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12976. if !m.op.Is(OpUpdateOne) {
  12977. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12978. }
  12979. if m.id == nil || m.oldValue == nil {
  12980. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12981. }
  12982. oldValue, err := m.oldValue(ctx)
  12983. if err != nil {
  12984. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12985. }
  12986. return oldValue.UpdatedAt, nil
  12987. }
  12988. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12989. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  12990. m.updated_at = nil
  12991. }
  12992. // SetDeletedAt sets the "deleted_at" field.
  12993. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  12994. m.deleted_at = &t
  12995. }
  12996. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12997. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  12998. v := m.deleted_at
  12999. if v == nil {
  13000. return
  13001. }
  13002. return *v, true
  13003. }
  13004. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13005. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13007. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13008. if !m.op.Is(OpUpdateOne) {
  13009. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13010. }
  13011. if m.id == nil || m.oldValue == nil {
  13012. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13013. }
  13014. oldValue, err := m.oldValue(ctx)
  13015. if err != nil {
  13016. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13017. }
  13018. return oldValue.DeletedAt, nil
  13019. }
  13020. // ClearDeletedAt clears the value of the "deleted_at" field.
  13021. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13022. m.deleted_at = nil
  13023. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13024. }
  13025. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13026. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13027. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13028. return ok
  13029. }
  13030. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13031. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13032. m.deleted_at = nil
  13033. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13034. }
  13035. // SetStype sets the "stype" field.
  13036. func (m *EmployeeConfigMutation) SetStype(s string) {
  13037. m.stype = &s
  13038. }
  13039. // Stype returns the value of the "stype" field in the mutation.
  13040. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13041. v := m.stype
  13042. if v == nil {
  13043. return
  13044. }
  13045. return *v, true
  13046. }
  13047. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13048. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13050. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13051. if !m.op.Is(OpUpdateOne) {
  13052. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13053. }
  13054. if m.id == nil || m.oldValue == nil {
  13055. return v, errors.New("OldStype requires an ID field in the mutation")
  13056. }
  13057. oldValue, err := m.oldValue(ctx)
  13058. if err != nil {
  13059. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13060. }
  13061. return oldValue.Stype, nil
  13062. }
  13063. // ResetStype resets all changes to the "stype" field.
  13064. func (m *EmployeeConfigMutation) ResetStype() {
  13065. m.stype = nil
  13066. }
  13067. // SetTitle sets the "title" field.
  13068. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13069. m.title = &s
  13070. }
  13071. // Title returns the value of the "title" field in the mutation.
  13072. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13073. v := m.title
  13074. if v == nil {
  13075. return
  13076. }
  13077. return *v, true
  13078. }
  13079. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13080. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13082. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13083. if !m.op.Is(OpUpdateOne) {
  13084. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13085. }
  13086. if m.id == nil || m.oldValue == nil {
  13087. return v, errors.New("OldTitle requires an ID field in the mutation")
  13088. }
  13089. oldValue, err := m.oldValue(ctx)
  13090. if err != nil {
  13091. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13092. }
  13093. return oldValue.Title, nil
  13094. }
  13095. // ResetTitle resets all changes to the "title" field.
  13096. func (m *EmployeeConfigMutation) ResetTitle() {
  13097. m.title = nil
  13098. }
  13099. // SetPhoto sets the "photo" field.
  13100. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13101. m.photo = &s
  13102. }
  13103. // Photo returns the value of the "photo" field in the mutation.
  13104. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13105. v := m.photo
  13106. if v == nil {
  13107. return
  13108. }
  13109. return *v, true
  13110. }
  13111. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13112. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13114. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13115. if !m.op.Is(OpUpdateOne) {
  13116. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13117. }
  13118. if m.id == nil || m.oldValue == nil {
  13119. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13120. }
  13121. oldValue, err := m.oldValue(ctx)
  13122. if err != nil {
  13123. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13124. }
  13125. return oldValue.Photo, nil
  13126. }
  13127. // ResetPhoto resets all changes to the "photo" field.
  13128. func (m *EmployeeConfigMutation) ResetPhoto() {
  13129. m.photo = nil
  13130. }
  13131. // SetOrganizationID sets the "organization_id" field.
  13132. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13133. m.organization_id = &u
  13134. m.addorganization_id = nil
  13135. }
  13136. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13137. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13138. v := m.organization_id
  13139. if v == nil {
  13140. return
  13141. }
  13142. return *v, true
  13143. }
  13144. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13145. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13147. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13148. if !m.op.Is(OpUpdateOne) {
  13149. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13150. }
  13151. if m.id == nil || m.oldValue == nil {
  13152. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13153. }
  13154. oldValue, err := m.oldValue(ctx)
  13155. if err != nil {
  13156. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13157. }
  13158. return oldValue.OrganizationID, nil
  13159. }
  13160. // AddOrganizationID adds u to the "organization_id" field.
  13161. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13162. if m.addorganization_id != nil {
  13163. *m.addorganization_id += u
  13164. } else {
  13165. m.addorganization_id = &u
  13166. }
  13167. }
  13168. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13169. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13170. v := m.addorganization_id
  13171. if v == nil {
  13172. return
  13173. }
  13174. return *v, true
  13175. }
  13176. // ClearOrganizationID clears the value of the "organization_id" field.
  13177. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13178. m.organization_id = nil
  13179. m.addorganization_id = nil
  13180. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13181. }
  13182. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13183. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13184. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13185. return ok
  13186. }
  13187. // ResetOrganizationID resets all changes to the "organization_id" field.
  13188. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13189. m.organization_id = nil
  13190. m.addorganization_id = nil
  13191. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13192. }
  13193. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13194. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13195. m.predicates = append(m.predicates, ps...)
  13196. }
  13197. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13198. // users can use type-assertion to append predicates that do not depend on any generated package.
  13199. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13200. p := make([]predicate.EmployeeConfig, len(ps))
  13201. for i := range ps {
  13202. p[i] = ps[i]
  13203. }
  13204. m.Where(p...)
  13205. }
  13206. // Op returns the operation name.
  13207. func (m *EmployeeConfigMutation) Op() Op {
  13208. return m.op
  13209. }
  13210. // SetOp allows setting the mutation operation.
  13211. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13212. m.op = op
  13213. }
  13214. // Type returns the node type of this mutation (EmployeeConfig).
  13215. func (m *EmployeeConfigMutation) Type() string {
  13216. return m.typ
  13217. }
  13218. // Fields returns all fields that were changed during this mutation. Note that in
  13219. // order to get all numeric fields that were incremented/decremented, call
  13220. // AddedFields().
  13221. func (m *EmployeeConfigMutation) Fields() []string {
  13222. fields := make([]string, 0, 7)
  13223. if m.created_at != nil {
  13224. fields = append(fields, employeeconfig.FieldCreatedAt)
  13225. }
  13226. if m.updated_at != nil {
  13227. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13228. }
  13229. if m.deleted_at != nil {
  13230. fields = append(fields, employeeconfig.FieldDeletedAt)
  13231. }
  13232. if m.stype != nil {
  13233. fields = append(fields, employeeconfig.FieldStype)
  13234. }
  13235. if m.title != nil {
  13236. fields = append(fields, employeeconfig.FieldTitle)
  13237. }
  13238. if m.photo != nil {
  13239. fields = append(fields, employeeconfig.FieldPhoto)
  13240. }
  13241. if m.organization_id != nil {
  13242. fields = append(fields, employeeconfig.FieldOrganizationID)
  13243. }
  13244. return fields
  13245. }
  13246. // Field returns the value of a field with the given name. The second boolean
  13247. // return value indicates that this field was not set, or was not defined in the
  13248. // schema.
  13249. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13250. switch name {
  13251. case employeeconfig.FieldCreatedAt:
  13252. return m.CreatedAt()
  13253. case employeeconfig.FieldUpdatedAt:
  13254. return m.UpdatedAt()
  13255. case employeeconfig.FieldDeletedAt:
  13256. return m.DeletedAt()
  13257. case employeeconfig.FieldStype:
  13258. return m.Stype()
  13259. case employeeconfig.FieldTitle:
  13260. return m.Title()
  13261. case employeeconfig.FieldPhoto:
  13262. return m.Photo()
  13263. case employeeconfig.FieldOrganizationID:
  13264. return m.OrganizationID()
  13265. }
  13266. return nil, false
  13267. }
  13268. // OldField returns the old value of the field from the database. An error is
  13269. // returned if the mutation operation is not UpdateOne, or the query to the
  13270. // database failed.
  13271. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13272. switch name {
  13273. case employeeconfig.FieldCreatedAt:
  13274. return m.OldCreatedAt(ctx)
  13275. case employeeconfig.FieldUpdatedAt:
  13276. return m.OldUpdatedAt(ctx)
  13277. case employeeconfig.FieldDeletedAt:
  13278. return m.OldDeletedAt(ctx)
  13279. case employeeconfig.FieldStype:
  13280. return m.OldStype(ctx)
  13281. case employeeconfig.FieldTitle:
  13282. return m.OldTitle(ctx)
  13283. case employeeconfig.FieldPhoto:
  13284. return m.OldPhoto(ctx)
  13285. case employeeconfig.FieldOrganizationID:
  13286. return m.OldOrganizationID(ctx)
  13287. }
  13288. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13289. }
  13290. // SetField sets the value of a field with the given name. It returns an error if
  13291. // the field is not defined in the schema, or if the type mismatched the field
  13292. // type.
  13293. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13294. switch name {
  13295. case employeeconfig.FieldCreatedAt:
  13296. v, ok := value.(time.Time)
  13297. if !ok {
  13298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13299. }
  13300. m.SetCreatedAt(v)
  13301. return nil
  13302. case employeeconfig.FieldUpdatedAt:
  13303. v, ok := value.(time.Time)
  13304. if !ok {
  13305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13306. }
  13307. m.SetUpdatedAt(v)
  13308. return nil
  13309. case employeeconfig.FieldDeletedAt:
  13310. v, ok := value.(time.Time)
  13311. if !ok {
  13312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13313. }
  13314. m.SetDeletedAt(v)
  13315. return nil
  13316. case employeeconfig.FieldStype:
  13317. v, ok := value.(string)
  13318. if !ok {
  13319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13320. }
  13321. m.SetStype(v)
  13322. return nil
  13323. case employeeconfig.FieldTitle:
  13324. v, ok := value.(string)
  13325. if !ok {
  13326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13327. }
  13328. m.SetTitle(v)
  13329. return nil
  13330. case employeeconfig.FieldPhoto:
  13331. v, ok := value.(string)
  13332. if !ok {
  13333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13334. }
  13335. m.SetPhoto(v)
  13336. return nil
  13337. case employeeconfig.FieldOrganizationID:
  13338. v, ok := value.(uint64)
  13339. if !ok {
  13340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13341. }
  13342. m.SetOrganizationID(v)
  13343. return nil
  13344. }
  13345. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13346. }
  13347. // AddedFields returns all numeric fields that were incremented/decremented during
  13348. // this mutation.
  13349. func (m *EmployeeConfigMutation) AddedFields() []string {
  13350. var fields []string
  13351. if m.addorganization_id != nil {
  13352. fields = append(fields, employeeconfig.FieldOrganizationID)
  13353. }
  13354. return fields
  13355. }
  13356. // AddedField returns the numeric value that was incremented/decremented on a field
  13357. // with the given name. The second boolean return value indicates that this field
  13358. // was not set, or was not defined in the schema.
  13359. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13360. switch name {
  13361. case employeeconfig.FieldOrganizationID:
  13362. return m.AddedOrganizationID()
  13363. }
  13364. return nil, false
  13365. }
  13366. // AddField adds the value to the field with the given name. It returns an error if
  13367. // the field is not defined in the schema, or if the type mismatched the field
  13368. // type.
  13369. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13370. switch name {
  13371. case employeeconfig.FieldOrganizationID:
  13372. v, ok := value.(int64)
  13373. if !ok {
  13374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13375. }
  13376. m.AddOrganizationID(v)
  13377. return nil
  13378. }
  13379. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13380. }
  13381. // ClearedFields returns all nullable fields that were cleared during this
  13382. // mutation.
  13383. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13384. var fields []string
  13385. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13386. fields = append(fields, employeeconfig.FieldDeletedAt)
  13387. }
  13388. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13389. fields = append(fields, employeeconfig.FieldOrganizationID)
  13390. }
  13391. return fields
  13392. }
  13393. // FieldCleared returns a boolean indicating if a field with the given name was
  13394. // cleared in this mutation.
  13395. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13396. _, ok := m.clearedFields[name]
  13397. return ok
  13398. }
  13399. // ClearField clears the value of the field with the given name. It returns an
  13400. // error if the field is not defined in the schema.
  13401. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13402. switch name {
  13403. case employeeconfig.FieldDeletedAt:
  13404. m.ClearDeletedAt()
  13405. return nil
  13406. case employeeconfig.FieldOrganizationID:
  13407. m.ClearOrganizationID()
  13408. return nil
  13409. }
  13410. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13411. }
  13412. // ResetField resets all changes in the mutation for the field with the given name.
  13413. // It returns an error if the field is not defined in the schema.
  13414. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13415. switch name {
  13416. case employeeconfig.FieldCreatedAt:
  13417. m.ResetCreatedAt()
  13418. return nil
  13419. case employeeconfig.FieldUpdatedAt:
  13420. m.ResetUpdatedAt()
  13421. return nil
  13422. case employeeconfig.FieldDeletedAt:
  13423. m.ResetDeletedAt()
  13424. return nil
  13425. case employeeconfig.FieldStype:
  13426. m.ResetStype()
  13427. return nil
  13428. case employeeconfig.FieldTitle:
  13429. m.ResetTitle()
  13430. return nil
  13431. case employeeconfig.FieldPhoto:
  13432. m.ResetPhoto()
  13433. return nil
  13434. case employeeconfig.FieldOrganizationID:
  13435. m.ResetOrganizationID()
  13436. return nil
  13437. }
  13438. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13439. }
  13440. // AddedEdges returns all edge names that were set/added in this mutation.
  13441. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13442. edges := make([]string, 0, 0)
  13443. return edges
  13444. }
  13445. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13446. // name in this mutation.
  13447. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13448. return nil
  13449. }
  13450. // RemovedEdges returns all edge names that were removed in this mutation.
  13451. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13452. edges := make([]string, 0, 0)
  13453. return edges
  13454. }
  13455. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13456. // the given name in this mutation.
  13457. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13458. return nil
  13459. }
  13460. // ClearedEdges returns all edge names that were cleared in this mutation.
  13461. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13462. edges := make([]string, 0, 0)
  13463. return edges
  13464. }
  13465. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13466. // was cleared in this mutation.
  13467. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13468. return false
  13469. }
  13470. // ClearEdge clears the value of the edge with the given name. It returns an error
  13471. // if that edge is not defined in the schema.
  13472. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13473. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13474. }
  13475. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13476. // It returns an error if the edge is not defined in the schema.
  13477. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13478. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13479. }
  13480. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13481. type LabelMutation struct {
  13482. config
  13483. op Op
  13484. typ string
  13485. id *uint64
  13486. created_at *time.Time
  13487. updated_at *time.Time
  13488. status *uint8
  13489. addstatus *int8
  13490. _type *int
  13491. add_type *int
  13492. name *string
  13493. from *int
  13494. addfrom *int
  13495. mode *int
  13496. addmode *int
  13497. conditions *string
  13498. organization_id *uint64
  13499. addorganization_id *int64
  13500. clearedFields map[string]struct{}
  13501. label_relationships map[uint64]struct{}
  13502. removedlabel_relationships map[uint64]struct{}
  13503. clearedlabel_relationships bool
  13504. done bool
  13505. oldValue func(context.Context) (*Label, error)
  13506. predicates []predicate.Label
  13507. }
  13508. var _ ent.Mutation = (*LabelMutation)(nil)
  13509. // labelOption allows management of the mutation configuration using functional options.
  13510. type labelOption func(*LabelMutation)
  13511. // newLabelMutation creates new mutation for the Label entity.
  13512. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13513. m := &LabelMutation{
  13514. config: c,
  13515. op: op,
  13516. typ: TypeLabel,
  13517. clearedFields: make(map[string]struct{}),
  13518. }
  13519. for _, opt := range opts {
  13520. opt(m)
  13521. }
  13522. return m
  13523. }
  13524. // withLabelID sets the ID field of the mutation.
  13525. func withLabelID(id uint64) labelOption {
  13526. return func(m *LabelMutation) {
  13527. var (
  13528. err error
  13529. once sync.Once
  13530. value *Label
  13531. )
  13532. m.oldValue = func(ctx context.Context) (*Label, error) {
  13533. once.Do(func() {
  13534. if m.done {
  13535. err = errors.New("querying old values post mutation is not allowed")
  13536. } else {
  13537. value, err = m.Client().Label.Get(ctx, id)
  13538. }
  13539. })
  13540. return value, err
  13541. }
  13542. m.id = &id
  13543. }
  13544. }
  13545. // withLabel sets the old Label of the mutation.
  13546. func withLabel(node *Label) labelOption {
  13547. return func(m *LabelMutation) {
  13548. m.oldValue = func(context.Context) (*Label, error) {
  13549. return node, nil
  13550. }
  13551. m.id = &node.ID
  13552. }
  13553. }
  13554. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13555. // executed in a transaction (ent.Tx), a transactional client is returned.
  13556. func (m LabelMutation) Client() *Client {
  13557. client := &Client{config: m.config}
  13558. client.init()
  13559. return client
  13560. }
  13561. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13562. // it returns an error otherwise.
  13563. func (m LabelMutation) Tx() (*Tx, error) {
  13564. if _, ok := m.driver.(*txDriver); !ok {
  13565. return nil, errors.New("ent: mutation is not running in a transaction")
  13566. }
  13567. tx := &Tx{config: m.config}
  13568. tx.init()
  13569. return tx, nil
  13570. }
  13571. // SetID sets the value of the id field. Note that this
  13572. // operation is only accepted on creation of Label entities.
  13573. func (m *LabelMutation) SetID(id uint64) {
  13574. m.id = &id
  13575. }
  13576. // ID returns the ID value in the mutation. Note that the ID is only available
  13577. // if it was provided to the builder or after it was returned from the database.
  13578. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13579. if m.id == nil {
  13580. return
  13581. }
  13582. return *m.id, true
  13583. }
  13584. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13585. // That means, if the mutation is applied within a transaction with an isolation level such
  13586. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13587. // or updated by the mutation.
  13588. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13589. switch {
  13590. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13591. id, exists := m.ID()
  13592. if exists {
  13593. return []uint64{id}, nil
  13594. }
  13595. fallthrough
  13596. case m.op.Is(OpUpdate | OpDelete):
  13597. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13598. default:
  13599. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13600. }
  13601. }
  13602. // SetCreatedAt sets the "created_at" field.
  13603. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13604. m.created_at = &t
  13605. }
  13606. // CreatedAt returns the value of the "created_at" field in the mutation.
  13607. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13608. v := m.created_at
  13609. if v == nil {
  13610. return
  13611. }
  13612. return *v, true
  13613. }
  13614. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13615. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13617. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13618. if !m.op.Is(OpUpdateOne) {
  13619. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13620. }
  13621. if m.id == nil || m.oldValue == nil {
  13622. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13623. }
  13624. oldValue, err := m.oldValue(ctx)
  13625. if err != nil {
  13626. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13627. }
  13628. return oldValue.CreatedAt, nil
  13629. }
  13630. // ResetCreatedAt resets all changes to the "created_at" field.
  13631. func (m *LabelMutation) ResetCreatedAt() {
  13632. m.created_at = nil
  13633. }
  13634. // SetUpdatedAt sets the "updated_at" field.
  13635. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13636. m.updated_at = &t
  13637. }
  13638. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13639. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13640. v := m.updated_at
  13641. if v == nil {
  13642. return
  13643. }
  13644. return *v, true
  13645. }
  13646. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13647. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13649. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13650. if !m.op.Is(OpUpdateOne) {
  13651. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13652. }
  13653. if m.id == nil || m.oldValue == nil {
  13654. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13655. }
  13656. oldValue, err := m.oldValue(ctx)
  13657. if err != nil {
  13658. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13659. }
  13660. return oldValue.UpdatedAt, nil
  13661. }
  13662. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13663. func (m *LabelMutation) ResetUpdatedAt() {
  13664. m.updated_at = nil
  13665. }
  13666. // SetStatus sets the "status" field.
  13667. func (m *LabelMutation) SetStatus(u uint8) {
  13668. m.status = &u
  13669. m.addstatus = nil
  13670. }
  13671. // Status returns the value of the "status" field in the mutation.
  13672. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13673. v := m.status
  13674. if v == nil {
  13675. return
  13676. }
  13677. return *v, true
  13678. }
  13679. // OldStatus returns the old "status" field's value of the Label entity.
  13680. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13682. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13683. if !m.op.Is(OpUpdateOne) {
  13684. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13685. }
  13686. if m.id == nil || m.oldValue == nil {
  13687. return v, errors.New("OldStatus requires an ID field in the mutation")
  13688. }
  13689. oldValue, err := m.oldValue(ctx)
  13690. if err != nil {
  13691. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13692. }
  13693. return oldValue.Status, nil
  13694. }
  13695. // AddStatus adds u to the "status" field.
  13696. func (m *LabelMutation) AddStatus(u int8) {
  13697. if m.addstatus != nil {
  13698. *m.addstatus += u
  13699. } else {
  13700. m.addstatus = &u
  13701. }
  13702. }
  13703. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13704. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13705. v := m.addstatus
  13706. if v == nil {
  13707. return
  13708. }
  13709. return *v, true
  13710. }
  13711. // ClearStatus clears the value of the "status" field.
  13712. func (m *LabelMutation) ClearStatus() {
  13713. m.status = nil
  13714. m.addstatus = nil
  13715. m.clearedFields[label.FieldStatus] = struct{}{}
  13716. }
  13717. // StatusCleared returns if the "status" field was cleared in this mutation.
  13718. func (m *LabelMutation) StatusCleared() bool {
  13719. _, ok := m.clearedFields[label.FieldStatus]
  13720. return ok
  13721. }
  13722. // ResetStatus resets all changes to the "status" field.
  13723. func (m *LabelMutation) ResetStatus() {
  13724. m.status = nil
  13725. m.addstatus = nil
  13726. delete(m.clearedFields, label.FieldStatus)
  13727. }
  13728. // SetType sets the "type" field.
  13729. func (m *LabelMutation) SetType(i int) {
  13730. m._type = &i
  13731. m.add_type = nil
  13732. }
  13733. // GetType returns the value of the "type" field in the mutation.
  13734. func (m *LabelMutation) GetType() (r int, exists bool) {
  13735. v := m._type
  13736. if v == nil {
  13737. return
  13738. }
  13739. return *v, true
  13740. }
  13741. // OldType returns the old "type" field's value of the Label entity.
  13742. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13744. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13745. if !m.op.Is(OpUpdateOne) {
  13746. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13747. }
  13748. if m.id == nil || m.oldValue == nil {
  13749. return v, errors.New("OldType requires an ID field in the mutation")
  13750. }
  13751. oldValue, err := m.oldValue(ctx)
  13752. if err != nil {
  13753. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13754. }
  13755. return oldValue.Type, nil
  13756. }
  13757. // AddType adds i to the "type" field.
  13758. func (m *LabelMutation) AddType(i int) {
  13759. if m.add_type != nil {
  13760. *m.add_type += i
  13761. } else {
  13762. m.add_type = &i
  13763. }
  13764. }
  13765. // AddedType returns the value that was added to the "type" field in this mutation.
  13766. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13767. v := m.add_type
  13768. if v == nil {
  13769. return
  13770. }
  13771. return *v, true
  13772. }
  13773. // ResetType resets all changes to the "type" field.
  13774. func (m *LabelMutation) ResetType() {
  13775. m._type = nil
  13776. m.add_type = nil
  13777. }
  13778. // SetName sets the "name" field.
  13779. func (m *LabelMutation) SetName(s string) {
  13780. m.name = &s
  13781. }
  13782. // Name returns the value of the "name" field in the mutation.
  13783. func (m *LabelMutation) Name() (r string, exists bool) {
  13784. v := m.name
  13785. if v == nil {
  13786. return
  13787. }
  13788. return *v, true
  13789. }
  13790. // OldName returns the old "name" field's value of the Label entity.
  13791. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13793. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13794. if !m.op.Is(OpUpdateOne) {
  13795. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13796. }
  13797. if m.id == nil || m.oldValue == nil {
  13798. return v, errors.New("OldName requires an ID field in the mutation")
  13799. }
  13800. oldValue, err := m.oldValue(ctx)
  13801. if err != nil {
  13802. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13803. }
  13804. return oldValue.Name, nil
  13805. }
  13806. // ResetName resets all changes to the "name" field.
  13807. func (m *LabelMutation) ResetName() {
  13808. m.name = nil
  13809. }
  13810. // SetFrom sets the "from" field.
  13811. func (m *LabelMutation) SetFrom(i int) {
  13812. m.from = &i
  13813. m.addfrom = nil
  13814. }
  13815. // From returns the value of the "from" field in the mutation.
  13816. func (m *LabelMutation) From() (r int, exists bool) {
  13817. v := m.from
  13818. if v == nil {
  13819. return
  13820. }
  13821. return *v, true
  13822. }
  13823. // OldFrom returns the old "from" field's value of the Label entity.
  13824. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13826. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13827. if !m.op.Is(OpUpdateOne) {
  13828. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13829. }
  13830. if m.id == nil || m.oldValue == nil {
  13831. return v, errors.New("OldFrom requires an ID field in the mutation")
  13832. }
  13833. oldValue, err := m.oldValue(ctx)
  13834. if err != nil {
  13835. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13836. }
  13837. return oldValue.From, nil
  13838. }
  13839. // AddFrom adds i to the "from" field.
  13840. func (m *LabelMutation) AddFrom(i int) {
  13841. if m.addfrom != nil {
  13842. *m.addfrom += i
  13843. } else {
  13844. m.addfrom = &i
  13845. }
  13846. }
  13847. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13848. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13849. v := m.addfrom
  13850. if v == nil {
  13851. return
  13852. }
  13853. return *v, true
  13854. }
  13855. // ResetFrom resets all changes to the "from" field.
  13856. func (m *LabelMutation) ResetFrom() {
  13857. m.from = nil
  13858. m.addfrom = nil
  13859. }
  13860. // SetMode sets the "mode" field.
  13861. func (m *LabelMutation) SetMode(i int) {
  13862. m.mode = &i
  13863. m.addmode = nil
  13864. }
  13865. // Mode returns the value of the "mode" field in the mutation.
  13866. func (m *LabelMutation) Mode() (r int, exists bool) {
  13867. v := m.mode
  13868. if v == nil {
  13869. return
  13870. }
  13871. return *v, true
  13872. }
  13873. // OldMode returns the old "mode" field's value of the Label entity.
  13874. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13876. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  13877. if !m.op.Is(OpUpdateOne) {
  13878. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  13879. }
  13880. if m.id == nil || m.oldValue == nil {
  13881. return v, errors.New("OldMode requires an ID field in the mutation")
  13882. }
  13883. oldValue, err := m.oldValue(ctx)
  13884. if err != nil {
  13885. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  13886. }
  13887. return oldValue.Mode, nil
  13888. }
  13889. // AddMode adds i to the "mode" field.
  13890. func (m *LabelMutation) AddMode(i int) {
  13891. if m.addmode != nil {
  13892. *m.addmode += i
  13893. } else {
  13894. m.addmode = &i
  13895. }
  13896. }
  13897. // AddedMode returns the value that was added to the "mode" field in this mutation.
  13898. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  13899. v := m.addmode
  13900. if v == nil {
  13901. return
  13902. }
  13903. return *v, true
  13904. }
  13905. // ResetMode resets all changes to the "mode" field.
  13906. func (m *LabelMutation) ResetMode() {
  13907. m.mode = nil
  13908. m.addmode = nil
  13909. }
  13910. // SetConditions sets the "conditions" field.
  13911. func (m *LabelMutation) SetConditions(s string) {
  13912. m.conditions = &s
  13913. }
  13914. // Conditions returns the value of the "conditions" field in the mutation.
  13915. func (m *LabelMutation) Conditions() (r string, exists bool) {
  13916. v := m.conditions
  13917. if v == nil {
  13918. return
  13919. }
  13920. return *v, true
  13921. }
  13922. // OldConditions returns the old "conditions" field's value of the Label entity.
  13923. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13925. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  13926. if !m.op.Is(OpUpdateOne) {
  13927. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13928. }
  13929. if m.id == nil || m.oldValue == nil {
  13930. return v, errors.New("OldConditions requires an ID field in the mutation")
  13931. }
  13932. oldValue, err := m.oldValue(ctx)
  13933. if err != nil {
  13934. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13935. }
  13936. return oldValue.Conditions, nil
  13937. }
  13938. // ClearConditions clears the value of the "conditions" field.
  13939. func (m *LabelMutation) ClearConditions() {
  13940. m.conditions = nil
  13941. m.clearedFields[label.FieldConditions] = struct{}{}
  13942. }
  13943. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  13944. func (m *LabelMutation) ConditionsCleared() bool {
  13945. _, ok := m.clearedFields[label.FieldConditions]
  13946. return ok
  13947. }
  13948. // ResetConditions resets all changes to the "conditions" field.
  13949. func (m *LabelMutation) ResetConditions() {
  13950. m.conditions = nil
  13951. delete(m.clearedFields, label.FieldConditions)
  13952. }
  13953. // SetOrganizationID sets the "organization_id" field.
  13954. func (m *LabelMutation) SetOrganizationID(u uint64) {
  13955. m.organization_id = &u
  13956. m.addorganization_id = nil
  13957. }
  13958. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13959. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  13960. v := m.organization_id
  13961. if v == nil {
  13962. return
  13963. }
  13964. return *v, true
  13965. }
  13966. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  13967. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13969. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13970. if !m.op.Is(OpUpdateOne) {
  13971. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13972. }
  13973. if m.id == nil || m.oldValue == nil {
  13974. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13975. }
  13976. oldValue, err := m.oldValue(ctx)
  13977. if err != nil {
  13978. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13979. }
  13980. return oldValue.OrganizationID, nil
  13981. }
  13982. // AddOrganizationID adds u to the "organization_id" field.
  13983. func (m *LabelMutation) AddOrganizationID(u int64) {
  13984. if m.addorganization_id != nil {
  13985. *m.addorganization_id += u
  13986. } else {
  13987. m.addorganization_id = &u
  13988. }
  13989. }
  13990. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13991. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  13992. v := m.addorganization_id
  13993. if v == nil {
  13994. return
  13995. }
  13996. return *v, true
  13997. }
  13998. // ClearOrganizationID clears the value of the "organization_id" field.
  13999. func (m *LabelMutation) ClearOrganizationID() {
  14000. m.organization_id = nil
  14001. m.addorganization_id = nil
  14002. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14003. }
  14004. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14005. func (m *LabelMutation) OrganizationIDCleared() bool {
  14006. _, ok := m.clearedFields[label.FieldOrganizationID]
  14007. return ok
  14008. }
  14009. // ResetOrganizationID resets all changes to the "organization_id" field.
  14010. func (m *LabelMutation) ResetOrganizationID() {
  14011. m.organization_id = nil
  14012. m.addorganization_id = nil
  14013. delete(m.clearedFields, label.FieldOrganizationID)
  14014. }
  14015. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14016. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14017. if m.label_relationships == nil {
  14018. m.label_relationships = make(map[uint64]struct{})
  14019. }
  14020. for i := range ids {
  14021. m.label_relationships[ids[i]] = struct{}{}
  14022. }
  14023. }
  14024. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14025. func (m *LabelMutation) ClearLabelRelationships() {
  14026. m.clearedlabel_relationships = true
  14027. }
  14028. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14029. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14030. return m.clearedlabel_relationships
  14031. }
  14032. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14033. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14034. if m.removedlabel_relationships == nil {
  14035. m.removedlabel_relationships = make(map[uint64]struct{})
  14036. }
  14037. for i := range ids {
  14038. delete(m.label_relationships, ids[i])
  14039. m.removedlabel_relationships[ids[i]] = struct{}{}
  14040. }
  14041. }
  14042. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14043. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14044. for id := range m.removedlabel_relationships {
  14045. ids = append(ids, id)
  14046. }
  14047. return
  14048. }
  14049. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14050. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14051. for id := range m.label_relationships {
  14052. ids = append(ids, id)
  14053. }
  14054. return
  14055. }
  14056. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14057. func (m *LabelMutation) ResetLabelRelationships() {
  14058. m.label_relationships = nil
  14059. m.clearedlabel_relationships = false
  14060. m.removedlabel_relationships = nil
  14061. }
  14062. // Where appends a list predicates to the LabelMutation builder.
  14063. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14064. m.predicates = append(m.predicates, ps...)
  14065. }
  14066. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14067. // users can use type-assertion to append predicates that do not depend on any generated package.
  14068. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14069. p := make([]predicate.Label, len(ps))
  14070. for i := range ps {
  14071. p[i] = ps[i]
  14072. }
  14073. m.Where(p...)
  14074. }
  14075. // Op returns the operation name.
  14076. func (m *LabelMutation) Op() Op {
  14077. return m.op
  14078. }
  14079. // SetOp allows setting the mutation operation.
  14080. func (m *LabelMutation) SetOp(op Op) {
  14081. m.op = op
  14082. }
  14083. // Type returns the node type of this mutation (Label).
  14084. func (m *LabelMutation) Type() string {
  14085. return m.typ
  14086. }
  14087. // Fields returns all fields that were changed during this mutation. Note that in
  14088. // order to get all numeric fields that were incremented/decremented, call
  14089. // AddedFields().
  14090. func (m *LabelMutation) Fields() []string {
  14091. fields := make([]string, 0, 9)
  14092. if m.created_at != nil {
  14093. fields = append(fields, label.FieldCreatedAt)
  14094. }
  14095. if m.updated_at != nil {
  14096. fields = append(fields, label.FieldUpdatedAt)
  14097. }
  14098. if m.status != nil {
  14099. fields = append(fields, label.FieldStatus)
  14100. }
  14101. if m._type != nil {
  14102. fields = append(fields, label.FieldType)
  14103. }
  14104. if m.name != nil {
  14105. fields = append(fields, label.FieldName)
  14106. }
  14107. if m.from != nil {
  14108. fields = append(fields, label.FieldFrom)
  14109. }
  14110. if m.mode != nil {
  14111. fields = append(fields, label.FieldMode)
  14112. }
  14113. if m.conditions != nil {
  14114. fields = append(fields, label.FieldConditions)
  14115. }
  14116. if m.organization_id != nil {
  14117. fields = append(fields, label.FieldOrganizationID)
  14118. }
  14119. return fields
  14120. }
  14121. // Field returns the value of a field with the given name. The second boolean
  14122. // return value indicates that this field was not set, or was not defined in the
  14123. // schema.
  14124. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14125. switch name {
  14126. case label.FieldCreatedAt:
  14127. return m.CreatedAt()
  14128. case label.FieldUpdatedAt:
  14129. return m.UpdatedAt()
  14130. case label.FieldStatus:
  14131. return m.Status()
  14132. case label.FieldType:
  14133. return m.GetType()
  14134. case label.FieldName:
  14135. return m.Name()
  14136. case label.FieldFrom:
  14137. return m.From()
  14138. case label.FieldMode:
  14139. return m.Mode()
  14140. case label.FieldConditions:
  14141. return m.Conditions()
  14142. case label.FieldOrganizationID:
  14143. return m.OrganizationID()
  14144. }
  14145. return nil, false
  14146. }
  14147. // OldField returns the old value of the field from the database. An error is
  14148. // returned if the mutation operation is not UpdateOne, or the query to the
  14149. // database failed.
  14150. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14151. switch name {
  14152. case label.FieldCreatedAt:
  14153. return m.OldCreatedAt(ctx)
  14154. case label.FieldUpdatedAt:
  14155. return m.OldUpdatedAt(ctx)
  14156. case label.FieldStatus:
  14157. return m.OldStatus(ctx)
  14158. case label.FieldType:
  14159. return m.OldType(ctx)
  14160. case label.FieldName:
  14161. return m.OldName(ctx)
  14162. case label.FieldFrom:
  14163. return m.OldFrom(ctx)
  14164. case label.FieldMode:
  14165. return m.OldMode(ctx)
  14166. case label.FieldConditions:
  14167. return m.OldConditions(ctx)
  14168. case label.FieldOrganizationID:
  14169. return m.OldOrganizationID(ctx)
  14170. }
  14171. return nil, fmt.Errorf("unknown Label field %s", name)
  14172. }
  14173. // SetField sets the value of a field with the given name. It returns an error if
  14174. // the field is not defined in the schema, or if the type mismatched the field
  14175. // type.
  14176. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14177. switch name {
  14178. case label.FieldCreatedAt:
  14179. v, ok := value.(time.Time)
  14180. if !ok {
  14181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14182. }
  14183. m.SetCreatedAt(v)
  14184. return nil
  14185. case label.FieldUpdatedAt:
  14186. v, ok := value.(time.Time)
  14187. if !ok {
  14188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14189. }
  14190. m.SetUpdatedAt(v)
  14191. return nil
  14192. case label.FieldStatus:
  14193. v, ok := value.(uint8)
  14194. if !ok {
  14195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14196. }
  14197. m.SetStatus(v)
  14198. return nil
  14199. case label.FieldType:
  14200. v, ok := value.(int)
  14201. if !ok {
  14202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14203. }
  14204. m.SetType(v)
  14205. return nil
  14206. case label.FieldName:
  14207. v, ok := value.(string)
  14208. if !ok {
  14209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14210. }
  14211. m.SetName(v)
  14212. return nil
  14213. case label.FieldFrom:
  14214. v, ok := value.(int)
  14215. if !ok {
  14216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14217. }
  14218. m.SetFrom(v)
  14219. return nil
  14220. case label.FieldMode:
  14221. v, ok := value.(int)
  14222. if !ok {
  14223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14224. }
  14225. m.SetMode(v)
  14226. return nil
  14227. case label.FieldConditions:
  14228. v, ok := value.(string)
  14229. if !ok {
  14230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14231. }
  14232. m.SetConditions(v)
  14233. return nil
  14234. case label.FieldOrganizationID:
  14235. v, ok := value.(uint64)
  14236. if !ok {
  14237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14238. }
  14239. m.SetOrganizationID(v)
  14240. return nil
  14241. }
  14242. return fmt.Errorf("unknown Label field %s", name)
  14243. }
  14244. // AddedFields returns all numeric fields that were incremented/decremented during
  14245. // this mutation.
  14246. func (m *LabelMutation) AddedFields() []string {
  14247. var fields []string
  14248. if m.addstatus != nil {
  14249. fields = append(fields, label.FieldStatus)
  14250. }
  14251. if m.add_type != nil {
  14252. fields = append(fields, label.FieldType)
  14253. }
  14254. if m.addfrom != nil {
  14255. fields = append(fields, label.FieldFrom)
  14256. }
  14257. if m.addmode != nil {
  14258. fields = append(fields, label.FieldMode)
  14259. }
  14260. if m.addorganization_id != nil {
  14261. fields = append(fields, label.FieldOrganizationID)
  14262. }
  14263. return fields
  14264. }
  14265. // AddedField returns the numeric value that was incremented/decremented on a field
  14266. // with the given name. The second boolean return value indicates that this field
  14267. // was not set, or was not defined in the schema.
  14268. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14269. switch name {
  14270. case label.FieldStatus:
  14271. return m.AddedStatus()
  14272. case label.FieldType:
  14273. return m.AddedType()
  14274. case label.FieldFrom:
  14275. return m.AddedFrom()
  14276. case label.FieldMode:
  14277. return m.AddedMode()
  14278. case label.FieldOrganizationID:
  14279. return m.AddedOrganizationID()
  14280. }
  14281. return nil, false
  14282. }
  14283. // AddField adds the value to the field with the given name. It returns an error if
  14284. // the field is not defined in the schema, or if the type mismatched the field
  14285. // type.
  14286. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14287. switch name {
  14288. case label.FieldStatus:
  14289. v, ok := value.(int8)
  14290. if !ok {
  14291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14292. }
  14293. m.AddStatus(v)
  14294. return nil
  14295. case label.FieldType:
  14296. v, ok := value.(int)
  14297. if !ok {
  14298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14299. }
  14300. m.AddType(v)
  14301. return nil
  14302. case label.FieldFrom:
  14303. v, ok := value.(int)
  14304. if !ok {
  14305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14306. }
  14307. m.AddFrom(v)
  14308. return nil
  14309. case label.FieldMode:
  14310. v, ok := value.(int)
  14311. if !ok {
  14312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14313. }
  14314. m.AddMode(v)
  14315. return nil
  14316. case label.FieldOrganizationID:
  14317. v, ok := value.(int64)
  14318. if !ok {
  14319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14320. }
  14321. m.AddOrganizationID(v)
  14322. return nil
  14323. }
  14324. return fmt.Errorf("unknown Label numeric field %s", name)
  14325. }
  14326. // ClearedFields returns all nullable fields that were cleared during this
  14327. // mutation.
  14328. func (m *LabelMutation) ClearedFields() []string {
  14329. var fields []string
  14330. if m.FieldCleared(label.FieldStatus) {
  14331. fields = append(fields, label.FieldStatus)
  14332. }
  14333. if m.FieldCleared(label.FieldConditions) {
  14334. fields = append(fields, label.FieldConditions)
  14335. }
  14336. if m.FieldCleared(label.FieldOrganizationID) {
  14337. fields = append(fields, label.FieldOrganizationID)
  14338. }
  14339. return fields
  14340. }
  14341. // FieldCleared returns a boolean indicating if a field with the given name was
  14342. // cleared in this mutation.
  14343. func (m *LabelMutation) FieldCleared(name string) bool {
  14344. _, ok := m.clearedFields[name]
  14345. return ok
  14346. }
  14347. // ClearField clears the value of the field with the given name. It returns an
  14348. // error if the field is not defined in the schema.
  14349. func (m *LabelMutation) ClearField(name string) error {
  14350. switch name {
  14351. case label.FieldStatus:
  14352. m.ClearStatus()
  14353. return nil
  14354. case label.FieldConditions:
  14355. m.ClearConditions()
  14356. return nil
  14357. case label.FieldOrganizationID:
  14358. m.ClearOrganizationID()
  14359. return nil
  14360. }
  14361. return fmt.Errorf("unknown Label nullable field %s", name)
  14362. }
  14363. // ResetField resets all changes in the mutation for the field with the given name.
  14364. // It returns an error if the field is not defined in the schema.
  14365. func (m *LabelMutation) ResetField(name string) error {
  14366. switch name {
  14367. case label.FieldCreatedAt:
  14368. m.ResetCreatedAt()
  14369. return nil
  14370. case label.FieldUpdatedAt:
  14371. m.ResetUpdatedAt()
  14372. return nil
  14373. case label.FieldStatus:
  14374. m.ResetStatus()
  14375. return nil
  14376. case label.FieldType:
  14377. m.ResetType()
  14378. return nil
  14379. case label.FieldName:
  14380. m.ResetName()
  14381. return nil
  14382. case label.FieldFrom:
  14383. m.ResetFrom()
  14384. return nil
  14385. case label.FieldMode:
  14386. m.ResetMode()
  14387. return nil
  14388. case label.FieldConditions:
  14389. m.ResetConditions()
  14390. return nil
  14391. case label.FieldOrganizationID:
  14392. m.ResetOrganizationID()
  14393. return nil
  14394. }
  14395. return fmt.Errorf("unknown Label field %s", name)
  14396. }
  14397. // AddedEdges returns all edge names that were set/added in this mutation.
  14398. func (m *LabelMutation) AddedEdges() []string {
  14399. edges := make([]string, 0, 1)
  14400. if m.label_relationships != nil {
  14401. edges = append(edges, label.EdgeLabelRelationships)
  14402. }
  14403. return edges
  14404. }
  14405. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14406. // name in this mutation.
  14407. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14408. switch name {
  14409. case label.EdgeLabelRelationships:
  14410. ids := make([]ent.Value, 0, len(m.label_relationships))
  14411. for id := range m.label_relationships {
  14412. ids = append(ids, id)
  14413. }
  14414. return ids
  14415. }
  14416. return nil
  14417. }
  14418. // RemovedEdges returns all edge names that were removed in this mutation.
  14419. func (m *LabelMutation) RemovedEdges() []string {
  14420. edges := make([]string, 0, 1)
  14421. if m.removedlabel_relationships != nil {
  14422. edges = append(edges, label.EdgeLabelRelationships)
  14423. }
  14424. return edges
  14425. }
  14426. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14427. // the given name in this mutation.
  14428. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14429. switch name {
  14430. case label.EdgeLabelRelationships:
  14431. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14432. for id := range m.removedlabel_relationships {
  14433. ids = append(ids, id)
  14434. }
  14435. return ids
  14436. }
  14437. return nil
  14438. }
  14439. // ClearedEdges returns all edge names that were cleared in this mutation.
  14440. func (m *LabelMutation) ClearedEdges() []string {
  14441. edges := make([]string, 0, 1)
  14442. if m.clearedlabel_relationships {
  14443. edges = append(edges, label.EdgeLabelRelationships)
  14444. }
  14445. return edges
  14446. }
  14447. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14448. // was cleared in this mutation.
  14449. func (m *LabelMutation) EdgeCleared(name string) bool {
  14450. switch name {
  14451. case label.EdgeLabelRelationships:
  14452. return m.clearedlabel_relationships
  14453. }
  14454. return false
  14455. }
  14456. // ClearEdge clears the value of the edge with the given name. It returns an error
  14457. // if that edge is not defined in the schema.
  14458. func (m *LabelMutation) ClearEdge(name string) error {
  14459. switch name {
  14460. }
  14461. return fmt.Errorf("unknown Label unique edge %s", name)
  14462. }
  14463. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14464. // It returns an error if the edge is not defined in the schema.
  14465. func (m *LabelMutation) ResetEdge(name string) error {
  14466. switch name {
  14467. case label.EdgeLabelRelationships:
  14468. m.ResetLabelRelationships()
  14469. return nil
  14470. }
  14471. return fmt.Errorf("unknown Label edge %s", name)
  14472. }
  14473. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14474. type LabelRelationshipMutation struct {
  14475. config
  14476. op Op
  14477. typ string
  14478. id *uint64
  14479. created_at *time.Time
  14480. updated_at *time.Time
  14481. status *uint8
  14482. addstatus *int8
  14483. deleted_at *time.Time
  14484. organization_id *uint64
  14485. addorganization_id *int64
  14486. clearedFields map[string]struct{}
  14487. contacts *uint64
  14488. clearedcontacts bool
  14489. labels *uint64
  14490. clearedlabels bool
  14491. done bool
  14492. oldValue func(context.Context) (*LabelRelationship, error)
  14493. predicates []predicate.LabelRelationship
  14494. }
  14495. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14496. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14497. type labelrelationshipOption func(*LabelRelationshipMutation)
  14498. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14499. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14500. m := &LabelRelationshipMutation{
  14501. config: c,
  14502. op: op,
  14503. typ: TypeLabelRelationship,
  14504. clearedFields: make(map[string]struct{}),
  14505. }
  14506. for _, opt := range opts {
  14507. opt(m)
  14508. }
  14509. return m
  14510. }
  14511. // withLabelRelationshipID sets the ID field of the mutation.
  14512. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14513. return func(m *LabelRelationshipMutation) {
  14514. var (
  14515. err error
  14516. once sync.Once
  14517. value *LabelRelationship
  14518. )
  14519. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14520. once.Do(func() {
  14521. if m.done {
  14522. err = errors.New("querying old values post mutation is not allowed")
  14523. } else {
  14524. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14525. }
  14526. })
  14527. return value, err
  14528. }
  14529. m.id = &id
  14530. }
  14531. }
  14532. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14533. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14534. return func(m *LabelRelationshipMutation) {
  14535. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14536. return node, nil
  14537. }
  14538. m.id = &node.ID
  14539. }
  14540. }
  14541. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14542. // executed in a transaction (ent.Tx), a transactional client is returned.
  14543. func (m LabelRelationshipMutation) Client() *Client {
  14544. client := &Client{config: m.config}
  14545. client.init()
  14546. return client
  14547. }
  14548. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14549. // it returns an error otherwise.
  14550. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14551. if _, ok := m.driver.(*txDriver); !ok {
  14552. return nil, errors.New("ent: mutation is not running in a transaction")
  14553. }
  14554. tx := &Tx{config: m.config}
  14555. tx.init()
  14556. return tx, nil
  14557. }
  14558. // SetID sets the value of the id field. Note that this
  14559. // operation is only accepted on creation of LabelRelationship entities.
  14560. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14561. m.id = &id
  14562. }
  14563. // ID returns the ID value in the mutation. Note that the ID is only available
  14564. // if it was provided to the builder or after it was returned from the database.
  14565. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14566. if m.id == nil {
  14567. return
  14568. }
  14569. return *m.id, true
  14570. }
  14571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14572. // That means, if the mutation is applied within a transaction with an isolation level such
  14573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14574. // or updated by the mutation.
  14575. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14576. switch {
  14577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14578. id, exists := m.ID()
  14579. if exists {
  14580. return []uint64{id}, nil
  14581. }
  14582. fallthrough
  14583. case m.op.Is(OpUpdate | OpDelete):
  14584. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14585. default:
  14586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14587. }
  14588. }
  14589. // SetCreatedAt sets the "created_at" field.
  14590. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14591. m.created_at = &t
  14592. }
  14593. // CreatedAt returns the value of the "created_at" field in the mutation.
  14594. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14595. v := m.created_at
  14596. if v == nil {
  14597. return
  14598. }
  14599. return *v, true
  14600. }
  14601. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14602. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14604. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14605. if !m.op.Is(OpUpdateOne) {
  14606. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14607. }
  14608. if m.id == nil || m.oldValue == nil {
  14609. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14610. }
  14611. oldValue, err := m.oldValue(ctx)
  14612. if err != nil {
  14613. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14614. }
  14615. return oldValue.CreatedAt, nil
  14616. }
  14617. // ResetCreatedAt resets all changes to the "created_at" field.
  14618. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14619. m.created_at = nil
  14620. }
  14621. // SetUpdatedAt sets the "updated_at" field.
  14622. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14623. m.updated_at = &t
  14624. }
  14625. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14626. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14627. v := m.updated_at
  14628. if v == nil {
  14629. return
  14630. }
  14631. return *v, true
  14632. }
  14633. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14634. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14636. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14637. if !m.op.Is(OpUpdateOne) {
  14638. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14639. }
  14640. if m.id == nil || m.oldValue == nil {
  14641. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14642. }
  14643. oldValue, err := m.oldValue(ctx)
  14644. if err != nil {
  14645. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14646. }
  14647. return oldValue.UpdatedAt, nil
  14648. }
  14649. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14650. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14651. m.updated_at = nil
  14652. }
  14653. // SetStatus sets the "status" field.
  14654. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14655. m.status = &u
  14656. m.addstatus = nil
  14657. }
  14658. // Status returns the value of the "status" field in the mutation.
  14659. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14660. v := m.status
  14661. if v == nil {
  14662. return
  14663. }
  14664. return *v, true
  14665. }
  14666. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14667. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14669. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14670. if !m.op.Is(OpUpdateOne) {
  14671. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14672. }
  14673. if m.id == nil || m.oldValue == nil {
  14674. return v, errors.New("OldStatus requires an ID field in the mutation")
  14675. }
  14676. oldValue, err := m.oldValue(ctx)
  14677. if err != nil {
  14678. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14679. }
  14680. return oldValue.Status, nil
  14681. }
  14682. // AddStatus adds u to the "status" field.
  14683. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14684. if m.addstatus != nil {
  14685. *m.addstatus += u
  14686. } else {
  14687. m.addstatus = &u
  14688. }
  14689. }
  14690. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14691. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14692. v := m.addstatus
  14693. if v == nil {
  14694. return
  14695. }
  14696. return *v, true
  14697. }
  14698. // ClearStatus clears the value of the "status" field.
  14699. func (m *LabelRelationshipMutation) ClearStatus() {
  14700. m.status = nil
  14701. m.addstatus = nil
  14702. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14703. }
  14704. // StatusCleared returns if the "status" field was cleared in this mutation.
  14705. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14706. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14707. return ok
  14708. }
  14709. // ResetStatus resets all changes to the "status" field.
  14710. func (m *LabelRelationshipMutation) ResetStatus() {
  14711. m.status = nil
  14712. m.addstatus = nil
  14713. delete(m.clearedFields, labelrelationship.FieldStatus)
  14714. }
  14715. // SetDeletedAt sets the "deleted_at" field.
  14716. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  14717. m.deleted_at = &t
  14718. }
  14719. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14720. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  14721. v := m.deleted_at
  14722. if v == nil {
  14723. return
  14724. }
  14725. return *v, true
  14726. }
  14727. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  14728. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14730. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14731. if !m.op.Is(OpUpdateOne) {
  14732. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14733. }
  14734. if m.id == nil || m.oldValue == nil {
  14735. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14736. }
  14737. oldValue, err := m.oldValue(ctx)
  14738. if err != nil {
  14739. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14740. }
  14741. return oldValue.DeletedAt, nil
  14742. }
  14743. // ClearDeletedAt clears the value of the "deleted_at" field.
  14744. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  14745. m.deleted_at = nil
  14746. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  14747. }
  14748. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14749. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  14750. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  14751. return ok
  14752. }
  14753. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14754. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  14755. m.deleted_at = nil
  14756. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  14757. }
  14758. // SetLabelID sets the "label_id" field.
  14759. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14760. m.labels = &u
  14761. }
  14762. // LabelID returns the value of the "label_id" field in the mutation.
  14763. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14764. v := m.labels
  14765. if v == nil {
  14766. return
  14767. }
  14768. return *v, true
  14769. }
  14770. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14771. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14773. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14774. if !m.op.Is(OpUpdateOne) {
  14775. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14776. }
  14777. if m.id == nil || m.oldValue == nil {
  14778. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14779. }
  14780. oldValue, err := m.oldValue(ctx)
  14781. if err != nil {
  14782. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14783. }
  14784. return oldValue.LabelID, nil
  14785. }
  14786. // ResetLabelID resets all changes to the "label_id" field.
  14787. func (m *LabelRelationshipMutation) ResetLabelID() {
  14788. m.labels = nil
  14789. }
  14790. // SetContactID sets the "contact_id" field.
  14791. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14792. m.contacts = &u
  14793. }
  14794. // ContactID returns the value of the "contact_id" field in the mutation.
  14795. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14796. v := m.contacts
  14797. if v == nil {
  14798. return
  14799. }
  14800. return *v, true
  14801. }
  14802. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14803. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14805. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14806. if !m.op.Is(OpUpdateOne) {
  14807. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14808. }
  14809. if m.id == nil || m.oldValue == nil {
  14810. return v, errors.New("OldContactID requires an ID field in the mutation")
  14811. }
  14812. oldValue, err := m.oldValue(ctx)
  14813. if err != nil {
  14814. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14815. }
  14816. return oldValue.ContactID, nil
  14817. }
  14818. // ResetContactID resets all changes to the "contact_id" field.
  14819. func (m *LabelRelationshipMutation) ResetContactID() {
  14820. m.contacts = nil
  14821. }
  14822. // SetOrganizationID sets the "organization_id" field.
  14823. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14824. m.organization_id = &u
  14825. m.addorganization_id = nil
  14826. }
  14827. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14828. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14829. v := m.organization_id
  14830. if v == nil {
  14831. return
  14832. }
  14833. return *v, true
  14834. }
  14835. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14836. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14838. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14839. if !m.op.Is(OpUpdateOne) {
  14840. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14841. }
  14842. if m.id == nil || m.oldValue == nil {
  14843. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14844. }
  14845. oldValue, err := m.oldValue(ctx)
  14846. if err != nil {
  14847. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14848. }
  14849. return oldValue.OrganizationID, nil
  14850. }
  14851. // AddOrganizationID adds u to the "organization_id" field.
  14852. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14853. if m.addorganization_id != nil {
  14854. *m.addorganization_id += u
  14855. } else {
  14856. m.addorganization_id = &u
  14857. }
  14858. }
  14859. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14860. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14861. v := m.addorganization_id
  14862. if v == nil {
  14863. return
  14864. }
  14865. return *v, true
  14866. }
  14867. // ClearOrganizationID clears the value of the "organization_id" field.
  14868. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14869. m.organization_id = nil
  14870. m.addorganization_id = nil
  14871. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14872. }
  14873. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14874. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14875. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14876. return ok
  14877. }
  14878. // ResetOrganizationID resets all changes to the "organization_id" field.
  14879. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14880. m.organization_id = nil
  14881. m.addorganization_id = nil
  14882. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14883. }
  14884. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14885. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14886. m.contacts = &id
  14887. }
  14888. // ClearContacts clears the "contacts" edge to the Contact entity.
  14889. func (m *LabelRelationshipMutation) ClearContacts() {
  14890. m.clearedcontacts = true
  14891. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14892. }
  14893. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14894. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14895. return m.clearedcontacts
  14896. }
  14897. // ContactsID returns the "contacts" edge ID in the mutation.
  14898. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14899. if m.contacts != nil {
  14900. return *m.contacts, true
  14901. }
  14902. return
  14903. }
  14904. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14905. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14906. // ContactsID instead. It exists only for internal usage by the builders.
  14907. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14908. if id := m.contacts; id != nil {
  14909. ids = append(ids, *id)
  14910. }
  14911. return
  14912. }
  14913. // ResetContacts resets all changes to the "contacts" edge.
  14914. func (m *LabelRelationshipMutation) ResetContacts() {
  14915. m.contacts = nil
  14916. m.clearedcontacts = false
  14917. }
  14918. // SetLabelsID sets the "labels" edge to the Label entity by id.
  14919. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  14920. m.labels = &id
  14921. }
  14922. // ClearLabels clears the "labels" edge to the Label entity.
  14923. func (m *LabelRelationshipMutation) ClearLabels() {
  14924. m.clearedlabels = true
  14925. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  14926. }
  14927. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  14928. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  14929. return m.clearedlabels
  14930. }
  14931. // LabelsID returns the "labels" edge ID in the mutation.
  14932. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  14933. if m.labels != nil {
  14934. return *m.labels, true
  14935. }
  14936. return
  14937. }
  14938. // LabelsIDs returns the "labels" edge IDs in the mutation.
  14939. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14940. // LabelsID instead. It exists only for internal usage by the builders.
  14941. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  14942. if id := m.labels; id != nil {
  14943. ids = append(ids, *id)
  14944. }
  14945. return
  14946. }
  14947. // ResetLabels resets all changes to the "labels" edge.
  14948. func (m *LabelRelationshipMutation) ResetLabels() {
  14949. m.labels = nil
  14950. m.clearedlabels = false
  14951. }
  14952. // Where appends a list predicates to the LabelRelationshipMutation builder.
  14953. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  14954. m.predicates = append(m.predicates, ps...)
  14955. }
  14956. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  14957. // users can use type-assertion to append predicates that do not depend on any generated package.
  14958. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  14959. p := make([]predicate.LabelRelationship, len(ps))
  14960. for i := range ps {
  14961. p[i] = ps[i]
  14962. }
  14963. m.Where(p...)
  14964. }
  14965. // Op returns the operation name.
  14966. func (m *LabelRelationshipMutation) Op() Op {
  14967. return m.op
  14968. }
  14969. // SetOp allows setting the mutation operation.
  14970. func (m *LabelRelationshipMutation) SetOp(op Op) {
  14971. m.op = op
  14972. }
  14973. // Type returns the node type of this mutation (LabelRelationship).
  14974. func (m *LabelRelationshipMutation) Type() string {
  14975. return m.typ
  14976. }
  14977. // Fields returns all fields that were changed during this mutation. Note that in
  14978. // order to get all numeric fields that were incremented/decremented, call
  14979. // AddedFields().
  14980. func (m *LabelRelationshipMutation) Fields() []string {
  14981. fields := make([]string, 0, 7)
  14982. if m.created_at != nil {
  14983. fields = append(fields, labelrelationship.FieldCreatedAt)
  14984. }
  14985. if m.updated_at != nil {
  14986. fields = append(fields, labelrelationship.FieldUpdatedAt)
  14987. }
  14988. if m.status != nil {
  14989. fields = append(fields, labelrelationship.FieldStatus)
  14990. }
  14991. if m.deleted_at != nil {
  14992. fields = append(fields, labelrelationship.FieldDeletedAt)
  14993. }
  14994. if m.labels != nil {
  14995. fields = append(fields, labelrelationship.FieldLabelID)
  14996. }
  14997. if m.contacts != nil {
  14998. fields = append(fields, labelrelationship.FieldContactID)
  14999. }
  15000. if m.organization_id != nil {
  15001. fields = append(fields, labelrelationship.FieldOrganizationID)
  15002. }
  15003. return fields
  15004. }
  15005. // Field returns the value of a field with the given name. The second boolean
  15006. // return value indicates that this field was not set, or was not defined in the
  15007. // schema.
  15008. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15009. switch name {
  15010. case labelrelationship.FieldCreatedAt:
  15011. return m.CreatedAt()
  15012. case labelrelationship.FieldUpdatedAt:
  15013. return m.UpdatedAt()
  15014. case labelrelationship.FieldStatus:
  15015. return m.Status()
  15016. case labelrelationship.FieldDeletedAt:
  15017. return m.DeletedAt()
  15018. case labelrelationship.FieldLabelID:
  15019. return m.LabelID()
  15020. case labelrelationship.FieldContactID:
  15021. return m.ContactID()
  15022. case labelrelationship.FieldOrganizationID:
  15023. return m.OrganizationID()
  15024. }
  15025. return nil, false
  15026. }
  15027. // OldField returns the old value of the field from the database. An error is
  15028. // returned if the mutation operation is not UpdateOne, or the query to the
  15029. // database failed.
  15030. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15031. switch name {
  15032. case labelrelationship.FieldCreatedAt:
  15033. return m.OldCreatedAt(ctx)
  15034. case labelrelationship.FieldUpdatedAt:
  15035. return m.OldUpdatedAt(ctx)
  15036. case labelrelationship.FieldStatus:
  15037. return m.OldStatus(ctx)
  15038. case labelrelationship.FieldDeletedAt:
  15039. return m.OldDeletedAt(ctx)
  15040. case labelrelationship.FieldLabelID:
  15041. return m.OldLabelID(ctx)
  15042. case labelrelationship.FieldContactID:
  15043. return m.OldContactID(ctx)
  15044. case labelrelationship.FieldOrganizationID:
  15045. return m.OldOrganizationID(ctx)
  15046. }
  15047. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15048. }
  15049. // SetField sets the value of a field with the given name. It returns an error if
  15050. // the field is not defined in the schema, or if the type mismatched the field
  15051. // type.
  15052. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15053. switch name {
  15054. case labelrelationship.FieldCreatedAt:
  15055. v, ok := value.(time.Time)
  15056. if !ok {
  15057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15058. }
  15059. m.SetCreatedAt(v)
  15060. return nil
  15061. case labelrelationship.FieldUpdatedAt:
  15062. v, ok := value.(time.Time)
  15063. if !ok {
  15064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15065. }
  15066. m.SetUpdatedAt(v)
  15067. return nil
  15068. case labelrelationship.FieldStatus:
  15069. v, ok := value.(uint8)
  15070. if !ok {
  15071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15072. }
  15073. m.SetStatus(v)
  15074. return nil
  15075. case labelrelationship.FieldDeletedAt:
  15076. v, ok := value.(time.Time)
  15077. if !ok {
  15078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15079. }
  15080. m.SetDeletedAt(v)
  15081. return nil
  15082. case labelrelationship.FieldLabelID:
  15083. v, ok := value.(uint64)
  15084. if !ok {
  15085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15086. }
  15087. m.SetLabelID(v)
  15088. return nil
  15089. case labelrelationship.FieldContactID:
  15090. v, ok := value.(uint64)
  15091. if !ok {
  15092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15093. }
  15094. m.SetContactID(v)
  15095. return nil
  15096. case labelrelationship.FieldOrganizationID:
  15097. v, ok := value.(uint64)
  15098. if !ok {
  15099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15100. }
  15101. m.SetOrganizationID(v)
  15102. return nil
  15103. }
  15104. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15105. }
  15106. // AddedFields returns all numeric fields that were incremented/decremented during
  15107. // this mutation.
  15108. func (m *LabelRelationshipMutation) AddedFields() []string {
  15109. var fields []string
  15110. if m.addstatus != nil {
  15111. fields = append(fields, labelrelationship.FieldStatus)
  15112. }
  15113. if m.addorganization_id != nil {
  15114. fields = append(fields, labelrelationship.FieldOrganizationID)
  15115. }
  15116. return fields
  15117. }
  15118. // AddedField returns the numeric value that was incremented/decremented on a field
  15119. // with the given name. The second boolean return value indicates that this field
  15120. // was not set, or was not defined in the schema.
  15121. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15122. switch name {
  15123. case labelrelationship.FieldStatus:
  15124. return m.AddedStatus()
  15125. case labelrelationship.FieldOrganizationID:
  15126. return m.AddedOrganizationID()
  15127. }
  15128. return nil, false
  15129. }
  15130. // AddField adds the value to the field with the given name. It returns an error if
  15131. // the field is not defined in the schema, or if the type mismatched the field
  15132. // type.
  15133. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15134. switch name {
  15135. case labelrelationship.FieldStatus:
  15136. v, ok := value.(int8)
  15137. if !ok {
  15138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15139. }
  15140. m.AddStatus(v)
  15141. return nil
  15142. case labelrelationship.FieldOrganizationID:
  15143. v, ok := value.(int64)
  15144. if !ok {
  15145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15146. }
  15147. m.AddOrganizationID(v)
  15148. return nil
  15149. }
  15150. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15151. }
  15152. // ClearedFields returns all nullable fields that were cleared during this
  15153. // mutation.
  15154. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15155. var fields []string
  15156. if m.FieldCleared(labelrelationship.FieldStatus) {
  15157. fields = append(fields, labelrelationship.FieldStatus)
  15158. }
  15159. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  15160. fields = append(fields, labelrelationship.FieldDeletedAt)
  15161. }
  15162. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15163. fields = append(fields, labelrelationship.FieldOrganizationID)
  15164. }
  15165. return fields
  15166. }
  15167. // FieldCleared returns a boolean indicating if a field with the given name was
  15168. // cleared in this mutation.
  15169. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15170. _, ok := m.clearedFields[name]
  15171. return ok
  15172. }
  15173. // ClearField clears the value of the field with the given name. It returns an
  15174. // error if the field is not defined in the schema.
  15175. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15176. switch name {
  15177. case labelrelationship.FieldStatus:
  15178. m.ClearStatus()
  15179. return nil
  15180. case labelrelationship.FieldDeletedAt:
  15181. m.ClearDeletedAt()
  15182. return nil
  15183. case labelrelationship.FieldOrganizationID:
  15184. m.ClearOrganizationID()
  15185. return nil
  15186. }
  15187. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15188. }
  15189. // ResetField resets all changes in the mutation for the field with the given name.
  15190. // It returns an error if the field is not defined in the schema.
  15191. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15192. switch name {
  15193. case labelrelationship.FieldCreatedAt:
  15194. m.ResetCreatedAt()
  15195. return nil
  15196. case labelrelationship.FieldUpdatedAt:
  15197. m.ResetUpdatedAt()
  15198. return nil
  15199. case labelrelationship.FieldStatus:
  15200. m.ResetStatus()
  15201. return nil
  15202. case labelrelationship.FieldDeletedAt:
  15203. m.ResetDeletedAt()
  15204. return nil
  15205. case labelrelationship.FieldLabelID:
  15206. m.ResetLabelID()
  15207. return nil
  15208. case labelrelationship.FieldContactID:
  15209. m.ResetContactID()
  15210. return nil
  15211. case labelrelationship.FieldOrganizationID:
  15212. m.ResetOrganizationID()
  15213. return nil
  15214. }
  15215. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15216. }
  15217. // AddedEdges returns all edge names that were set/added in this mutation.
  15218. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15219. edges := make([]string, 0, 2)
  15220. if m.contacts != nil {
  15221. edges = append(edges, labelrelationship.EdgeContacts)
  15222. }
  15223. if m.labels != nil {
  15224. edges = append(edges, labelrelationship.EdgeLabels)
  15225. }
  15226. return edges
  15227. }
  15228. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15229. // name in this mutation.
  15230. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15231. switch name {
  15232. case labelrelationship.EdgeContacts:
  15233. if id := m.contacts; id != nil {
  15234. return []ent.Value{*id}
  15235. }
  15236. case labelrelationship.EdgeLabels:
  15237. if id := m.labels; id != nil {
  15238. return []ent.Value{*id}
  15239. }
  15240. }
  15241. return nil
  15242. }
  15243. // RemovedEdges returns all edge names that were removed in this mutation.
  15244. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15245. edges := make([]string, 0, 2)
  15246. return edges
  15247. }
  15248. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15249. // the given name in this mutation.
  15250. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15251. return nil
  15252. }
  15253. // ClearedEdges returns all edge names that were cleared in this mutation.
  15254. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15255. edges := make([]string, 0, 2)
  15256. if m.clearedcontacts {
  15257. edges = append(edges, labelrelationship.EdgeContacts)
  15258. }
  15259. if m.clearedlabels {
  15260. edges = append(edges, labelrelationship.EdgeLabels)
  15261. }
  15262. return edges
  15263. }
  15264. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15265. // was cleared in this mutation.
  15266. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15267. switch name {
  15268. case labelrelationship.EdgeContacts:
  15269. return m.clearedcontacts
  15270. case labelrelationship.EdgeLabels:
  15271. return m.clearedlabels
  15272. }
  15273. return false
  15274. }
  15275. // ClearEdge clears the value of the edge with the given name. It returns an error
  15276. // if that edge is not defined in the schema.
  15277. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15278. switch name {
  15279. case labelrelationship.EdgeContacts:
  15280. m.ClearContacts()
  15281. return nil
  15282. case labelrelationship.EdgeLabels:
  15283. m.ClearLabels()
  15284. return nil
  15285. }
  15286. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15287. }
  15288. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15289. // It returns an error if the edge is not defined in the schema.
  15290. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15291. switch name {
  15292. case labelrelationship.EdgeContacts:
  15293. m.ResetContacts()
  15294. return nil
  15295. case labelrelationship.EdgeLabels:
  15296. m.ResetLabels()
  15297. return nil
  15298. }
  15299. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15300. }
  15301. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15302. type LabelTaggingMutation struct {
  15303. config
  15304. op Op
  15305. typ string
  15306. id *uint64
  15307. created_at *time.Time
  15308. updated_at *time.Time
  15309. status *uint8
  15310. addstatus *int8
  15311. deleted_at *time.Time
  15312. organization_id *uint64
  15313. addorganization_id *int64
  15314. _type *int
  15315. add_type *int
  15316. conditions *string
  15317. action_label_add *[]uint64
  15318. appendaction_label_add []uint64
  15319. action_label_del *[]uint64
  15320. appendaction_label_del []uint64
  15321. clearedFields map[string]struct{}
  15322. done bool
  15323. oldValue func(context.Context) (*LabelTagging, error)
  15324. predicates []predicate.LabelTagging
  15325. }
  15326. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15327. // labeltaggingOption allows management of the mutation configuration using functional options.
  15328. type labeltaggingOption func(*LabelTaggingMutation)
  15329. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15330. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15331. m := &LabelTaggingMutation{
  15332. config: c,
  15333. op: op,
  15334. typ: TypeLabelTagging,
  15335. clearedFields: make(map[string]struct{}),
  15336. }
  15337. for _, opt := range opts {
  15338. opt(m)
  15339. }
  15340. return m
  15341. }
  15342. // withLabelTaggingID sets the ID field of the mutation.
  15343. func withLabelTaggingID(id uint64) labeltaggingOption {
  15344. return func(m *LabelTaggingMutation) {
  15345. var (
  15346. err error
  15347. once sync.Once
  15348. value *LabelTagging
  15349. )
  15350. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15351. once.Do(func() {
  15352. if m.done {
  15353. err = errors.New("querying old values post mutation is not allowed")
  15354. } else {
  15355. value, err = m.Client().LabelTagging.Get(ctx, id)
  15356. }
  15357. })
  15358. return value, err
  15359. }
  15360. m.id = &id
  15361. }
  15362. }
  15363. // withLabelTagging sets the old LabelTagging of the mutation.
  15364. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15365. return func(m *LabelTaggingMutation) {
  15366. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15367. return node, nil
  15368. }
  15369. m.id = &node.ID
  15370. }
  15371. }
  15372. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15373. // executed in a transaction (ent.Tx), a transactional client is returned.
  15374. func (m LabelTaggingMutation) Client() *Client {
  15375. client := &Client{config: m.config}
  15376. client.init()
  15377. return client
  15378. }
  15379. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15380. // it returns an error otherwise.
  15381. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15382. if _, ok := m.driver.(*txDriver); !ok {
  15383. return nil, errors.New("ent: mutation is not running in a transaction")
  15384. }
  15385. tx := &Tx{config: m.config}
  15386. tx.init()
  15387. return tx, nil
  15388. }
  15389. // SetID sets the value of the id field. Note that this
  15390. // operation is only accepted on creation of LabelTagging entities.
  15391. func (m *LabelTaggingMutation) SetID(id uint64) {
  15392. m.id = &id
  15393. }
  15394. // ID returns the ID value in the mutation. Note that the ID is only available
  15395. // if it was provided to the builder or after it was returned from the database.
  15396. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15397. if m.id == nil {
  15398. return
  15399. }
  15400. return *m.id, true
  15401. }
  15402. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15403. // That means, if the mutation is applied within a transaction with an isolation level such
  15404. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15405. // or updated by the mutation.
  15406. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15407. switch {
  15408. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15409. id, exists := m.ID()
  15410. if exists {
  15411. return []uint64{id}, nil
  15412. }
  15413. fallthrough
  15414. case m.op.Is(OpUpdate | OpDelete):
  15415. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15416. default:
  15417. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15418. }
  15419. }
  15420. // SetCreatedAt sets the "created_at" field.
  15421. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15422. m.created_at = &t
  15423. }
  15424. // CreatedAt returns the value of the "created_at" field in the mutation.
  15425. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15426. v := m.created_at
  15427. if v == nil {
  15428. return
  15429. }
  15430. return *v, true
  15431. }
  15432. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15433. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15435. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15436. if !m.op.Is(OpUpdateOne) {
  15437. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15438. }
  15439. if m.id == nil || m.oldValue == nil {
  15440. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15441. }
  15442. oldValue, err := m.oldValue(ctx)
  15443. if err != nil {
  15444. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15445. }
  15446. return oldValue.CreatedAt, nil
  15447. }
  15448. // ResetCreatedAt resets all changes to the "created_at" field.
  15449. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15450. m.created_at = nil
  15451. }
  15452. // SetUpdatedAt sets the "updated_at" field.
  15453. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15454. m.updated_at = &t
  15455. }
  15456. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15457. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15458. v := m.updated_at
  15459. if v == nil {
  15460. return
  15461. }
  15462. return *v, true
  15463. }
  15464. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15465. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15467. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15468. if !m.op.Is(OpUpdateOne) {
  15469. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15470. }
  15471. if m.id == nil || m.oldValue == nil {
  15472. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15473. }
  15474. oldValue, err := m.oldValue(ctx)
  15475. if err != nil {
  15476. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15477. }
  15478. return oldValue.UpdatedAt, nil
  15479. }
  15480. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15481. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15482. m.updated_at = nil
  15483. }
  15484. // SetStatus sets the "status" field.
  15485. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15486. m.status = &u
  15487. m.addstatus = nil
  15488. }
  15489. // Status returns the value of the "status" field in the mutation.
  15490. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15491. v := m.status
  15492. if v == nil {
  15493. return
  15494. }
  15495. return *v, true
  15496. }
  15497. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15498. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15500. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15501. if !m.op.Is(OpUpdateOne) {
  15502. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15503. }
  15504. if m.id == nil || m.oldValue == nil {
  15505. return v, errors.New("OldStatus requires an ID field in the mutation")
  15506. }
  15507. oldValue, err := m.oldValue(ctx)
  15508. if err != nil {
  15509. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15510. }
  15511. return oldValue.Status, nil
  15512. }
  15513. // AddStatus adds u to the "status" field.
  15514. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15515. if m.addstatus != nil {
  15516. *m.addstatus += u
  15517. } else {
  15518. m.addstatus = &u
  15519. }
  15520. }
  15521. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15522. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15523. v := m.addstatus
  15524. if v == nil {
  15525. return
  15526. }
  15527. return *v, true
  15528. }
  15529. // ClearStatus clears the value of the "status" field.
  15530. func (m *LabelTaggingMutation) ClearStatus() {
  15531. m.status = nil
  15532. m.addstatus = nil
  15533. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15534. }
  15535. // StatusCleared returns if the "status" field was cleared in this mutation.
  15536. func (m *LabelTaggingMutation) StatusCleared() bool {
  15537. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15538. return ok
  15539. }
  15540. // ResetStatus resets all changes to the "status" field.
  15541. func (m *LabelTaggingMutation) ResetStatus() {
  15542. m.status = nil
  15543. m.addstatus = nil
  15544. delete(m.clearedFields, labeltagging.FieldStatus)
  15545. }
  15546. // SetDeletedAt sets the "deleted_at" field.
  15547. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15548. m.deleted_at = &t
  15549. }
  15550. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15551. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15552. v := m.deleted_at
  15553. if v == nil {
  15554. return
  15555. }
  15556. return *v, true
  15557. }
  15558. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15559. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15561. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15562. if !m.op.Is(OpUpdateOne) {
  15563. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15564. }
  15565. if m.id == nil || m.oldValue == nil {
  15566. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15567. }
  15568. oldValue, err := m.oldValue(ctx)
  15569. if err != nil {
  15570. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15571. }
  15572. return oldValue.DeletedAt, nil
  15573. }
  15574. // ClearDeletedAt clears the value of the "deleted_at" field.
  15575. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15576. m.deleted_at = nil
  15577. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15578. }
  15579. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15580. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15581. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15582. return ok
  15583. }
  15584. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15585. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15586. m.deleted_at = nil
  15587. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15588. }
  15589. // SetOrganizationID sets the "organization_id" field.
  15590. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15591. m.organization_id = &u
  15592. m.addorganization_id = nil
  15593. }
  15594. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15595. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15596. v := m.organization_id
  15597. if v == nil {
  15598. return
  15599. }
  15600. return *v, true
  15601. }
  15602. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15603. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15605. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15606. if !m.op.Is(OpUpdateOne) {
  15607. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15608. }
  15609. if m.id == nil || m.oldValue == nil {
  15610. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15611. }
  15612. oldValue, err := m.oldValue(ctx)
  15613. if err != nil {
  15614. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15615. }
  15616. return oldValue.OrganizationID, nil
  15617. }
  15618. // AddOrganizationID adds u to the "organization_id" field.
  15619. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15620. if m.addorganization_id != nil {
  15621. *m.addorganization_id += u
  15622. } else {
  15623. m.addorganization_id = &u
  15624. }
  15625. }
  15626. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15627. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15628. v := m.addorganization_id
  15629. if v == nil {
  15630. return
  15631. }
  15632. return *v, true
  15633. }
  15634. // ResetOrganizationID resets all changes to the "organization_id" field.
  15635. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15636. m.organization_id = nil
  15637. m.addorganization_id = nil
  15638. }
  15639. // SetType sets the "type" field.
  15640. func (m *LabelTaggingMutation) SetType(i int) {
  15641. m._type = &i
  15642. m.add_type = nil
  15643. }
  15644. // GetType returns the value of the "type" field in the mutation.
  15645. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15646. v := m._type
  15647. if v == nil {
  15648. return
  15649. }
  15650. return *v, true
  15651. }
  15652. // OldType returns the old "type" field's value of the LabelTagging entity.
  15653. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15655. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15656. if !m.op.Is(OpUpdateOne) {
  15657. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15658. }
  15659. if m.id == nil || m.oldValue == nil {
  15660. return v, errors.New("OldType requires an ID field in the mutation")
  15661. }
  15662. oldValue, err := m.oldValue(ctx)
  15663. if err != nil {
  15664. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15665. }
  15666. return oldValue.Type, nil
  15667. }
  15668. // AddType adds i to the "type" field.
  15669. func (m *LabelTaggingMutation) AddType(i int) {
  15670. if m.add_type != nil {
  15671. *m.add_type += i
  15672. } else {
  15673. m.add_type = &i
  15674. }
  15675. }
  15676. // AddedType returns the value that was added to the "type" field in this mutation.
  15677. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15678. v := m.add_type
  15679. if v == nil {
  15680. return
  15681. }
  15682. return *v, true
  15683. }
  15684. // ResetType resets all changes to the "type" field.
  15685. func (m *LabelTaggingMutation) ResetType() {
  15686. m._type = nil
  15687. m.add_type = nil
  15688. }
  15689. // SetConditions sets the "conditions" field.
  15690. func (m *LabelTaggingMutation) SetConditions(s string) {
  15691. m.conditions = &s
  15692. }
  15693. // Conditions returns the value of the "conditions" field in the mutation.
  15694. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15695. v := m.conditions
  15696. if v == nil {
  15697. return
  15698. }
  15699. return *v, true
  15700. }
  15701. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15702. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15704. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15705. if !m.op.Is(OpUpdateOne) {
  15706. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15707. }
  15708. if m.id == nil || m.oldValue == nil {
  15709. return v, errors.New("OldConditions requires an ID field in the mutation")
  15710. }
  15711. oldValue, err := m.oldValue(ctx)
  15712. if err != nil {
  15713. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15714. }
  15715. return oldValue.Conditions, nil
  15716. }
  15717. // ResetConditions resets all changes to the "conditions" field.
  15718. func (m *LabelTaggingMutation) ResetConditions() {
  15719. m.conditions = nil
  15720. }
  15721. // SetActionLabelAdd sets the "action_label_add" field.
  15722. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15723. m.action_label_add = &u
  15724. m.appendaction_label_add = nil
  15725. }
  15726. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15727. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15728. v := m.action_label_add
  15729. if v == nil {
  15730. return
  15731. }
  15732. return *v, true
  15733. }
  15734. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15735. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15737. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15738. if !m.op.Is(OpUpdateOne) {
  15739. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15740. }
  15741. if m.id == nil || m.oldValue == nil {
  15742. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15743. }
  15744. oldValue, err := m.oldValue(ctx)
  15745. if err != nil {
  15746. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15747. }
  15748. return oldValue.ActionLabelAdd, nil
  15749. }
  15750. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15751. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15752. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15753. }
  15754. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15755. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15756. if len(m.appendaction_label_add) == 0 {
  15757. return nil, false
  15758. }
  15759. return m.appendaction_label_add, true
  15760. }
  15761. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15762. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15763. m.action_label_add = nil
  15764. m.appendaction_label_add = nil
  15765. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15766. }
  15767. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15768. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15769. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15770. return ok
  15771. }
  15772. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15773. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15774. m.action_label_add = nil
  15775. m.appendaction_label_add = nil
  15776. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15777. }
  15778. // SetActionLabelDel sets the "action_label_del" field.
  15779. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15780. m.action_label_del = &u
  15781. m.appendaction_label_del = nil
  15782. }
  15783. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15784. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15785. v := m.action_label_del
  15786. if v == nil {
  15787. return
  15788. }
  15789. return *v, true
  15790. }
  15791. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15792. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15794. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15795. if !m.op.Is(OpUpdateOne) {
  15796. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15797. }
  15798. if m.id == nil || m.oldValue == nil {
  15799. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15800. }
  15801. oldValue, err := m.oldValue(ctx)
  15802. if err != nil {
  15803. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15804. }
  15805. return oldValue.ActionLabelDel, nil
  15806. }
  15807. // AppendActionLabelDel adds u to the "action_label_del" field.
  15808. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15809. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15810. }
  15811. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15812. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15813. if len(m.appendaction_label_del) == 0 {
  15814. return nil, false
  15815. }
  15816. return m.appendaction_label_del, true
  15817. }
  15818. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15819. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15820. m.action_label_del = nil
  15821. m.appendaction_label_del = nil
  15822. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15823. }
  15824. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15825. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15826. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15827. return ok
  15828. }
  15829. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15830. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15831. m.action_label_del = nil
  15832. m.appendaction_label_del = nil
  15833. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15834. }
  15835. // Where appends a list predicates to the LabelTaggingMutation builder.
  15836. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15837. m.predicates = append(m.predicates, ps...)
  15838. }
  15839. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15840. // users can use type-assertion to append predicates that do not depend on any generated package.
  15841. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15842. p := make([]predicate.LabelTagging, len(ps))
  15843. for i := range ps {
  15844. p[i] = ps[i]
  15845. }
  15846. m.Where(p...)
  15847. }
  15848. // Op returns the operation name.
  15849. func (m *LabelTaggingMutation) Op() Op {
  15850. return m.op
  15851. }
  15852. // SetOp allows setting the mutation operation.
  15853. func (m *LabelTaggingMutation) SetOp(op Op) {
  15854. m.op = op
  15855. }
  15856. // Type returns the node type of this mutation (LabelTagging).
  15857. func (m *LabelTaggingMutation) Type() string {
  15858. return m.typ
  15859. }
  15860. // Fields returns all fields that were changed during this mutation. Note that in
  15861. // order to get all numeric fields that were incremented/decremented, call
  15862. // AddedFields().
  15863. func (m *LabelTaggingMutation) Fields() []string {
  15864. fields := make([]string, 0, 9)
  15865. if m.created_at != nil {
  15866. fields = append(fields, labeltagging.FieldCreatedAt)
  15867. }
  15868. if m.updated_at != nil {
  15869. fields = append(fields, labeltagging.FieldUpdatedAt)
  15870. }
  15871. if m.status != nil {
  15872. fields = append(fields, labeltagging.FieldStatus)
  15873. }
  15874. if m.deleted_at != nil {
  15875. fields = append(fields, labeltagging.FieldDeletedAt)
  15876. }
  15877. if m.organization_id != nil {
  15878. fields = append(fields, labeltagging.FieldOrganizationID)
  15879. }
  15880. if m._type != nil {
  15881. fields = append(fields, labeltagging.FieldType)
  15882. }
  15883. if m.conditions != nil {
  15884. fields = append(fields, labeltagging.FieldConditions)
  15885. }
  15886. if m.action_label_add != nil {
  15887. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15888. }
  15889. if m.action_label_del != nil {
  15890. fields = append(fields, labeltagging.FieldActionLabelDel)
  15891. }
  15892. return fields
  15893. }
  15894. // Field returns the value of a field with the given name. The second boolean
  15895. // return value indicates that this field was not set, or was not defined in the
  15896. // schema.
  15897. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15898. switch name {
  15899. case labeltagging.FieldCreatedAt:
  15900. return m.CreatedAt()
  15901. case labeltagging.FieldUpdatedAt:
  15902. return m.UpdatedAt()
  15903. case labeltagging.FieldStatus:
  15904. return m.Status()
  15905. case labeltagging.FieldDeletedAt:
  15906. return m.DeletedAt()
  15907. case labeltagging.FieldOrganizationID:
  15908. return m.OrganizationID()
  15909. case labeltagging.FieldType:
  15910. return m.GetType()
  15911. case labeltagging.FieldConditions:
  15912. return m.Conditions()
  15913. case labeltagging.FieldActionLabelAdd:
  15914. return m.ActionLabelAdd()
  15915. case labeltagging.FieldActionLabelDel:
  15916. return m.ActionLabelDel()
  15917. }
  15918. return nil, false
  15919. }
  15920. // OldField returns the old value of the field from the database. An error is
  15921. // returned if the mutation operation is not UpdateOne, or the query to the
  15922. // database failed.
  15923. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15924. switch name {
  15925. case labeltagging.FieldCreatedAt:
  15926. return m.OldCreatedAt(ctx)
  15927. case labeltagging.FieldUpdatedAt:
  15928. return m.OldUpdatedAt(ctx)
  15929. case labeltagging.FieldStatus:
  15930. return m.OldStatus(ctx)
  15931. case labeltagging.FieldDeletedAt:
  15932. return m.OldDeletedAt(ctx)
  15933. case labeltagging.FieldOrganizationID:
  15934. return m.OldOrganizationID(ctx)
  15935. case labeltagging.FieldType:
  15936. return m.OldType(ctx)
  15937. case labeltagging.FieldConditions:
  15938. return m.OldConditions(ctx)
  15939. case labeltagging.FieldActionLabelAdd:
  15940. return m.OldActionLabelAdd(ctx)
  15941. case labeltagging.FieldActionLabelDel:
  15942. return m.OldActionLabelDel(ctx)
  15943. }
  15944. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  15945. }
  15946. // SetField sets the value of a field with the given name. It returns an error if
  15947. // the field is not defined in the schema, or if the type mismatched the field
  15948. // type.
  15949. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  15950. switch name {
  15951. case labeltagging.FieldCreatedAt:
  15952. v, ok := value.(time.Time)
  15953. if !ok {
  15954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15955. }
  15956. m.SetCreatedAt(v)
  15957. return nil
  15958. case labeltagging.FieldUpdatedAt:
  15959. v, ok := value.(time.Time)
  15960. if !ok {
  15961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15962. }
  15963. m.SetUpdatedAt(v)
  15964. return nil
  15965. case labeltagging.FieldStatus:
  15966. v, ok := value.(uint8)
  15967. if !ok {
  15968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15969. }
  15970. m.SetStatus(v)
  15971. return nil
  15972. case labeltagging.FieldDeletedAt:
  15973. v, ok := value.(time.Time)
  15974. if !ok {
  15975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15976. }
  15977. m.SetDeletedAt(v)
  15978. return nil
  15979. case labeltagging.FieldOrganizationID:
  15980. v, ok := value.(uint64)
  15981. if !ok {
  15982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15983. }
  15984. m.SetOrganizationID(v)
  15985. return nil
  15986. case labeltagging.FieldType:
  15987. v, ok := value.(int)
  15988. if !ok {
  15989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15990. }
  15991. m.SetType(v)
  15992. return nil
  15993. case labeltagging.FieldConditions:
  15994. v, ok := value.(string)
  15995. if !ok {
  15996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15997. }
  15998. m.SetConditions(v)
  15999. return nil
  16000. case labeltagging.FieldActionLabelAdd:
  16001. v, ok := value.([]uint64)
  16002. if !ok {
  16003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16004. }
  16005. m.SetActionLabelAdd(v)
  16006. return nil
  16007. case labeltagging.FieldActionLabelDel:
  16008. v, ok := value.([]uint64)
  16009. if !ok {
  16010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16011. }
  16012. m.SetActionLabelDel(v)
  16013. return nil
  16014. }
  16015. return fmt.Errorf("unknown LabelTagging field %s", name)
  16016. }
  16017. // AddedFields returns all numeric fields that were incremented/decremented during
  16018. // this mutation.
  16019. func (m *LabelTaggingMutation) AddedFields() []string {
  16020. var fields []string
  16021. if m.addstatus != nil {
  16022. fields = append(fields, labeltagging.FieldStatus)
  16023. }
  16024. if m.addorganization_id != nil {
  16025. fields = append(fields, labeltagging.FieldOrganizationID)
  16026. }
  16027. if m.add_type != nil {
  16028. fields = append(fields, labeltagging.FieldType)
  16029. }
  16030. return fields
  16031. }
  16032. // AddedField returns the numeric value that was incremented/decremented on a field
  16033. // with the given name. The second boolean return value indicates that this field
  16034. // was not set, or was not defined in the schema.
  16035. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16036. switch name {
  16037. case labeltagging.FieldStatus:
  16038. return m.AddedStatus()
  16039. case labeltagging.FieldOrganizationID:
  16040. return m.AddedOrganizationID()
  16041. case labeltagging.FieldType:
  16042. return m.AddedType()
  16043. }
  16044. return nil, false
  16045. }
  16046. // AddField adds the value to the field with the given name. It returns an error if
  16047. // the field is not defined in the schema, or if the type mismatched the field
  16048. // type.
  16049. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16050. switch name {
  16051. case labeltagging.FieldStatus:
  16052. v, ok := value.(int8)
  16053. if !ok {
  16054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16055. }
  16056. m.AddStatus(v)
  16057. return nil
  16058. case labeltagging.FieldOrganizationID:
  16059. v, ok := value.(int64)
  16060. if !ok {
  16061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16062. }
  16063. m.AddOrganizationID(v)
  16064. return nil
  16065. case labeltagging.FieldType:
  16066. v, ok := value.(int)
  16067. if !ok {
  16068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16069. }
  16070. m.AddType(v)
  16071. return nil
  16072. }
  16073. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16074. }
  16075. // ClearedFields returns all nullable fields that were cleared during this
  16076. // mutation.
  16077. func (m *LabelTaggingMutation) ClearedFields() []string {
  16078. var fields []string
  16079. if m.FieldCleared(labeltagging.FieldStatus) {
  16080. fields = append(fields, labeltagging.FieldStatus)
  16081. }
  16082. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16083. fields = append(fields, labeltagging.FieldDeletedAt)
  16084. }
  16085. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16086. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16087. }
  16088. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16089. fields = append(fields, labeltagging.FieldActionLabelDel)
  16090. }
  16091. return fields
  16092. }
  16093. // FieldCleared returns a boolean indicating if a field with the given name was
  16094. // cleared in this mutation.
  16095. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16096. _, ok := m.clearedFields[name]
  16097. return ok
  16098. }
  16099. // ClearField clears the value of the field with the given name. It returns an
  16100. // error if the field is not defined in the schema.
  16101. func (m *LabelTaggingMutation) ClearField(name string) error {
  16102. switch name {
  16103. case labeltagging.FieldStatus:
  16104. m.ClearStatus()
  16105. return nil
  16106. case labeltagging.FieldDeletedAt:
  16107. m.ClearDeletedAt()
  16108. return nil
  16109. case labeltagging.FieldActionLabelAdd:
  16110. m.ClearActionLabelAdd()
  16111. return nil
  16112. case labeltagging.FieldActionLabelDel:
  16113. m.ClearActionLabelDel()
  16114. return nil
  16115. }
  16116. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16117. }
  16118. // ResetField resets all changes in the mutation for the field with the given name.
  16119. // It returns an error if the field is not defined in the schema.
  16120. func (m *LabelTaggingMutation) ResetField(name string) error {
  16121. switch name {
  16122. case labeltagging.FieldCreatedAt:
  16123. m.ResetCreatedAt()
  16124. return nil
  16125. case labeltagging.FieldUpdatedAt:
  16126. m.ResetUpdatedAt()
  16127. return nil
  16128. case labeltagging.FieldStatus:
  16129. m.ResetStatus()
  16130. return nil
  16131. case labeltagging.FieldDeletedAt:
  16132. m.ResetDeletedAt()
  16133. return nil
  16134. case labeltagging.FieldOrganizationID:
  16135. m.ResetOrganizationID()
  16136. return nil
  16137. case labeltagging.FieldType:
  16138. m.ResetType()
  16139. return nil
  16140. case labeltagging.FieldConditions:
  16141. m.ResetConditions()
  16142. return nil
  16143. case labeltagging.FieldActionLabelAdd:
  16144. m.ResetActionLabelAdd()
  16145. return nil
  16146. case labeltagging.FieldActionLabelDel:
  16147. m.ResetActionLabelDel()
  16148. return nil
  16149. }
  16150. return fmt.Errorf("unknown LabelTagging field %s", name)
  16151. }
  16152. // AddedEdges returns all edge names that were set/added in this mutation.
  16153. func (m *LabelTaggingMutation) AddedEdges() []string {
  16154. edges := make([]string, 0, 0)
  16155. return edges
  16156. }
  16157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16158. // name in this mutation.
  16159. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16160. return nil
  16161. }
  16162. // RemovedEdges returns all edge names that were removed in this mutation.
  16163. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16164. edges := make([]string, 0, 0)
  16165. return edges
  16166. }
  16167. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16168. // the given name in this mutation.
  16169. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16170. return nil
  16171. }
  16172. // ClearedEdges returns all edge names that were cleared in this mutation.
  16173. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16174. edges := make([]string, 0, 0)
  16175. return edges
  16176. }
  16177. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16178. // was cleared in this mutation.
  16179. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16180. return false
  16181. }
  16182. // ClearEdge clears the value of the edge with the given name. It returns an error
  16183. // if that edge is not defined in the schema.
  16184. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16185. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16186. }
  16187. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16188. // It returns an error if the edge is not defined in the schema.
  16189. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16190. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16191. }
  16192. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16193. type MessageMutation struct {
  16194. config
  16195. op Op
  16196. typ string
  16197. id *int
  16198. wx_wxid *string
  16199. wxid *string
  16200. content *string
  16201. clearedFields map[string]struct{}
  16202. done bool
  16203. oldValue func(context.Context) (*Message, error)
  16204. predicates []predicate.Message
  16205. }
  16206. var _ ent.Mutation = (*MessageMutation)(nil)
  16207. // messageOption allows management of the mutation configuration using functional options.
  16208. type messageOption func(*MessageMutation)
  16209. // newMessageMutation creates new mutation for the Message entity.
  16210. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16211. m := &MessageMutation{
  16212. config: c,
  16213. op: op,
  16214. typ: TypeMessage,
  16215. clearedFields: make(map[string]struct{}),
  16216. }
  16217. for _, opt := range opts {
  16218. opt(m)
  16219. }
  16220. return m
  16221. }
  16222. // withMessageID sets the ID field of the mutation.
  16223. func withMessageID(id int) messageOption {
  16224. return func(m *MessageMutation) {
  16225. var (
  16226. err error
  16227. once sync.Once
  16228. value *Message
  16229. )
  16230. m.oldValue = func(ctx context.Context) (*Message, error) {
  16231. once.Do(func() {
  16232. if m.done {
  16233. err = errors.New("querying old values post mutation is not allowed")
  16234. } else {
  16235. value, err = m.Client().Message.Get(ctx, id)
  16236. }
  16237. })
  16238. return value, err
  16239. }
  16240. m.id = &id
  16241. }
  16242. }
  16243. // withMessage sets the old Message of the mutation.
  16244. func withMessage(node *Message) messageOption {
  16245. return func(m *MessageMutation) {
  16246. m.oldValue = func(context.Context) (*Message, error) {
  16247. return node, nil
  16248. }
  16249. m.id = &node.ID
  16250. }
  16251. }
  16252. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16253. // executed in a transaction (ent.Tx), a transactional client is returned.
  16254. func (m MessageMutation) Client() *Client {
  16255. client := &Client{config: m.config}
  16256. client.init()
  16257. return client
  16258. }
  16259. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16260. // it returns an error otherwise.
  16261. func (m MessageMutation) Tx() (*Tx, error) {
  16262. if _, ok := m.driver.(*txDriver); !ok {
  16263. return nil, errors.New("ent: mutation is not running in a transaction")
  16264. }
  16265. tx := &Tx{config: m.config}
  16266. tx.init()
  16267. return tx, nil
  16268. }
  16269. // ID returns the ID value in the mutation. Note that the ID is only available
  16270. // if it was provided to the builder or after it was returned from the database.
  16271. func (m *MessageMutation) ID() (id int, exists bool) {
  16272. if m.id == nil {
  16273. return
  16274. }
  16275. return *m.id, true
  16276. }
  16277. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16278. // That means, if the mutation is applied within a transaction with an isolation level such
  16279. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16280. // or updated by the mutation.
  16281. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16282. switch {
  16283. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16284. id, exists := m.ID()
  16285. if exists {
  16286. return []int{id}, nil
  16287. }
  16288. fallthrough
  16289. case m.op.Is(OpUpdate | OpDelete):
  16290. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16291. default:
  16292. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16293. }
  16294. }
  16295. // SetWxWxid sets the "wx_wxid" field.
  16296. func (m *MessageMutation) SetWxWxid(s string) {
  16297. m.wx_wxid = &s
  16298. }
  16299. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16300. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16301. v := m.wx_wxid
  16302. if v == nil {
  16303. return
  16304. }
  16305. return *v, true
  16306. }
  16307. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16308. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16310. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16311. if !m.op.Is(OpUpdateOne) {
  16312. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16313. }
  16314. if m.id == nil || m.oldValue == nil {
  16315. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16316. }
  16317. oldValue, err := m.oldValue(ctx)
  16318. if err != nil {
  16319. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16320. }
  16321. return oldValue.WxWxid, nil
  16322. }
  16323. // ClearWxWxid clears the value of the "wx_wxid" field.
  16324. func (m *MessageMutation) ClearWxWxid() {
  16325. m.wx_wxid = nil
  16326. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16327. }
  16328. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16329. func (m *MessageMutation) WxWxidCleared() bool {
  16330. _, ok := m.clearedFields[message.FieldWxWxid]
  16331. return ok
  16332. }
  16333. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16334. func (m *MessageMutation) ResetWxWxid() {
  16335. m.wx_wxid = nil
  16336. delete(m.clearedFields, message.FieldWxWxid)
  16337. }
  16338. // SetWxid sets the "wxid" field.
  16339. func (m *MessageMutation) SetWxid(s string) {
  16340. m.wxid = &s
  16341. }
  16342. // Wxid returns the value of the "wxid" field in the mutation.
  16343. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16344. v := m.wxid
  16345. if v == nil {
  16346. return
  16347. }
  16348. return *v, true
  16349. }
  16350. // OldWxid returns the old "wxid" field's value of the Message entity.
  16351. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16353. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16354. if !m.op.Is(OpUpdateOne) {
  16355. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16356. }
  16357. if m.id == nil || m.oldValue == nil {
  16358. return v, errors.New("OldWxid requires an ID field in the mutation")
  16359. }
  16360. oldValue, err := m.oldValue(ctx)
  16361. if err != nil {
  16362. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16363. }
  16364. return oldValue.Wxid, nil
  16365. }
  16366. // ResetWxid resets all changes to the "wxid" field.
  16367. func (m *MessageMutation) ResetWxid() {
  16368. m.wxid = nil
  16369. }
  16370. // SetContent sets the "content" field.
  16371. func (m *MessageMutation) SetContent(s string) {
  16372. m.content = &s
  16373. }
  16374. // Content returns the value of the "content" field in the mutation.
  16375. func (m *MessageMutation) Content() (r string, exists bool) {
  16376. v := m.content
  16377. if v == nil {
  16378. return
  16379. }
  16380. return *v, true
  16381. }
  16382. // OldContent returns the old "content" field's value of the Message entity.
  16383. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16385. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16386. if !m.op.Is(OpUpdateOne) {
  16387. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16388. }
  16389. if m.id == nil || m.oldValue == nil {
  16390. return v, errors.New("OldContent requires an ID field in the mutation")
  16391. }
  16392. oldValue, err := m.oldValue(ctx)
  16393. if err != nil {
  16394. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16395. }
  16396. return oldValue.Content, nil
  16397. }
  16398. // ResetContent resets all changes to the "content" field.
  16399. func (m *MessageMutation) ResetContent() {
  16400. m.content = nil
  16401. }
  16402. // Where appends a list predicates to the MessageMutation builder.
  16403. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16404. m.predicates = append(m.predicates, ps...)
  16405. }
  16406. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16407. // users can use type-assertion to append predicates that do not depend on any generated package.
  16408. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16409. p := make([]predicate.Message, len(ps))
  16410. for i := range ps {
  16411. p[i] = ps[i]
  16412. }
  16413. m.Where(p...)
  16414. }
  16415. // Op returns the operation name.
  16416. func (m *MessageMutation) Op() Op {
  16417. return m.op
  16418. }
  16419. // SetOp allows setting the mutation operation.
  16420. func (m *MessageMutation) SetOp(op Op) {
  16421. m.op = op
  16422. }
  16423. // Type returns the node type of this mutation (Message).
  16424. func (m *MessageMutation) Type() string {
  16425. return m.typ
  16426. }
  16427. // Fields returns all fields that were changed during this mutation. Note that in
  16428. // order to get all numeric fields that were incremented/decremented, call
  16429. // AddedFields().
  16430. func (m *MessageMutation) Fields() []string {
  16431. fields := make([]string, 0, 3)
  16432. if m.wx_wxid != nil {
  16433. fields = append(fields, message.FieldWxWxid)
  16434. }
  16435. if m.wxid != nil {
  16436. fields = append(fields, message.FieldWxid)
  16437. }
  16438. if m.content != nil {
  16439. fields = append(fields, message.FieldContent)
  16440. }
  16441. return fields
  16442. }
  16443. // Field returns the value of a field with the given name. The second boolean
  16444. // return value indicates that this field was not set, or was not defined in the
  16445. // schema.
  16446. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16447. switch name {
  16448. case message.FieldWxWxid:
  16449. return m.WxWxid()
  16450. case message.FieldWxid:
  16451. return m.Wxid()
  16452. case message.FieldContent:
  16453. return m.Content()
  16454. }
  16455. return nil, false
  16456. }
  16457. // OldField returns the old value of the field from the database. An error is
  16458. // returned if the mutation operation is not UpdateOne, or the query to the
  16459. // database failed.
  16460. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16461. switch name {
  16462. case message.FieldWxWxid:
  16463. return m.OldWxWxid(ctx)
  16464. case message.FieldWxid:
  16465. return m.OldWxid(ctx)
  16466. case message.FieldContent:
  16467. return m.OldContent(ctx)
  16468. }
  16469. return nil, fmt.Errorf("unknown Message field %s", name)
  16470. }
  16471. // SetField sets the value of a field with the given name. It returns an error if
  16472. // the field is not defined in the schema, or if the type mismatched the field
  16473. // type.
  16474. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16475. switch name {
  16476. case message.FieldWxWxid:
  16477. v, ok := value.(string)
  16478. if !ok {
  16479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16480. }
  16481. m.SetWxWxid(v)
  16482. return nil
  16483. case message.FieldWxid:
  16484. v, ok := value.(string)
  16485. if !ok {
  16486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16487. }
  16488. m.SetWxid(v)
  16489. return nil
  16490. case message.FieldContent:
  16491. v, ok := value.(string)
  16492. if !ok {
  16493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16494. }
  16495. m.SetContent(v)
  16496. return nil
  16497. }
  16498. return fmt.Errorf("unknown Message field %s", name)
  16499. }
  16500. // AddedFields returns all numeric fields that were incremented/decremented during
  16501. // this mutation.
  16502. func (m *MessageMutation) AddedFields() []string {
  16503. return nil
  16504. }
  16505. // AddedField returns the numeric value that was incremented/decremented on a field
  16506. // with the given name. The second boolean return value indicates that this field
  16507. // was not set, or was not defined in the schema.
  16508. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16509. return nil, false
  16510. }
  16511. // AddField adds the value to the field with the given name. It returns an error if
  16512. // the field is not defined in the schema, or if the type mismatched the field
  16513. // type.
  16514. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16515. switch name {
  16516. }
  16517. return fmt.Errorf("unknown Message numeric field %s", name)
  16518. }
  16519. // ClearedFields returns all nullable fields that were cleared during this
  16520. // mutation.
  16521. func (m *MessageMutation) ClearedFields() []string {
  16522. var fields []string
  16523. if m.FieldCleared(message.FieldWxWxid) {
  16524. fields = append(fields, message.FieldWxWxid)
  16525. }
  16526. return fields
  16527. }
  16528. // FieldCleared returns a boolean indicating if a field with the given name was
  16529. // cleared in this mutation.
  16530. func (m *MessageMutation) FieldCleared(name string) bool {
  16531. _, ok := m.clearedFields[name]
  16532. return ok
  16533. }
  16534. // ClearField clears the value of the field with the given name. It returns an
  16535. // error if the field is not defined in the schema.
  16536. func (m *MessageMutation) ClearField(name string) error {
  16537. switch name {
  16538. case message.FieldWxWxid:
  16539. m.ClearWxWxid()
  16540. return nil
  16541. }
  16542. return fmt.Errorf("unknown Message nullable field %s", name)
  16543. }
  16544. // ResetField resets all changes in the mutation for the field with the given name.
  16545. // It returns an error if the field is not defined in the schema.
  16546. func (m *MessageMutation) ResetField(name string) error {
  16547. switch name {
  16548. case message.FieldWxWxid:
  16549. m.ResetWxWxid()
  16550. return nil
  16551. case message.FieldWxid:
  16552. m.ResetWxid()
  16553. return nil
  16554. case message.FieldContent:
  16555. m.ResetContent()
  16556. return nil
  16557. }
  16558. return fmt.Errorf("unknown Message field %s", name)
  16559. }
  16560. // AddedEdges returns all edge names that were set/added in this mutation.
  16561. func (m *MessageMutation) AddedEdges() []string {
  16562. edges := make([]string, 0, 0)
  16563. return edges
  16564. }
  16565. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16566. // name in this mutation.
  16567. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16568. return nil
  16569. }
  16570. // RemovedEdges returns all edge names that were removed in this mutation.
  16571. func (m *MessageMutation) RemovedEdges() []string {
  16572. edges := make([]string, 0, 0)
  16573. return edges
  16574. }
  16575. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16576. // the given name in this mutation.
  16577. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16578. return nil
  16579. }
  16580. // ClearedEdges returns all edge names that were cleared in this mutation.
  16581. func (m *MessageMutation) ClearedEdges() []string {
  16582. edges := make([]string, 0, 0)
  16583. return edges
  16584. }
  16585. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16586. // was cleared in this mutation.
  16587. func (m *MessageMutation) EdgeCleared(name string) bool {
  16588. return false
  16589. }
  16590. // ClearEdge clears the value of the edge with the given name. It returns an error
  16591. // if that edge is not defined in the schema.
  16592. func (m *MessageMutation) ClearEdge(name string) error {
  16593. return fmt.Errorf("unknown Message unique edge %s", name)
  16594. }
  16595. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16596. // It returns an error if the edge is not defined in the schema.
  16597. func (m *MessageMutation) ResetEdge(name string) error {
  16598. return fmt.Errorf("unknown Message edge %s", name)
  16599. }
  16600. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16601. type MessageRecordsMutation struct {
  16602. config
  16603. op Op
  16604. typ string
  16605. id *uint64
  16606. created_at *time.Time
  16607. updated_at *time.Time
  16608. status *uint8
  16609. addstatus *int8
  16610. bot_wxid *string
  16611. contact_type *int
  16612. addcontact_type *int
  16613. contact_wxid *string
  16614. content_type *int
  16615. addcontent_type *int
  16616. content *string
  16617. meta *custom_types.Meta
  16618. error_detail *string
  16619. send_time *time.Time
  16620. source_type *int
  16621. addsource_type *int
  16622. organization_id *uint64
  16623. addorganization_id *int64
  16624. clearedFields map[string]struct{}
  16625. sop_stage *uint64
  16626. clearedsop_stage bool
  16627. sop_node *uint64
  16628. clearedsop_node bool
  16629. message_contact *uint64
  16630. clearedmessage_contact bool
  16631. done bool
  16632. oldValue func(context.Context) (*MessageRecords, error)
  16633. predicates []predicate.MessageRecords
  16634. }
  16635. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16636. // messagerecordsOption allows management of the mutation configuration using functional options.
  16637. type messagerecordsOption func(*MessageRecordsMutation)
  16638. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16639. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16640. m := &MessageRecordsMutation{
  16641. config: c,
  16642. op: op,
  16643. typ: TypeMessageRecords,
  16644. clearedFields: make(map[string]struct{}),
  16645. }
  16646. for _, opt := range opts {
  16647. opt(m)
  16648. }
  16649. return m
  16650. }
  16651. // withMessageRecordsID sets the ID field of the mutation.
  16652. func withMessageRecordsID(id uint64) messagerecordsOption {
  16653. return func(m *MessageRecordsMutation) {
  16654. var (
  16655. err error
  16656. once sync.Once
  16657. value *MessageRecords
  16658. )
  16659. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16660. once.Do(func() {
  16661. if m.done {
  16662. err = errors.New("querying old values post mutation is not allowed")
  16663. } else {
  16664. value, err = m.Client().MessageRecords.Get(ctx, id)
  16665. }
  16666. })
  16667. return value, err
  16668. }
  16669. m.id = &id
  16670. }
  16671. }
  16672. // withMessageRecords sets the old MessageRecords of the mutation.
  16673. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16674. return func(m *MessageRecordsMutation) {
  16675. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16676. return node, nil
  16677. }
  16678. m.id = &node.ID
  16679. }
  16680. }
  16681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16682. // executed in a transaction (ent.Tx), a transactional client is returned.
  16683. func (m MessageRecordsMutation) Client() *Client {
  16684. client := &Client{config: m.config}
  16685. client.init()
  16686. return client
  16687. }
  16688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16689. // it returns an error otherwise.
  16690. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16691. if _, ok := m.driver.(*txDriver); !ok {
  16692. return nil, errors.New("ent: mutation is not running in a transaction")
  16693. }
  16694. tx := &Tx{config: m.config}
  16695. tx.init()
  16696. return tx, nil
  16697. }
  16698. // SetID sets the value of the id field. Note that this
  16699. // operation is only accepted on creation of MessageRecords entities.
  16700. func (m *MessageRecordsMutation) SetID(id uint64) {
  16701. m.id = &id
  16702. }
  16703. // ID returns the ID value in the mutation. Note that the ID is only available
  16704. // if it was provided to the builder or after it was returned from the database.
  16705. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16706. if m.id == nil {
  16707. return
  16708. }
  16709. return *m.id, true
  16710. }
  16711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16712. // That means, if the mutation is applied within a transaction with an isolation level such
  16713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16714. // or updated by the mutation.
  16715. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16716. switch {
  16717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16718. id, exists := m.ID()
  16719. if exists {
  16720. return []uint64{id}, nil
  16721. }
  16722. fallthrough
  16723. case m.op.Is(OpUpdate | OpDelete):
  16724. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16725. default:
  16726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16727. }
  16728. }
  16729. // SetCreatedAt sets the "created_at" field.
  16730. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16731. m.created_at = &t
  16732. }
  16733. // CreatedAt returns the value of the "created_at" field in the mutation.
  16734. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16735. v := m.created_at
  16736. if v == nil {
  16737. return
  16738. }
  16739. return *v, true
  16740. }
  16741. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16742. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16744. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16745. if !m.op.Is(OpUpdateOne) {
  16746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16747. }
  16748. if m.id == nil || m.oldValue == nil {
  16749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16750. }
  16751. oldValue, err := m.oldValue(ctx)
  16752. if err != nil {
  16753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16754. }
  16755. return oldValue.CreatedAt, nil
  16756. }
  16757. // ResetCreatedAt resets all changes to the "created_at" field.
  16758. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16759. m.created_at = nil
  16760. }
  16761. // SetUpdatedAt sets the "updated_at" field.
  16762. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16763. m.updated_at = &t
  16764. }
  16765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16766. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16767. v := m.updated_at
  16768. if v == nil {
  16769. return
  16770. }
  16771. return *v, true
  16772. }
  16773. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16774. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16776. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16777. if !m.op.Is(OpUpdateOne) {
  16778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16779. }
  16780. if m.id == nil || m.oldValue == nil {
  16781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16782. }
  16783. oldValue, err := m.oldValue(ctx)
  16784. if err != nil {
  16785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16786. }
  16787. return oldValue.UpdatedAt, nil
  16788. }
  16789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16790. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16791. m.updated_at = nil
  16792. }
  16793. // SetStatus sets the "status" field.
  16794. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16795. m.status = &u
  16796. m.addstatus = nil
  16797. }
  16798. // Status returns the value of the "status" field in the mutation.
  16799. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16800. v := m.status
  16801. if v == nil {
  16802. return
  16803. }
  16804. return *v, true
  16805. }
  16806. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16807. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16809. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16810. if !m.op.Is(OpUpdateOne) {
  16811. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16812. }
  16813. if m.id == nil || m.oldValue == nil {
  16814. return v, errors.New("OldStatus requires an ID field in the mutation")
  16815. }
  16816. oldValue, err := m.oldValue(ctx)
  16817. if err != nil {
  16818. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16819. }
  16820. return oldValue.Status, nil
  16821. }
  16822. // AddStatus adds u to the "status" field.
  16823. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16824. if m.addstatus != nil {
  16825. *m.addstatus += u
  16826. } else {
  16827. m.addstatus = &u
  16828. }
  16829. }
  16830. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16831. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16832. v := m.addstatus
  16833. if v == nil {
  16834. return
  16835. }
  16836. return *v, true
  16837. }
  16838. // ClearStatus clears the value of the "status" field.
  16839. func (m *MessageRecordsMutation) ClearStatus() {
  16840. m.status = nil
  16841. m.addstatus = nil
  16842. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16843. }
  16844. // StatusCleared returns if the "status" field was cleared in this mutation.
  16845. func (m *MessageRecordsMutation) StatusCleared() bool {
  16846. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16847. return ok
  16848. }
  16849. // ResetStatus resets all changes to the "status" field.
  16850. func (m *MessageRecordsMutation) ResetStatus() {
  16851. m.status = nil
  16852. m.addstatus = nil
  16853. delete(m.clearedFields, messagerecords.FieldStatus)
  16854. }
  16855. // SetBotWxid sets the "bot_wxid" field.
  16856. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16857. m.bot_wxid = &s
  16858. }
  16859. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16860. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16861. v := m.bot_wxid
  16862. if v == nil {
  16863. return
  16864. }
  16865. return *v, true
  16866. }
  16867. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16868. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16870. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16871. if !m.op.Is(OpUpdateOne) {
  16872. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16873. }
  16874. if m.id == nil || m.oldValue == nil {
  16875. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16876. }
  16877. oldValue, err := m.oldValue(ctx)
  16878. if err != nil {
  16879. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16880. }
  16881. return oldValue.BotWxid, nil
  16882. }
  16883. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16884. func (m *MessageRecordsMutation) ResetBotWxid() {
  16885. m.bot_wxid = nil
  16886. }
  16887. // SetContactID sets the "contact_id" field.
  16888. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16889. m.message_contact = &u
  16890. }
  16891. // ContactID returns the value of the "contact_id" field in the mutation.
  16892. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16893. v := m.message_contact
  16894. if v == nil {
  16895. return
  16896. }
  16897. return *v, true
  16898. }
  16899. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16900. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16902. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16903. if !m.op.Is(OpUpdateOne) {
  16904. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16905. }
  16906. if m.id == nil || m.oldValue == nil {
  16907. return v, errors.New("OldContactID requires an ID field in the mutation")
  16908. }
  16909. oldValue, err := m.oldValue(ctx)
  16910. if err != nil {
  16911. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16912. }
  16913. return oldValue.ContactID, nil
  16914. }
  16915. // ClearContactID clears the value of the "contact_id" field.
  16916. func (m *MessageRecordsMutation) ClearContactID() {
  16917. m.message_contact = nil
  16918. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16919. }
  16920. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16921. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16922. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16923. return ok
  16924. }
  16925. // ResetContactID resets all changes to the "contact_id" field.
  16926. func (m *MessageRecordsMutation) ResetContactID() {
  16927. m.message_contact = nil
  16928. delete(m.clearedFields, messagerecords.FieldContactID)
  16929. }
  16930. // SetContactType sets the "contact_type" field.
  16931. func (m *MessageRecordsMutation) SetContactType(i int) {
  16932. m.contact_type = &i
  16933. m.addcontact_type = nil
  16934. }
  16935. // ContactType returns the value of the "contact_type" field in the mutation.
  16936. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  16937. v := m.contact_type
  16938. if v == nil {
  16939. return
  16940. }
  16941. return *v, true
  16942. }
  16943. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  16944. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16946. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  16947. if !m.op.Is(OpUpdateOne) {
  16948. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  16949. }
  16950. if m.id == nil || m.oldValue == nil {
  16951. return v, errors.New("OldContactType requires an ID field in the mutation")
  16952. }
  16953. oldValue, err := m.oldValue(ctx)
  16954. if err != nil {
  16955. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  16956. }
  16957. return oldValue.ContactType, nil
  16958. }
  16959. // AddContactType adds i to the "contact_type" field.
  16960. func (m *MessageRecordsMutation) AddContactType(i int) {
  16961. if m.addcontact_type != nil {
  16962. *m.addcontact_type += i
  16963. } else {
  16964. m.addcontact_type = &i
  16965. }
  16966. }
  16967. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  16968. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  16969. v := m.addcontact_type
  16970. if v == nil {
  16971. return
  16972. }
  16973. return *v, true
  16974. }
  16975. // ResetContactType resets all changes to the "contact_type" field.
  16976. func (m *MessageRecordsMutation) ResetContactType() {
  16977. m.contact_type = nil
  16978. m.addcontact_type = nil
  16979. }
  16980. // SetContactWxid sets the "contact_wxid" field.
  16981. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  16982. m.contact_wxid = &s
  16983. }
  16984. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  16985. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  16986. v := m.contact_wxid
  16987. if v == nil {
  16988. return
  16989. }
  16990. return *v, true
  16991. }
  16992. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  16993. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16995. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  16996. if !m.op.Is(OpUpdateOne) {
  16997. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  16998. }
  16999. if m.id == nil || m.oldValue == nil {
  17000. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17001. }
  17002. oldValue, err := m.oldValue(ctx)
  17003. if err != nil {
  17004. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17005. }
  17006. return oldValue.ContactWxid, nil
  17007. }
  17008. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17009. func (m *MessageRecordsMutation) ResetContactWxid() {
  17010. m.contact_wxid = nil
  17011. }
  17012. // SetContentType sets the "content_type" field.
  17013. func (m *MessageRecordsMutation) SetContentType(i int) {
  17014. m.content_type = &i
  17015. m.addcontent_type = nil
  17016. }
  17017. // ContentType returns the value of the "content_type" field in the mutation.
  17018. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17019. v := m.content_type
  17020. if v == nil {
  17021. return
  17022. }
  17023. return *v, true
  17024. }
  17025. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17026. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17028. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17029. if !m.op.Is(OpUpdateOne) {
  17030. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17031. }
  17032. if m.id == nil || m.oldValue == nil {
  17033. return v, errors.New("OldContentType requires an ID field in the mutation")
  17034. }
  17035. oldValue, err := m.oldValue(ctx)
  17036. if err != nil {
  17037. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17038. }
  17039. return oldValue.ContentType, nil
  17040. }
  17041. // AddContentType adds i to the "content_type" field.
  17042. func (m *MessageRecordsMutation) AddContentType(i int) {
  17043. if m.addcontent_type != nil {
  17044. *m.addcontent_type += i
  17045. } else {
  17046. m.addcontent_type = &i
  17047. }
  17048. }
  17049. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17050. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17051. v := m.addcontent_type
  17052. if v == nil {
  17053. return
  17054. }
  17055. return *v, true
  17056. }
  17057. // ResetContentType resets all changes to the "content_type" field.
  17058. func (m *MessageRecordsMutation) ResetContentType() {
  17059. m.content_type = nil
  17060. m.addcontent_type = nil
  17061. }
  17062. // SetContent sets the "content" field.
  17063. func (m *MessageRecordsMutation) SetContent(s string) {
  17064. m.content = &s
  17065. }
  17066. // Content returns the value of the "content" field in the mutation.
  17067. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17068. v := m.content
  17069. if v == nil {
  17070. return
  17071. }
  17072. return *v, true
  17073. }
  17074. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17075. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17077. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17078. if !m.op.Is(OpUpdateOne) {
  17079. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17080. }
  17081. if m.id == nil || m.oldValue == nil {
  17082. return v, errors.New("OldContent requires an ID field in the mutation")
  17083. }
  17084. oldValue, err := m.oldValue(ctx)
  17085. if err != nil {
  17086. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17087. }
  17088. return oldValue.Content, nil
  17089. }
  17090. // ResetContent resets all changes to the "content" field.
  17091. func (m *MessageRecordsMutation) ResetContent() {
  17092. m.content = nil
  17093. }
  17094. // SetMeta sets the "meta" field.
  17095. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17096. m.meta = &ct
  17097. }
  17098. // Meta returns the value of the "meta" field in the mutation.
  17099. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17100. v := m.meta
  17101. if v == nil {
  17102. return
  17103. }
  17104. return *v, true
  17105. }
  17106. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17107. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17109. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17110. if !m.op.Is(OpUpdateOne) {
  17111. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17112. }
  17113. if m.id == nil || m.oldValue == nil {
  17114. return v, errors.New("OldMeta requires an ID field in the mutation")
  17115. }
  17116. oldValue, err := m.oldValue(ctx)
  17117. if err != nil {
  17118. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17119. }
  17120. return oldValue.Meta, nil
  17121. }
  17122. // ClearMeta clears the value of the "meta" field.
  17123. func (m *MessageRecordsMutation) ClearMeta() {
  17124. m.meta = nil
  17125. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17126. }
  17127. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17128. func (m *MessageRecordsMutation) MetaCleared() bool {
  17129. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17130. return ok
  17131. }
  17132. // ResetMeta resets all changes to the "meta" field.
  17133. func (m *MessageRecordsMutation) ResetMeta() {
  17134. m.meta = nil
  17135. delete(m.clearedFields, messagerecords.FieldMeta)
  17136. }
  17137. // SetErrorDetail sets the "error_detail" field.
  17138. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17139. m.error_detail = &s
  17140. }
  17141. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17142. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17143. v := m.error_detail
  17144. if v == nil {
  17145. return
  17146. }
  17147. return *v, true
  17148. }
  17149. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17150. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17152. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17153. if !m.op.Is(OpUpdateOne) {
  17154. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17155. }
  17156. if m.id == nil || m.oldValue == nil {
  17157. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17158. }
  17159. oldValue, err := m.oldValue(ctx)
  17160. if err != nil {
  17161. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17162. }
  17163. return oldValue.ErrorDetail, nil
  17164. }
  17165. // ResetErrorDetail resets all changes to the "error_detail" field.
  17166. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17167. m.error_detail = nil
  17168. }
  17169. // SetSendTime sets the "send_time" field.
  17170. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17171. m.send_time = &t
  17172. }
  17173. // SendTime returns the value of the "send_time" field in the mutation.
  17174. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17175. v := m.send_time
  17176. if v == nil {
  17177. return
  17178. }
  17179. return *v, true
  17180. }
  17181. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17182. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17184. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17185. if !m.op.Is(OpUpdateOne) {
  17186. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17187. }
  17188. if m.id == nil || m.oldValue == nil {
  17189. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17190. }
  17191. oldValue, err := m.oldValue(ctx)
  17192. if err != nil {
  17193. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17194. }
  17195. return oldValue.SendTime, nil
  17196. }
  17197. // ClearSendTime clears the value of the "send_time" field.
  17198. func (m *MessageRecordsMutation) ClearSendTime() {
  17199. m.send_time = nil
  17200. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17201. }
  17202. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17203. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17204. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17205. return ok
  17206. }
  17207. // ResetSendTime resets all changes to the "send_time" field.
  17208. func (m *MessageRecordsMutation) ResetSendTime() {
  17209. m.send_time = nil
  17210. delete(m.clearedFields, messagerecords.FieldSendTime)
  17211. }
  17212. // SetSourceType sets the "source_type" field.
  17213. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17214. m.source_type = &i
  17215. m.addsource_type = nil
  17216. }
  17217. // SourceType returns the value of the "source_type" field in the mutation.
  17218. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17219. v := m.source_type
  17220. if v == nil {
  17221. return
  17222. }
  17223. return *v, true
  17224. }
  17225. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17226. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17228. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17229. if !m.op.Is(OpUpdateOne) {
  17230. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17231. }
  17232. if m.id == nil || m.oldValue == nil {
  17233. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17234. }
  17235. oldValue, err := m.oldValue(ctx)
  17236. if err != nil {
  17237. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17238. }
  17239. return oldValue.SourceType, nil
  17240. }
  17241. // AddSourceType adds i to the "source_type" field.
  17242. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17243. if m.addsource_type != nil {
  17244. *m.addsource_type += i
  17245. } else {
  17246. m.addsource_type = &i
  17247. }
  17248. }
  17249. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17250. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17251. v := m.addsource_type
  17252. if v == nil {
  17253. return
  17254. }
  17255. return *v, true
  17256. }
  17257. // ResetSourceType resets all changes to the "source_type" field.
  17258. func (m *MessageRecordsMutation) ResetSourceType() {
  17259. m.source_type = nil
  17260. m.addsource_type = nil
  17261. }
  17262. // SetSourceID sets the "source_id" field.
  17263. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17264. m.sop_stage = &u
  17265. }
  17266. // SourceID returns the value of the "source_id" field in the mutation.
  17267. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17268. v := m.sop_stage
  17269. if v == nil {
  17270. return
  17271. }
  17272. return *v, true
  17273. }
  17274. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17275. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17277. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17278. if !m.op.Is(OpUpdateOne) {
  17279. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17280. }
  17281. if m.id == nil || m.oldValue == nil {
  17282. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17283. }
  17284. oldValue, err := m.oldValue(ctx)
  17285. if err != nil {
  17286. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17287. }
  17288. return oldValue.SourceID, nil
  17289. }
  17290. // ClearSourceID clears the value of the "source_id" field.
  17291. func (m *MessageRecordsMutation) ClearSourceID() {
  17292. m.sop_stage = nil
  17293. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17294. }
  17295. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17296. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17297. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17298. return ok
  17299. }
  17300. // ResetSourceID resets all changes to the "source_id" field.
  17301. func (m *MessageRecordsMutation) ResetSourceID() {
  17302. m.sop_stage = nil
  17303. delete(m.clearedFields, messagerecords.FieldSourceID)
  17304. }
  17305. // SetSubSourceID sets the "sub_source_id" field.
  17306. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17307. m.sop_node = &u
  17308. }
  17309. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17310. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17311. v := m.sop_node
  17312. if v == nil {
  17313. return
  17314. }
  17315. return *v, true
  17316. }
  17317. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17318. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17320. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17321. if !m.op.Is(OpUpdateOne) {
  17322. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17323. }
  17324. if m.id == nil || m.oldValue == nil {
  17325. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17326. }
  17327. oldValue, err := m.oldValue(ctx)
  17328. if err != nil {
  17329. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17330. }
  17331. return oldValue.SubSourceID, nil
  17332. }
  17333. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17334. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17335. m.sop_node = nil
  17336. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17337. }
  17338. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17339. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17340. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17341. return ok
  17342. }
  17343. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17344. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17345. m.sop_node = nil
  17346. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17347. }
  17348. // SetOrganizationID sets the "organization_id" field.
  17349. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17350. m.organization_id = &u
  17351. m.addorganization_id = nil
  17352. }
  17353. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17354. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17355. v := m.organization_id
  17356. if v == nil {
  17357. return
  17358. }
  17359. return *v, true
  17360. }
  17361. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17362. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17364. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17365. if !m.op.Is(OpUpdateOne) {
  17366. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17367. }
  17368. if m.id == nil || m.oldValue == nil {
  17369. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17370. }
  17371. oldValue, err := m.oldValue(ctx)
  17372. if err != nil {
  17373. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17374. }
  17375. return oldValue.OrganizationID, nil
  17376. }
  17377. // AddOrganizationID adds u to the "organization_id" field.
  17378. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17379. if m.addorganization_id != nil {
  17380. *m.addorganization_id += u
  17381. } else {
  17382. m.addorganization_id = &u
  17383. }
  17384. }
  17385. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17386. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17387. v := m.addorganization_id
  17388. if v == nil {
  17389. return
  17390. }
  17391. return *v, true
  17392. }
  17393. // ClearOrganizationID clears the value of the "organization_id" field.
  17394. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17395. m.organization_id = nil
  17396. m.addorganization_id = nil
  17397. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17398. }
  17399. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17400. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17401. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17402. return ok
  17403. }
  17404. // ResetOrganizationID resets all changes to the "organization_id" field.
  17405. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17406. m.organization_id = nil
  17407. m.addorganization_id = nil
  17408. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17409. }
  17410. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17411. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17412. m.sop_stage = &id
  17413. }
  17414. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17415. func (m *MessageRecordsMutation) ClearSopStage() {
  17416. m.clearedsop_stage = true
  17417. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17418. }
  17419. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17420. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17421. return m.SourceIDCleared() || m.clearedsop_stage
  17422. }
  17423. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17424. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17425. if m.sop_stage != nil {
  17426. return *m.sop_stage, true
  17427. }
  17428. return
  17429. }
  17430. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17431. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17432. // SopStageID instead. It exists only for internal usage by the builders.
  17433. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17434. if id := m.sop_stage; id != nil {
  17435. ids = append(ids, *id)
  17436. }
  17437. return
  17438. }
  17439. // ResetSopStage resets all changes to the "sop_stage" edge.
  17440. func (m *MessageRecordsMutation) ResetSopStage() {
  17441. m.sop_stage = nil
  17442. m.clearedsop_stage = false
  17443. }
  17444. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17445. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17446. m.sop_node = &id
  17447. }
  17448. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17449. func (m *MessageRecordsMutation) ClearSopNode() {
  17450. m.clearedsop_node = true
  17451. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17452. }
  17453. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17454. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17455. return m.SubSourceIDCleared() || m.clearedsop_node
  17456. }
  17457. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17458. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17459. if m.sop_node != nil {
  17460. return *m.sop_node, true
  17461. }
  17462. return
  17463. }
  17464. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17465. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17466. // SopNodeID instead. It exists only for internal usage by the builders.
  17467. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17468. if id := m.sop_node; id != nil {
  17469. ids = append(ids, *id)
  17470. }
  17471. return
  17472. }
  17473. // ResetSopNode resets all changes to the "sop_node" edge.
  17474. func (m *MessageRecordsMutation) ResetSopNode() {
  17475. m.sop_node = nil
  17476. m.clearedsop_node = false
  17477. }
  17478. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17479. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17480. m.message_contact = &id
  17481. }
  17482. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17483. func (m *MessageRecordsMutation) ClearMessageContact() {
  17484. m.clearedmessage_contact = true
  17485. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17486. }
  17487. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17488. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17489. return m.ContactIDCleared() || m.clearedmessage_contact
  17490. }
  17491. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17492. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17493. if m.message_contact != nil {
  17494. return *m.message_contact, true
  17495. }
  17496. return
  17497. }
  17498. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17499. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17500. // MessageContactID instead. It exists only for internal usage by the builders.
  17501. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17502. if id := m.message_contact; id != nil {
  17503. ids = append(ids, *id)
  17504. }
  17505. return
  17506. }
  17507. // ResetMessageContact resets all changes to the "message_contact" edge.
  17508. func (m *MessageRecordsMutation) ResetMessageContact() {
  17509. m.message_contact = nil
  17510. m.clearedmessage_contact = false
  17511. }
  17512. // Where appends a list predicates to the MessageRecordsMutation builder.
  17513. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17514. m.predicates = append(m.predicates, ps...)
  17515. }
  17516. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17517. // users can use type-assertion to append predicates that do not depend on any generated package.
  17518. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17519. p := make([]predicate.MessageRecords, len(ps))
  17520. for i := range ps {
  17521. p[i] = ps[i]
  17522. }
  17523. m.Where(p...)
  17524. }
  17525. // Op returns the operation name.
  17526. func (m *MessageRecordsMutation) Op() Op {
  17527. return m.op
  17528. }
  17529. // SetOp allows setting the mutation operation.
  17530. func (m *MessageRecordsMutation) SetOp(op Op) {
  17531. m.op = op
  17532. }
  17533. // Type returns the node type of this mutation (MessageRecords).
  17534. func (m *MessageRecordsMutation) Type() string {
  17535. return m.typ
  17536. }
  17537. // Fields returns all fields that were changed during this mutation. Note that in
  17538. // order to get all numeric fields that were incremented/decremented, call
  17539. // AddedFields().
  17540. func (m *MessageRecordsMutation) Fields() []string {
  17541. fields := make([]string, 0, 16)
  17542. if m.created_at != nil {
  17543. fields = append(fields, messagerecords.FieldCreatedAt)
  17544. }
  17545. if m.updated_at != nil {
  17546. fields = append(fields, messagerecords.FieldUpdatedAt)
  17547. }
  17548. if m.status != nil {
  17549. fields = append(fields, messagerecords.FieldStatus)
  17550. }
  17551. if m.bot_wxid != nil {
  17552. fields = append(fields, messagerecords.FieldBotWxid)
  17553. }
  17554. if m.message_contact != nil {
  17555. fields = append(fields, messagerecords.FieldContactID)
  17556. }
  17557. if m.contact_type != nil {
  17558. fields = append(fields, messagerecords.FieldContactType)
  17559. }
  17560. if m.contact_wxid != nil {
  17561. fields = append(fields, messagerecords.FieldContactWxid)
  17562. }
  17563. if m.content_type != nil {
  17564. fields = append(fields, messagerecords.FieldContentType)
  17565. }
  17566. if m.content != nil {
  17567. fields = append(fields, messagerecords.FieldContent)
  17568. }
  17569. if m.meta != nil {
  17570. fields = append(fields, messagerecords.FieldMeta)
  17571. }
  17572. if m.error_detail != nil {
  17573. fields = append(fields, messagerecords.FieldErrorDetail)
  17574. }
  17575. if m.send_time != nil {
  17576. fields = append(fields, messagerecords.FieldSendTime)
  17577. }
  17578. if m.source_type != nil {
  17579. fields = append(fields, messagerecords.FieldSourceType)
  17580. }
  17581. if m.sop_stage != nil {
  17582. fields = append(fields, messagerecords.FieldSourceID)
  17583. }
  17584. if m.sop_node != nil {
  17585. fields = append(fields, messagerecords.FieldSubSourceID)
  17586. }
  17587. if m.organization_id != nil {
  17588. fields = append(fields, messagerecords.FieldOrganizationID)
  17589. }
  17590. return fields
  17591. }
  17592. // Field returns the value of a field with the given name. The second boolean
  17593. // return value indicates that this field was not set, or was not defined in the
  17594. // schema.
  17595. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17596. switch name {
  17597. case messagerecords.FieldCreatedAt:
  17598. return m.CreatedAt()
  17599. case messagerecords.FieldUpdatedAt:
  17600. return m.UpdatedAt()
  17601. case messagerecords.FieldStatus:
  17602. return m.Status()
  17603. case messagerecords.FieldBotWxid:
  17604. return m.BotWxid()
  17605. case messagerecords.FieldContactID:
  17606. return m.ContactID()
  17607. case messagerecords.FieldContactType:
  17608. return m.ContactType()
  17609. case messagerecords.FieldContactWxid:
  17610. return m.ContactWxid()
  17611. case messagerecords.FieldContentType:
  17612. return m.ContentType()
  17613. case messagerecords.FieldContent:
  17614. return m.Content()
  17615. case messagerecords.FieldMeta:
  17616. return m.Meta()
  17617. case messagerecords.FieldErrorDetail:
  17618. return m.ErrorDetail()
  17619. case messagerecords.FieldSendTime:
  17620. return m.SendTime()
  17621. case messagerecords.FieldSourceType:
  17622. return m.SourceType()
  17623. case messagerecords.FieldSourceID:
  17624. return m.SourceID()
  17625. case messagerecords.FieldSubSourceID:
  17626. return m.SubSourceID()
  17627. case messagerecords.FieldOrganizationID:
  17628. return m.OrganizationID()
  17629. }
  17630. return nil, false
  17631. }
  17632. // OldField returns the old value of the field from the database. An error is
  17633. // returned if the mutation operation is not UpdateOne, or the query to the
  17634. // database failed.
  17635. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17636. switch name {
  17637. case messagerecords.FieldCreatedAt:
  17638. return m.OldCreatedAt(ctx)
  17639. case messagerecords.FieldUpdatedAt:
  17640. return m.OldUpdatedAt(ctx)
  17641. case messagerecords.FieldStatus:
  17642. return m.OldStatus(ctx)
  17643. case messagerecords.FieldBotWxid:
  17644. return m.OldBotWxid(ctx)
  17645. case messagerecords.FieldContactID:
  17646. return m.OldContactID(ctx)
  17647. case messagerecords.FieldContactType:
  17648. return m.OldContactType(ctx)
  17649. case messagerecords.FieldContactWxid:
  17650. return m.OldContactWxid(ctx)
  17651. case messagerecords.FieldContentType:
  17652. return m.OldContentType(ctx)
  17653. case messagerecords.FieldContent:
  17654. return m.OldContent(ctx)
  17655. case messagerecords.FieldMeta:
  17656. return m.OldMeta(ctx)
  17657. case messagerecords.FieldErrorDetail:
  17658. return m.OldErrorDetail(ctx)
  17659. case messagerecords.FieldSendTime:
  17660. return m.OldSendTime(ctx)
  17661. case messagerecords.FieldSourceType:
  17662. return m.OldSourceType(ctx)
  17663. case messagerecords.FieldSourceID:
  17664. return m.OldSourceID(ctx)
  17665. case messagerecords.FieldSubSourceID:
  17666. return m.OldSubSourceID(ctx)
  17667. case messagerecords.FieldOrganizationID:
  17668. return m.OldOrganizationID(ctx)
  17669. }
  17670. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17671. }
  17672. // SetField sets the value of a field with the given name. It returns an error if
  17673. // the field is not defined in the schema, or if the type mismatched the field
  17674. // type.
  17675. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17676. switch name {
  17677. case messagerecords.FieldCreatedAt:
  17678. v, ok := value.(time.Time)
  17679. if !ok {
  17680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17681. }
  17682. m.SetCreatedAt(v)
  17683. return nil
  17684. case messagerecords.FieldUpdatedAt:
  17685. v, ok := value.(time.Time)
  17686. if !ok {
  17687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17688. }
  17689. m.SetUpdatedAt(v)
  17690. return nil
  17691. case messagerecords.FieldStatus:
  17692. v, ok := value.(uint8)
  17693. if !ok {
  17694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17695. }
  17696. m.SetStatus(v)
  17697. return nil
  17698. case messagerecords.FieldBotWxid:
  17699. v, ok := value.(string)
  17700. if !ok {
  17701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17702. }
  17703. m.SetBotWxid(v)
  17704. return nil
  17705. case messagerecords.FieldContactID:
  17706. v, ok := value.(uint64)
  17707. if !ok {
  17708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17709. }
  17710. m.SetContactID(v)
  17711. return nil
  17712. case messagerecords.FieldContactType:
  17713. v, ok := value.(int)
  17714. if !ok {
  17715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17716. }
  17717. m.SetContactType(v)
  17718. return nil
  17719. case messagerecords.FieldContactWxid:
  17720. v, ok := value.(string)
  17721. if !ok {
  17722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17723. }
  17724. m.SetContactWxid(v)
  17725. return nil
  17726. case messagerecords.FieldContentType:
  17727. v, ok := value.(int)
  17728. if !ok {
  17729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17730. }
  17731. m.SetContentType(v)
  17732. return nil
  17733. case messagerecords.FieldContent:
  17734. v, ok := value.(string)
  17735. if !ok {
  17736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17737. }
  17738. m.SetContent(v)
  17739. return nil
  17740. case messagerecords.FieldMeta:
  17741. v, ok := value.(custom_types.Meta)
  17742. if !ok {
  17743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17744. }
  17745. m.SetMeta(v)
  17746. return nil
  17747. case messagerecords.FieldErrorDetail:
  17748. v, ok := value.(string)
  17749. if !ok {
  17750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17751. }
  17752. m.SetErrorDetail(v)
  17753. return nil
  17754. case messagerecords.FieldSendTime:
  17755. v, ok := value.(time.Time)
  17756. if !ok {
  17757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17758. }
  17759. m.SetSendTime(v)
  17760. return nil
  17761. case messagerecords.FieldSourceType:
  17762. v, ok := value.(int)
  17763. if !ok {
  17764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17765. }
  17766. m.SetSourceType(v)
  17767. return nil
  17768. case messagerecords.FieldSourceID:
  17769. v, ok := value.(uint64)
  17770. if !ok {
  17771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17772. }
  17773. m.SetSourceID(v)
  17774. return nil
  17775. case messagerecords.FieldSubSourceID:
  17776. v, ok := value.(uint64)
  17777. if !ok {
  17778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17779. }
  17780. m.SetSubSourceID(v)
  17781. return nil
  17782. case messagerecords.FieldOrganizationID:
  17783. v, ok := value.(uint64)
  17784. if !ok {
  17785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17786. }
  17787. m.SetOrganizationID(v)
  17788. return nil
  17789. }
  17790. return fmt.Errorf("unknown MessageRecords field %s", name)
  17791. }
  17792. // AddedFields returns all numeric fields that were incremented/decremented during
  17793. // this mutation.
  17794. func (m *MessageRecordsMutation) AddedFields() []string {
  17795. var fields []string
  17796. if m.addstatus != nil {
  17797. fields = append(fields, messagerecords.FieldStatus)
  17798. }
  17799. if m.addcontact_type != nil {
  17800. fields = append(fields, messagerecords.FieldContactType)
  17801. }
  17802. if m.addcontent_type != nil {
  17803. fields = append(fields, messagerecords.FieldContentType)
  17804. }
  17805. if m.addsource_type != nil {
  17806. fields = append(fields, messagerecords.FieldSourceType)
  17807. }
  17808. if m.addorganization_id != nil {
  17809. fields = append(fields, messagerecords.FieldOrganizationID)
  17810. }
  17811. return fields
  17812. }
  17813. // AddedField returns the numeric value that was incremented/decremented on a field
  17814. // with the given name. The second boolean return value indicates that this field
  17815. // was not set, or was not defined in the schema.
  17816. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17817. switch name {
  17818. case messagerecords.FieldStatus:
  17819. return m.AddedStatus()
  17820. case messagerecords.FieldContactType:
  17821. return m.AddedContactType()
  17822. case messagerecords.FieldContentType:
  17823. return m.AddedContentType()
  17824. case messagerecords.FieldSourceType:
  17825. return m.AddedSourceType()
  17826. case messagerecords.FieldOrganizationID:
  17827. return m.AddedOrganizationID()
  17828. }
  17829. return nil, false
  17830. }
  17831. // AddField adds the value to the field with the given name. It returns an error if
  17832. // the field is not defined in the schema, or if the type mismatched the field
  17833. // type.
  17834. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17835. switch name {
  17836. case messagerecords.FieldStatus:
  17837. v, ok := value.(int8)
  17838. if !ok {
  17839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17840. }
  17841. m.AddStatus(v)
  17842. return nil
  17843. case messagerecords.FieldContactType:
  17844. v, ok := value.(int)
  17845. if !ok {
  17846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17847. }
  17848. m.AddContactType(v)
  17849. return nil
  17850. case messagerecords.FieldContentType:
  17851. v, ok := value.(int)
  17852. if !ok {
  17853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17854. }
  17855. m.AddContentType(v)
  17856. return nil
  17857. case messagerecords.FieldSourceType:
  17858. v, ok := value.(int)
  17859. if !ok {
  17860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17861. }
  17862. m.AddSourceType(v)
  17863. return nil
  17864. case messagerecords.FieldOrganizationID:
  17865. v, ok := value.(int64)
  17866. if !ok {
  17867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17868. }
  17869. m.AddOrganizationID(v)
  17870. return nil
  17871. }
  17872. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17873. }
  17874. // ClearedFields returns all nullable fields that were cleared during this
  17875. // mutation.
  17876. func (m *MessageRecordsMutation) ClearedFields() []string {
  17877. var fields []string
  17878. if m.FieldCleared(messagerecords.FieldStatus) {
  17879. fields = append(fields, messagerecords.FieldStatus)
  17880. }
  17881. if m.FieldCleared(messagerecords.FieldContactID) {
  17882. fields = append(fields, messagerecords.FieldContactID)
  17883. }
  17884. if m.FieldCleared(messagerecords.FieldMeta) {
  17885. fields = append(fields, messagerecords.FieldMeta)
  17886. }
  17887. if m.FieldCleared(messagerecords.FieldSendTime) {
  17888. fields = append(fields, messagerecords.FieldSendTime)
  17889. }
  17890. if m.FieldCleared(messagerecords.FieldSourceID) {
  17891. fields = append(fields, messagerecords.FieldSourceID)
  17892. }
  17893. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17894. fields = append(fields, messagerecords.FieldSubSourceID)
  17895. }
  17896. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17897. fields = append(fields, messagerecords.FieldOrganizationID)
  17898. }
  17899. return fields
  17900. }
  17901. // FieldCleared returns a boolean indicating if a field with the given name was
  17902. // cleared in this mutation.
  17903. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17904. _, ok := m.clearedFields[name]
  17905. return ok
  17906. }
  17907. // ClearField clears the value of the field with the given name. It returns an
  17908. // error if the field is not defined in the schema.
  17909. func (m *MessageRecordsMutation) ClearField(name string) error {
  17910. switch name {
  17911. case messagerecords.FieldStatus:
  17912. m.ClearStatus()
  17913. return nil
  17914. case messagerecords.FieldContactID:
  17915. m.ClearContactID()
  17916. return nil
  17917. case messagerecords.FieldMeta:
  17918. m.ClearMeta()
  17919. return nil
  17920. case messagerecords.FieldSendTime:
  17921. m.ClearSendTime()
  17922. return nil
  17923. case messagerecords.FieldSourceID:
  17924. m.ClearSourceID()
  17925. return nil
  17926. case messagerecords.FieldSubSourceID:
  17927. m.ClearSubSourceID()
  17928. return nil
  17929. case messagerecords.FieldOrganizationID:
  17930. m.ClearOrganizationID()
  17931. return nil
  17932. }
  17933. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17934. }
  17935. // ResetField resets all changes in the mutation for the field with the given name.
  17936. // It returns an error if the field is not defined in the schema.
  17937. func (m *MessageRecordsMutation) ResetField(name string) error {
  17938. switch name {
  17939. case messagerecords.FieldCreatedAt:
  17940. m.ResetCreatedAt()
  17941. return nil
  17942. case messagerecords.FieldUpdatedAt:
  17943. m.ResetUpdatedAt()
  17944. return nil
  17945. case messagerecords.FieldStatus:
  17946. m.ResetStatus()
  17947. return nil
  17948. case messagerecords.FieldBotWxid:
  17949. m.ResetBotWxid()
  17950. return nil
  17951. case messagerecords.FieldContactID:
  17952. m.ResetContactID()
  17953. return nil
  17954. case messagerecords.FieldContactType:
  17955. m.ResetContactType()
  17956. return nil
  17957. case messagerecords.FieldContactWxid:
  17958. m.ResetContactWxid()
  17959. return nil
  17960. case messagerecords.FieldContentType:
  17961. m.ResetContentType()
  17962. return nil
  17963. case messagerecords.FieldContent:
  17964. m.ResetContent()
  17965. return nil
  17966. case messagerecords.FieldMeta:
  17967. m.ResetMeta()
  17968. return nil
  17969. case messagerecords.FieldErrorDetail:
  17970. m.ResetErrorDetail()
  17971. return nil
  17972. case messagerecords.FieldSendTime:
  17973. m.ResetSendTime()
  17974. return nil
  17975. case messagerecords.FieldSourceType:
  17976. m.ResetSourceType()
  17977. return nil
  17978. case messagerecords.FieldSourceID:
  17979. m.ResetSourceID()
  17980. return nil
  17981. case messagerecords.FieldSubSourceID:
  17982. m.ResetSubSourceID()
  17983. return nil
  17984. case messagerecords.FieldOrganizationID:
  17985. m.ResetOrganizationID()
  17986. return nil
  17987. }
  17988. return fmt.Errorf("unknown MessageRecords field %s", name)
  17989. }
  17990. // AddedEdges returns all edge names that were set/added in this mutation.
  17991. func (m *MessageRecordsMutation) AddedEdges() []string {
  17992. edges := make([]string, 0, 3)
  17993. if m.sop_stage != nil {
  17994. edges = append(edges, messagerecords.EdgeSopStage)
  17995. }
  17996. if m.sop_node != nil {
  17997. edges = append(edges, messagerecords.EdgeSopNode)
  17998. }
  17999. if m.message_contact != nil {
  18000. edges = append(edges, messagerecords.EdgeMessageContact)
  18001. }
  18002. return edges
  18003. }
  18004. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18005. // name in this mutation.
  18006. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18007. switch name {
  18008. case messagerecords.EdgeSopStage:
  18009. if id := m.sop_stage; id != nil {
  18010. return []ent.Value{*id}
  18011. }
  18012. case messagerecords.EdgeSopNode:
  18013. if id := m.sop_node; id != nil {
  18014. return []ent.Value{*id}
  18015. }
  18016. case messagerecords.EdgeMessageContact:
  18017. if id := m.message_contact; id != nil {
  18018. return []ent.Value{*id}
  18019. }
  18020. }
  18021. return nil
  18022. }
  18023. // RemovedEdges returns all edge names that were removed in this mutation.
  18024. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18025. edges := make([]string, 0, 3)
  18026. return edges
  18027. }
  18028. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18029. // the given name in this mutation.
  18030. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18031. return nil
  18032. }
  18033. // ClearedEdges returns all edge names that were cleared in this mutation.
  18034. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18035. edges := make([]string, 0, 3)
  18036. if m.clearedsop_stage {
  18037. edges = append(edges, messagerecords.EdgeSopStage)
  18038. }
  18039. if m.clearedsop_node {
  18040. edges = append(edges, messagerecords.EdgeSopNode)
  18041. }
  18042. if m.clearedmessage_contact {
  18043. edges = append(edges, messagerecords.EdgeMessageContact)
  18044. }
  18045. return edges
  18046. }
  18047. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18048. // was cleared in this mutation.
  18049. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18050. switch name {
  18051. case messagerecords.EdgeSopStage:
  18052. return m.clearedsop_stage
  18053. case messagerecords.EdgeSopNode:
  18054. return m.clearedsop_node
  18055. case messagerecords.EdgeMessageContact:
  18056. return m.clearedmessage_contact
  18057. }
  18058. return false
  18059. }
  18060. // ClearEdge clears the value of the edge with the given name. It returns an error
  18061. // if that edge is not defined in the schema.
  18062. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18063. switch name {
  18064. case messagerecords.EdgeSopStage:
  18065. m.ClearSopStage()
  18066. return nil
  18067. case messagerecords.EdgeSopNode:
  18068. m.ClearSopNode()
  18069. return nil
  18070. case messagerecords.EdgeMessageContact:
  18071. m.ClearMessageContact()
  18072. return nil
  18073. }
  18074. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18075. }
  18076. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18077. // It returns an error if the edge is not defined in the schema.
  18078. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18079. switch name {
  18080. case messagerecords.EdgeSopStage:
  18081. m.ResetSopStage()
  18082. return nil
  18083. case messagerecords.EdgeSopNode:
  18084. m.ResetSopNode()
  18085. return nil
  18086. case messagerecords.EdgeMessageContact:
  18087. m.ResetMessageContact()
  18088. return nil
  18089. }
  18090. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18091. }
  18092. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18093. type MsgMutation struct {
  18094. config
  18095. op Op
  18096. typ string
  18097. id *uint64
  18098. created_at *time.Time
  18099. updated_at *time.Time
  18100. deleted_at *time.Time
  18101. status *uint8
  18102. addstatus *int8
  18103. fromwxid *string
  18104. toid *string
  18105. msgtype *int32
  18106. addmsgtype *int32
  18107. msg *string
  18108. batch_no *string
  18109. clearedFields map[string]struct{}
  18110. done bool
  18111. oldValue func(context.Context) (*Msg, error)
  18112. predicates []predicate.Msg
  18113. }
  18114. var _ ent.Mutation = (*MsgMutation)(nil)
  18115. // msgOption allows management of the mutation configuration using functional options.
  18116. type msgOption func(*MsgMutation)
  18117. // newMsgMutation creates new mutation for the Msg entity.
  18118. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18119. m := &MsgMutation{
  18120. config: c,
  18121. op: op,
  18122. typ: TypeMsg,
  18123. clearedFields: make(map[string]struct{}),
  18124. }
  18125. for _, opt := range opts {
  18126. opt(m)
  18127. }
  18128. return m
  18129. }
  18130. // withMsgID sets the ID field of the mutation.
  18131. func withMsgID(id uint64) msgOption {
  18132. return func(m *MsgMutation) {
  18133. var (
  18134. err error
  18135. once sync.Once
  18136. value *Msg
  18137. )
  18138. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18139. once.Do(func() {
  18140. if m.done {
  18141. err = errors.New("querying old values post mutation is not allowed")
  18142. } else {
  18143. value, err = m.Client().Msg.Get(ctx, id)
  18144. }
  18145. })
  18146. return value, err
  18147. }
  18148. m.id = &id
  18149. }
  18150. }
  18151. // withMsg sets the old Msg of the mutation.
  18152. func withMsg(node *Msg) msgOption {
  18153. return func(m *MsgMutation) {
  18154. m.oldValue = func(context.Context) (*Msg, error) {
  18155. return node, nil
  18156. }
  18157. m.id = &node.ID
  18158. }
  18159. }
  18160. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18161. // executed in a transaction (ent.Tx), a transactional client is returned.
  18162. func (m MsgMutation) Client() *Client {
  18163. client := &Client{config: m.config}
  18164. client.init()
  18165. return client
  18166. }
  18167. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18168. // it returns an error otherwise.
  18169. func (m MsgMutation) Tx() (*Tx, error) {
  18170. if _, ok := m.driver.(*txDriver); !ok {
  18171. return nil, errors.New("ent: mutation is not running in a transaction")
  18172. }
  18173. tx := &Tx{config: m.config}
  18174. tx.init()
  18175. return tx, nil
  18176. }
  18177. // SetID sets the value of the id field. Note that this
  18178. // operation is only accepted on creation of Msg entities.
  18179. func (m *MsgMutation) SetID(id uint64) {
  18180. m.id = &id
  18181. }
  18182. // ID returns the ID value in the mutation. Note that the ID is only available
  18183. // if it was provided to the builder or after it was returned from the database.
  18184. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18185. if m.id == nil {
  18186. return
  18187. }
  18188. return *m.id, true
  18189. }
  18190. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18191. // That means, if the mutation is applied within a transaction with an isolation level such
  18192. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18193. // or updated by the mutation.
  18194. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18195. switch {
  18196. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18197. id, exists := m.ID()
  18198. if exists {
  18199. return []uint64{id}, nil
  18200. }
  18201. fallthrough
  18202. case m.op.Is(OpUpdate | OpDelete):
  18203. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18204. default:
  18205. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18206. }
  18207. }
  18208. // SetCreatedAt sets the "created_at" field.
  18209. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18210. m.created_at = &t
  18211. }
  18212. // CreatedAt returns the value of the "created_at" field in the mutation.
  18213. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18214. v := m.created_at
  18215. if v == nil {
  18216. return
  18217. }
  18218. return *v, true
  18219. }
  18220. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18221. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18223. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18224. if !m.op.Is(OpUpdateOne) {
  18225. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18226. }
  18227. if m.id == nil || m.oldValue == nil {
  18228. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18229. }
  18230. oldValue, err := m.oldValue(ctx)
  18231. if err != nil {
  18232. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18233. }
  18234. return oldValue.CreatedAt, nil
  18235. }
  18236. // ResetCreatedAt resets all changes to the "created_at" field.
  18237. func (m *MsgMutation) ResetCreatedAt() {
  18238. m.created_at = nil
  18239. }
  18240. // SetUpdatedAt sets the "updated_at" field.
  18241. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18242. m.updated_at = &t
  18243. }
  18244. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18245. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18246. v := m.updated_at
  18247. if v == nil {
  18248. return
  18249. }
  18250. return *v, true
  18251. }
  18252. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18253. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18255. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18256. if !m.op.Is(OpUpdateOne) {
  18257. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18258. }
  18259. if m.id == nil || m.oldValue == nil {
  18260. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18261. }
  18262. oldValue, err := m.oldValue(ctx)
  18263. if err != nil {
  18264. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18265. }
  18266. return oldValue.UpdatedAt, nil
  18267. }
  18268. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18269. func (m *MsgMutation) ResetUpdatedAt() {
  18270. m.updated_at = nil
  18271. }
  18272. // SetDeletedAt sets the "deleted_at" field.
  18273. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18274. m.deleted_at = &t
  18275. }
  18276. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18277. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18278. v := m.deleted_at
  18279. if v == nil {
  18280. return
  18281. }
  18282. return *v, true
  18283. }
  18284. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18285. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18287. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18288. if !m.op.Is(OpUpdateOne) {
  18289. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18290. }
  18291. if m.id == nil || m.oldValue == nil {
  18292. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18293. }
  18294. oldValue, err := m.oldValue(ctx)
  18295. if err != nil {
  18296. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18297. }
  18298. return oldValue.DeletedAt, nil
  18299. }
  18300. // ClearDeletedAt clears the value of the "deleted_at" field.
  18301. func (m *MsgMutation) ClearDeletedAt() {
  18302. m.deleted_at = nil
  18303. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18304. }
  18305. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18306. func (m *MsgMutation) DeletedAtCleared() bool {
  18307. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18308. return ok
  18309. }
  18310. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18311. func (m *MsgMutation) ResetDeletedAt() {
  18312. m.deleted_at = nil
  18313. delete(m.clearedFields, msg.FieldDeletedAt)
  18314. }
  18315. // SetStatus sets the "status" field.
  18316. func (m *MsgMutation) SetStatus(u uint8) {
  18317. m.status = &u
  18318. m.addstatus = nil
  18319. }
  18320. // Status returns the value of the "status" field in the mutation.
  18321. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18322. v := m.status
  18323. if v == nil {
  18324. return
  18325. }
  18326. return *v, true
  18327. }
  18328. // OldStatus returns the old "status" field's value of the Msg entity.
  18329. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18331. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18332. if !m.op.Is(OpUpdateOne) {
  18333. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18334. }
  18335. if m.id == nil || m.oldValue == nil {
  18336. return v, errors.New("OldStatus requires an ID field in the mutation")
  18337. }
  18338. oldValue, err := m.oldValue(ctx)
  18339. if err != nil {
  18340. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18341. }
  18342. return oldValue.Status, nil
  18343. }
  18344. // AddStatus adds u to the "status" field.
  18345. func (m *MsgMutation) AddStatus(u int8) {
  18346. if m.addstatus != nil {
  18347. *m.addstatus += u
  18348. } else {
  18349. m.addstatus = &u
  18350. }
  18351. }
  18352. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18353. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18354. v := m.addstatus
  18355. if v == nil {
  18356. return
  18357. }
  18358. return *v, true
  18359. }
  18360. // ClearStatus clears the value of the "status" field.
  18361. func (m *MsgMutation) ClearStatus() {
  18362. m.status = nil
  18363. m.addstatus = nil
  18364. m.clearedFields[msg.FieldStatus] = struct{}{}
  18365. }
  18366. // StatusCleared returns if the "status" field was cleared in this mutation.
  18367. func (m *MsgMutation) StatusCleared() bool {
  18368. _, ok := m.clearedFields[msg.FieldStatus]
  18369. return ok
  18370. }
  18371. // ResetStatus resets all changes to the "status" field.
  18372. func (m *MsgMutation) ResetStatus() {
  18373. m.status = nil
  18374. m.addstatus = nil
  18375. delete(m.clearedFields, msg.FieldStatus)
  18376. }
  18377. // SetFromwxid sets the "fromwxid" field.
  18378. func (m *MsgMutation) SetFromwxid(s string) {
  18379. m.fromwxid = &s
  18380. }
  18381. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18382. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18383. v := m.fromwxid
  18384. if v == nil {
  18385. return
  18386. }
  18387. return *v, true
  18388. }
  18389. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18390. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18392. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18393. if !m.op.Is(OpUpdateOne) {
  18394. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18395. }
  18396. if m.id == nil || m.oldValue == nil {
  18397. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18398. }
  18399. oldValue, err := m.oldValue(ctx)
  18400. if err != nil {
  18401. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18402. }
  18403. return oldValue.Fromwxid, nil
  18404. }
  18405. // ClearFromwxid clears the value of the "fromwxid" field.
  18406. func (m *MsgMutation) ClearFromwxid() {
  18407. m.fromwxid = nil
  18408. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18409. }
  18410. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18411. func (m *MsgMutation) FromwxidCleared() bool {
  18412. _, ok := m.clearedFields[msg.FieldFromwxid]
  18413. return ok
  18414. }
  18415. // ResetFromwxid resets all changes to the "fromwxid" field.
  18416. func (m *MsgMutation) ResetFromwxid() {
  18417. m.fromwxid = nil
  18418. delete(m.clearedFields, msg.FieldFromwxid)
  18419. }
  18420. // SetToid sets the "toid" field.
  18421. func (m *MsgMutation) SetToid(s string) {
  18422. m.toid = &s
  18423. }
  18424. // Toid returns the value of the "toid" field in the mutation.
  18425. func (m *MsgMutation) Toid() (r string, exists bool) {
  18426. v := m.toid
  18427. if v == nil {
  18428. return
  18429. }
  18430. return *v, true
  18431. }
  18432. // OldToid returns the old "toid" field's value of the Msg entity.
  18433. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18435. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18436. if !m.op.Is(OpUpdateOne) {
  18437. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18438. }
  18439. if m.id == nil || m.oldValue == nil {
  18440. return v, errors.New("OldToid requires an ID field in the mutation")
  18441. }
  18442. oldValue, err := m.oldValue(ctx)
  18443. if err != nil {
  18444. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18445. }
  18446. return oldValue.Toid, nil
  18447. }
  18448. // ClearToid clears the value of the "toid" field.
  18449. func (m *MsgMutation) ClearToid() {
  18450. m.toid = nil
  18451. m.clearedFields[msg.FieldToid] = struct{}{}
  18452. }
  18453. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18454. func (m *MsgMutation) ToidCleared() bool {
  18455. _, ok := m.clearedFields[msg.FieldToid]
  18456. return ok
  18457. }
  18458. // ResetToid resets all changes to the "toid" field.
  18459. func (m *MsgMutation) ResetToid() {
  18460. m.toid = nil
  18461. delete(m.clearedFields, msg.FieldToid)
  18462. }
  18463. // SetMsgtype sets the "msgtype" field.
  18464. func (m *MsgMutation) SetMsgtype(i int32) {
  18465. m.msgtype = &i
  18466. m.addmsgtype = nil
  18467. }
  18468. // Msgtype returns the value of the "msgtype" field in the mutation.
  18469. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18470. v := m.msgtype
  18471. if v == nil {
  18472. return
  18473. }
  18474. return *v, true
  18475. }
  18476. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18477. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18479. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18480. if !m.op.Is(OpUpdateOne) {
  18481. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18482. }
  18483. if m.id == nil || m.oldValue == nil {
  18484. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18485. }
  18486. oldValue, err := m.oldValue(ctx)
  18487. if err != nil {
  18488. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18489. }
  18490. return oldValue.Msgtype, nil
  18491. }
  18492. // AddMsgtype adds i to the "msgtype" field.
  18493. func (m *MsgMutation) AddMsgtype(i int32) {
  18494. if m.addmsgtype != nil {
  18495. *m.addmsgtype += i
  18496. } else {
  18497. m.addmsgtype = &i
  18498. }
  18499. }
  18500. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18501. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18502. v := m.addmsgtype
  18503. if v == nil {
  18504. return
  18505. }
  18506. return *v, true
  18507. }
  18508. // ClearMsgtype clears the value of the "msgtype" field.
  18509. func (m *MsgMutation) ClearMsgtype() {
  18510. m.msgtype = nil
  18511. m.addmsgtype = nil
  18512. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18513. }
  18514. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18515. func (m *MsgMutation) MsgtypeCleared() bool {
  18516. _, ok := m.clearedFields[msg.FieldMsgtype]
  18517. return ok
  18518. }
  18519. // ResetMsgtype resets all changes to the "msgtype" field.
  18520. func (m *MsgMutation) ResetMsgtype() {
  18521. m.msgtype = nil
  18522. m.addmsgtype = nil
  18523. delete(m.clearedFields, msg.FieldMsgtype)
  18524. }
  18525. // SetMsg sets the "msg" field.
  18526. func (m *MsgMutation) SetMsg(s string) {
  18527. m.msg = &s
  18528. }
  18529. // Msg returns the value of the "msg" field in the mutation.
  18530. func (m *MsgMutation) Msg() (r string, exists bool) {
  18531. v := m.msg
  18532. if v == nil {
  18533. return
  18534. }
  18535. return *v, true
  18536. }
  18537. // OldMsg returns the old "msg" field's value of the Msg entity.
  18538. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18540. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18541. if !m.op.Is(OpUpdateOne) {
  18542. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18543. }
  18544. if m.id == nil || m.oldValue == nil {
  18545. return v, errors.New("OldMsg requires an ID field in the mutation")
  18546. }
  18547. oldValue, err := m.oldValue(ctx)
  18548. if err != nil {
  18549. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18550. }
  18551. return oldValue.Msg, nil
  18552. }
  18553. // ClearMsg clears the value of the "msg" field.
  18554. func (m *MsgMutation) ClearMsg() {
  18555. m.msg = nil
  18556. m.clearedFields[msg.FieldMsg] = struct{}{}
  18557. }
  18558. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18559. func (m *MsgMutation) MsgCleared() bool {
  18560. _, ok := m.clearedFields[msg.FieldMsg]
  18561. return ok
  18562. }
  18563. // ResetMsg resets all changes to the "msg" field.
  18564. func (m *MsgMutation) ResetMsg() {
  18565. m.msg = nil
  18566. delete(m.clearedFields, msg.FieldMsg)
  18567. }
  18568. // SetBatchNo sets the "batch_no" field.
  18569. func (m *MsgMutation) SetBatchNo(s string) {
  18570. m.batch_no = &s
  18571. }
  18572. // BatchNo returns the value of the "batch_no" field in the mutation.
  18573. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18574. v := m.batch_no
  18575. if v == nil {
  18576. return
  18577. }
  18578. return *v, true
  18579. }
  18580. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18581. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18583. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18584. if !m.op.Is(OpUpdateOne) {
  18585. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18586. }
  18587. if m.id == nil || m.oldValue == nil {
  18588. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18589. }
  18590. oldValue, err := m.oldValue(ctx)
  18591. if err != nil {
  18592. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18593. }
  18594. return oldValue.BatchNo, nil
  18595. }
  18596. // ClearBatchNo clears the value of the "batch_no" field.
  18597. func (m *MsgMutation) ClearBatchNo() {
  18598. m.batch_no = nil
  18599. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18600. }
  18601. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18602. func (m *MsgMutation) BatchNoCleared() bool {
  18603. _, ok := m.clearedFields[msg.FieldBatchNo]
  18604. return ok
  18605. }
  18606. // ResetBatchNo resets all changes to the "batch_no" field.
  18607. func (m *MsgMutation) ResetBatchNo() {
  18608. m.batch_no = nil
  18609. delete(m.clearedFields, msg.FieldBatchNo)
  18610. }
  18611. // Where appends a list predicates to the MsgMutation builder.
  18612. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18613. m.predicates = append(m.predicates, ps...)
  18614. }
  18615. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18616. // users can use type-assertion to append predicates that do not depend on any generated package.
  18617. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18618. p := make([]predicate.Msg, len(ps))
  18619. for i := range ps {
  18620. p[i] = ps[i]
  18621. }
  18622. m.Where(p...)
  18623. }
  18624. // Op returns the operation name.
  18625. func (m *MsgMutation) Op() Op {
  18626. return m.op
  18627. }
  18628. // SetOp allows setting the mutation operation.
  18629. func (m *MsgMutation) SetOp(op Op) {
  18630. m.op = op
  18631. }
  18632. // Type returns the node type of this mutation (Msg).
  18633. func (m *MsgMutation) Type() string {
  18634. return m.typ
  18635. }
  18636. // Fields returns all fields that were changed during this mutation. Note that in
  18637. // order to get all numeric fields that were incremented/decremented, call
  18638. // AddedFields().
  18639. func (m *MsgMutation) Fields() []string {
  18640. fields := make([]string, 0, 9)
  18641. if m.created_at != nil {
  18642. fields = append(fields, msg.FieldCreatedAt)
  18643. }
  18644. if m.updated_at != nil {
  18645. fields = append(fields, msg.FieldUpdatedAt)
  18646. }
  18647. if m.deleted_at != nil {
  18648. fields = append(fields, msg.FieldDeletedAt)
  18649. }
  18650. if m.status != nil {
  18651. fields = append(fields, msg.FieldStatus)
  18652. }
  18653. if m.fromwxid != nil {
  18654. fields = append(fields, msg.FieldFromwxid)
  18655. }
  18656. if m.toid != nil {
  18657. fields = append(fields, msg.FieldToid)
  18658. }
  18659. if m.msgtype != nil {
  18660. fields = append(fields, msg.FieldMsgtype)
  18661. }
  18662. if m.msg != nil {
  18663. fields = append(fields, msg.FieldMsg)
  18664. }
  18665. if m.batch_no != nil {
  18666. fields = append(fields, msg.FieldBatchNo)
  18667. }
  18668. return fields
  18669. }
  18670. // Field returns the value of a field with the given name. The second boolean
  18671. // return value indicates that this field was not set, or was not defined in the
  18672. // schema.
  18673. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18674. switch name {
  18675. case msg.FieldCreatedAt:
  18676. return m.CreatedAt()
  18677. case msg.FieldUpdatedAt:
  18678. return m.UpdatedAt()
  18679. case msg.FieldDeletedAt:
  18680. return m.DeletedAt()
  18681. case msg.FieldStatus:
  18682. return m.Status()
  18683. case msg.FieldFromwxid:
  18684. return m.Fromwxid()
  18685. case msg.FieldToid:
  18686. return m.Toid()
  18687. case msg.FieldMsgtype:
  18688. return m.Msgtype()
  18689. case msg.FieldMsg:
  18690. return m.Msg()
  18691. case msg.FieldBatchNo:
  18692. return m.BatchNo()
  18693. }
  18694. return nil, false
  18695. }
  18696. // OldField returns the old value of the field from the database. An error is
  18697. // returned if the mutation operation is not UpdateOne, or the query to the
  18698. // database failed.
  18699. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18700. switch name {
  18701. case msg.FieldCreatedAt:
  18702. return m.OldCreatedAt(ctx)
  18703. case msg.FieldUpdatedAt:
  18704. return m.OldUpdatedAt(ctx)
  18705. case msg.FieldDeletedAt:
  18706. return m.OldDeletedAt(ctx)
  18707. case msg.FieldStatus:
  18708. return m.OldStatus(ctx)
  18709. case msg.FieldFromwxid:
  18710. return m.OldFromwxid(ctx)
  18711. case msg.FieldToid:
  18712. return m.OldToid(ctx)
  18713. case msg.FieldMsgtype:
  18714. return m.OldMsgtype(ctx)
  18715. case msg.FieldMsg:
  18716. return m.OldMsg(ctx)
  18717. case msg.FieldBatchNo:
  18718. return m.OldBatchNo(ctx)
  18719. }
  18720. return nil, fmt.Errorf("unknown Msg field %s", name)
  18721. }
  18722. // SetField sets the value of a field with the given name. It returns an error if
  18723. // the field is not defined in the schema, or if the type mismatched the field
  18724. // type.
  18725. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18726. switch name {
  18727. case msg.FieldCreatedAt:
  18728. v, ok := value.(time.Time)
  18729. if !ok {
  18730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18731. }
  18732. m.SetCreatedAt(v)
  18733. return nil
  18734. case msg.FieldUpdatedAt:
  18735. v, ok := value.(time.Time)
  18736. if !ok {
  18737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18738. }
  18739. m.SetUpdatedAt(v)
  18740. return nil
  18741. case msg.FieldDeletedAt:
  18742. v, ok := value.(time.Time)
  18743. if !ok {
  18744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18745. }
  18746. m.SetDeletedAt(v)
  18747. return nil
  18748. case msg.FieldStatus:
  18749. v, ok := value.(uint8)
  18750. if !ok {
  18751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18752. }
  18753. m.SetStatus(v)
  18754. return nil
  18755. case msg.FieldFromwxid:
  18756. v, ok := value.(string)
  18757. if !ok {
  18758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18759. }
  18760. m.SetFromwxid(v)
  18761. return nil
  18762. case msg.FieldToid:
  18763. v, ok := value.(string)
  18764. if !ok {
  18765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18766. }
  18767. m.SetToid(v)
  18768. return nil
  18769. case msg.FieldMsgtype:
  18770. v, ok := value.(int32)
  18771. if !ok {
  18772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18773. }
  18774. m.SetMsgtype(v)
  18775. return nil
  18776. case msg.FieldMsg:
  18777. v, ok := value.(string)
  18778. if !ok {
  18779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18780. }
  18781. m.SetMsg(v)
  18782. return nil
  18783. case msg.FieldBatchNo:
  18784. v, ok := value.(string)
  18785. if !ok {
  18786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18787. }
  18788. m.SetBatchNo(v)
  18789. return nil
  18790. }
  18791. return fmt.Errorf("unknown Msg field %s", name)
  18792. }
  18793. // AddedFields returns all numeric fields that were incremented/decremented during
  18794. // this mutation.
  18795. func (m *MsgMutation) AddedFields() []string {
  18796. var fields []string
  18797. if m.addstatus != nil {
  18798. fields = append(fields, msg.FieldStatus)
  18799. }
  18800. if m.addmsgtype != nil {
  18801. fields = append(fields, msg.FieldMsgtype)
  18802. }
  18803. return fields
  18804. }
  18805. // AddedField returns the numeric value that was incremented/decremented on a field
  18806. // with the given name. The second boolean return value indicates that this field
  18807. // was not set, or was not defined in the schema.
  18808. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18809. switch name {
  18810. case msg.FieldStatus:
  18811. return m.AddedStatus()
  18812. case msg.FieldMsgtype:
  18813. return m.AddedMsgtype()
  18814. }
  18815. return nil, false
  18816. }
  18817. // AddField adds the value to the field with the given name. It returns an error if
  18818. // the field is not defined in the schema, or if the type mismatched the field
  18819. // type.
  18820. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18821. switch name {
  18822. case msg.FieldStatus:
  18823. v, ok := value.(int8)
  18824. if !ok {
  18825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18826. }
  18827. m.AddStatus(v)
  18828. return nil
  18829. case msg.FieldMsgtype:
  18830. v, ok := value.(int32)
  18831. if !ok {
  18832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18833. }
  18834. m.AddMsgtype(v)
  18835. return nil
  18836. }
  18837. return fmt.Errorf("unknown Msg numeric field %s", name)
  18838. }
  18839. // ClearedFields returns all nullable fields that were cleared during this
  18840. // mutation.
  18841. func (m *MsgMutation) ClearedFields() []string {
  18842. var fields []string
  18843. if m.FieldCleared(msg.FieldDeletedAt) {
  18844. fields = append(fields, msg.FieldDeletedAt)
  18845. }
  18846. if m.FieldCleared(msg.FieldStatus) {
  18847. fields = append(fields, msg.FieldStatus)
  18848. }
  18849. if m.FieldCleared(msg.FieldFromwxid) {
  18850. fields = append(fields, msg.FieldFromwxid)
  18851. }
  18852. if m.FieldCleared(msg.FieldToid) {
  18853. fields = append(fields, msg.FieldToid)
  18854. }
  18855. if m.FieldCleared(msg.FieldMsgtype) {
  18856. fields = append(fields, msg.FieldMsgtype)
  18857. }
  18858. if m.FieldCleared(msg.FieldMsg) {
  18859. fields = append(fields, msg.FieldMsg)
  18860. }
  18861. if m.FieldCleared(msg.FieldBatchNo) {
  18862. fields = append(fields, msg.FieldBatchNo)
  18863. }
  18864. return fields
  18865. }
  18866. // FieldCleared returns a boolean indicating if a field with the given name was
  18867. // cleared in this mutation.
  18868. func (m *MsgMutation) FieldCleared(name string) bool {
  18869. _, ok := m.clearedFields[name]
  18870. return ok
  18871. }
  18872. // ClearField clears the value of the field with the given name. It returns an
  18873. // error if the field is not defined in the schema.
  18874. func (m *MsgMutation) ClearField(name string) error {
  18875. switch name {
  18876. case msg.FieldDeletedAt:
  18877. m.ClearDeletedAt()
  18878. return nil
  18879. case msg.FieldStatus:
  18880. m.ClearStatus()
  18881. return nil
  18882. case msg.FieldFromwxid:
  18883. m.ClearFromwxid()
  18884. return nil
  18885. case msg.FieldToid:
  18886. m.ClearToid()
  18887. return nil
  18888. case msg.FieldMsgtype:
  18889. m.ClearMsgtype()
  18890. return nil
  18891. case msg.FieldMsg:
  18892. m.ClearMsg()
  18893. return nil
  18894. case msg.FieldBatchNo:
  18895. m.ClearBatchNo()
  18896. return nil
  18897. }
  18898. return fmt.Errorf("unknown Msg nullable field %s", name)
  18899. }
  18900. // ResetField resets all changes in the mutation for the field with the given name.
  18901. // It returns an error if the field is not defined in the schema.
  18902. func (m *MsgMutation) ResetField(name string) error {
  18903. switch name {
  18904. case msg.FieldCreatedAt:
  18905. m.ResetCreatedAt()
  18906. return nil
  18907. case msg.FieldUpdatedAt:
  18908. m.ResetUpdatedAt()
  18909. return nil
  18910. case msg.FieldDeletedAt:
  18911. m.ResetDeletedAt()
  18912. return nil
  18913. case msg.FieldStatus:
  18914. m.ResetStatus()
  18915. return nil
  18916. case msg.FieldFromwxid:
  18917. m.ResetFromwxid()
  18918. return nil
  18919. case msg.FieldToid:
  18920. m.ResetToid()
  18921. return nil
  18922. case msg.FieldMsgtype:
  18923. m.ResetMsgtype()
  18924. return nil
  18925. case msg.FieldMsg:
  18926. m.ResetMsg()
  18927. return nil
  18928. case msg.FieldBatchNo:
  18929. m.ResetBatchNo()
  18930. return nil
  18931. }
  18932. return fmt.Errorf("unknown Msg field %s", name)
  18933. }
  18934. // AddedEdges returns all edge names that were set/added in this mutation.
  18935. func (m *MsgMutation) AddedEdges() []string {
  18936. edges := make([]string, 0, 0)
  18937. return edges
  18938. }
  18939. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18940. // name in this mutation.
  18941. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  18942. return nil
  18943. }
  18944. // RemovedEdges returns all edge names that were removed in this mutation.
  18945. func (m *MsgMutation) RemovedEdges() []string {
  18946. edges := make([]string, 0, 0)
  18947. return edges
  18948. }
  18949. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18950. // the given name in this mutation.
  18951. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  18952. return nil
  18953. }
  18954. // ClearedEdges returns all edge names that were cleared in this mutation.
  18955. func (m *MsgMutation) ClearedEdges() []string {
  18956. edges := make([]string, 0, 0)
  18957. return edges
  18958. }
  18959. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18960. // was cleared in this mutation.
  18961. func (m *MsgMutation) EdgeCleared(name string) bool {
  18962. return false
  18963. }
  18964. // ClearEdge clears the value of the edge with the given name. It returns an error
  18965. // if that edge is not defined in the schema.
  18966. func (m *MsgMutation) ClearEdge(name string) error {
  18967. return fmt.Errorf("unknown Msg unique edge %s", name)
  18968. }
  18969. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18970. // It returns an error if the edge is not defined in the schema.
  18971. func (m *MsgMutation) ResetEdge(name string) error {
  18972. return fmt.Errorf("unknown Msg edge %s", name)
  18973. }
  18974. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  18975. type PayRechargeMutation struct {
  18976. config
  18977. op Op
  18978. typ string
  18979. id *uint64
  18980. created_at *time.Time
  18981. updated_at *time.Time
  18982. deleted_at *time.Time
  18983. user_id *string
  18984. number *float32
  18985. addnumber *float32
  18986. status *int
  18987. addstatus *int
  18988. money *float32
  18989. addmoney *float32
  18990. out_trade_no *string
  18991. organization_id *uint64
  18992. addorganization_id *int64
  18993. clearedFields map[string]struct{}
  18994. done bool
  18995. oldValue func(context.Context) (*PayRecharge, error)
  18996. predicates []predicate.PayRecharge
  18997. }
  18998. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  18999. // payrechargeOption allows management of the mutation configuration using functional options.
  19000. type payrechargeOption func(*PayRechargeMutation)
  19001. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19002. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19003. m := &PayRechargeMutation{
  19004. config: c,
  19005. op: op,
  19006. typ: TypePayRecharge,
  19007. clearedFields: make(map[string]struct{}),
  19008. }
  19009. for _, opt := range opts {
  19010. opt(m)
  19011. }
  19012. return m
  19013. }
  19014. // withPayRechargeID sets the ID field of the mutation.
  19015. func withPayRechargeID(id uint64) payrechargeOption {
  19016. return func(m *PayRechargeMutation) {
  19017. var (
  19018. err error
  19019. once sync.Once
  19020. value *PayRecharge
  19021. )
  19022. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19023. once.Do(func() {
  19024. if m.done {
  19025. err = errors.New("querying old values post mutation is not allowed")
  19026. } else {
  19027. value, err = m.Client().PayRecharge.Get(ctx, id)
  19028. }
  19029. })
  19030. return value, err
  19031. }
  19032. m.id = &id
  19033. }
  19034. }
  19035. // withPayRecharge sets the old PayRecharge of the mutation.
  19036. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19037. return func(m *PayRechargeMutation) {
  19038. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19039. return node, nil
  19040. }
  19041. m.id = &node.ID
  19042. }
  19043. }
  19044. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19045. // executed in a transaction (ent.Tx), a transactional client is returned.
  19046. func (m PayRechargeMutation) Client() *Client {
  19047. client := &Client{config: m.config}
  19048. client.init()
  19049. return client
  19050. }
  19051. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19052. // it returns an error otherwise.
  19053. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19054. if _, ok := m.driver.(*txDriver); !ok {
  19055. return nil, errors.New("ent: mutation is not running in a transaction")
  19056. }
  19057. tx := &Tx{config: m.config}
  19058. tx.init()
  19059. return tx, nil
  19060. }
  19061. // SetID sets the value of the id field. Note that this
  19062. // operation is only accepted on creation of PayRecharge entities.
  19063. func (m *PayRechargeMutation) SetID(id uint64) {
  19064. m.id = &id
  19065. }
  19066. // ID returns the ID value in the mutation. Note that the ID is only available
  19067. // if it was provided to the builder or after it was returned from the database.
  19068. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19069. if m.id == nil {
  19070. return
  19071. }
  19072. return *m.id, true
  19073. }
  19074. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19075. // That means, if the mutation is applied within a transaction with an isolation level such
  19076. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19077. // or updated by the mutation.
  19078. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19079. switch {
  19080. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19081. id, exists := m.ID()
  19082. if exists {
  19083. return []uint64{id}, nil
  19084. }
  19085. fallthrough
  19086. case m.op.Is(OpUpdate | OpDelete):
  19087. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19088. default:
  19089. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19090. }
  19091. }
  19092. // SetCreatedAt sets the "created_at" field.
  19093. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19094. m.created_at = &t
  19095. }
  19096. // CreatedAt returns the value of the "created_at" field in the mutation.
  19097. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19098. v := m.created_at
  19099. if v == nil {
  19100. return
  19101. }
  19102. return *v, true
  19103. }
  19104. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19105. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19107. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19108. if !m.op.Is(OpUpdateOne) {
  19109. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19110. }
  19111. if m.id == nil || m.oldValue == nil {
  19112. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19113. }
  19114. oldValue, err := m.oldValue(ctx)
  19115. if err != nil {
  19116. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19117. }
  19118. return oldValue.CreatedAt, nil
  19119. }
  19120. // ResetCreatedAt resets all changes to the "created_at" field.
  19121. func (m *PayRechargeMutation) ResetCreatedAt() {
  19122. m.created_at = nil
  19123. }
  19124. // SetUpdatedAt sets the "updated_at" field.
  19125. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19126. m.updated_at = &t
  19127. }
  19128. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19129. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19130. v := m.updated_at
  19131. if v == nil {
  19132. return
  19133. }
  19134. return *v, true
  19135. }
  19136. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19137. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19139. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19140. if !m.op.Is(OpUpdateOne) {
  19141. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19142. }
  19143. if m.id == nil || m.oldValue == nil {
  19144. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19145. }
  19146. oldValue, err := m.oldValue(ctx)
  19147. if err != nil {
  19148. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19149. }
  19150. return oldValue.UpdatedAt, nil
  19151. }
  19152. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19153. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19154. m.updated_at = nil
  19155. }
  19156. // SetDeletedAt sets the "deleted_at" field.
  19157. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19158. m.deleted_at = &t
  19159. }
  19160. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19161. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19162. v := m.deleted_at
  19163. if v == nil {
  19164. return
  19165. }
  19166. return *v, true
  19167. }
  19168. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19169. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19171. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19172. if !m.op.Is(OpUpdateOne) {
  19173. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19174. }
  19175. if m.id == nil || m.oldValue == nil {
  19176. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19177. }
  19178. oldValue, err := m.oldValue(ctx)
  19179. if err != nil {
  19180. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19181. }
  19182. return oldValue.DeletedAt, nil
  19183. }
  19184. // ClearDeletedAt clears the value of the "deleted_at" field.
  19185. func (m *PayRechargeMutation) ClearDeletedAt() {
  19186. m.deleted_at = nil
  19187. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19188. }
  19189. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19190. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19191. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19192. return ok
  19193. }
  19194. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19195. func (m *PayRechargeMutation) ResetDeletedAt() {
  19196. m.deleted_at = nil
  19197. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19198. }
  19199. // SetUserID sets the "user_id" field.
  19200. func (m *PayRechargeMutation) SetUserID(s string) {
  19201. m.user_id = &s
  19202. }
  19203. // UserID returns the value of the "user_id" field in the mutation.
  19204. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19205. v := m.user_id
  19206. if v == nil {
  19207. return
  19208. }
  19209. return *v, true
  19210. }
  19211. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19212. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19214. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19215. if !m.op.Is(OpUpdateOne) {
  19216. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19217. }
  19218. if m.id == nil || m.oldValue == nil {
  19219. return v, errors.New("OldUserID requires an ID field in the mutation")
  19220. }
  19221. oldValue, err := m.oldValue(ctx)
  19222. if err != nil {
  19223. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19224. }
  19225. return oldValue.UserID, nil
  19226. }
  19227. // ResetUserID resets all changes to the "user_id" field.
  19228. func (m *PayRechargeMutation) ResetUserID() {
  19229. m.user_id = nil
  19230. }
  19231. // SetNumber sets the "number" field.
  19232. func (m *PayRechargeMutation) SetNumber(f float32) {
  19233. m.number = &f
  19234. m.addnumber = nil
  19235. }
  19236. // Number returns the value of the "number" field in the mutation.
  19237. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19238. v := m.number
  19239. if v == nil {
  19240. return
  19241. }
  19242. return *v, true
  19243. }
  19244. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19245. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19247. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19248. if !m.op.Is(OpUpdateOne) {
  19249. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19250. }
  19251. if m.id == nil || m.oldValue == nil {
  19252. return v, errors.New("OldNumber requires an ID field in the mutation")
  19253. }
  19254. oldValue, err := m.oldValue(ctx)
  19255. if err != nil {
  19256. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19257. }
  19258. return oldValue.Number, nil
  19259. }
  19260. // AddNumber adds f to the "number" field.
  19261. func (m *PayRechargeMutation) AddNumber(f float32) {
  19262. if m.addnumber != nil {
  19263. *m.addnumber += f
  19264. } else {
  19265. m.addnumber = &f
  19266. }
  19267. }
  19268. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19269. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19270. v := m.addnumber
  19271. if v == nil {
  19272. return
  19273. }
  19274. return *v, true
  19275. }
  19276. // ResetNumber resets all changes to the "number" field.
  19277. func (m *PayRechargeMutation) ResetNumber() {
  19278. m.number = nil
  19279. m.addnumber = nil
  19280. }
  19281. // SetStatus sets the "status" field.
  19282. func (m *PayRechargeMutation) SetStatus(i int) {
  19283. m.status = &i
  19284. m.addstatus = nil
  19285. }
  19286. // Status returns the value of the "status" field in the mutation.
  19287. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19288. v := m.status
  19289. if v == nil {
  19290. return
  19291. }
  19292. return *v, true
  19293. }
  19294. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19295. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19297. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19298. if !m.op.Is(OpUpdateOne) {
  19299. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19300. }
  19301. if m.id == nil || m.oldValue == nil {
  19302. return v, errors.New("OldStatus requires an ID field in the mutation")
  19303. }
  19304. oldValue, err := m.oldValue(ctx)
  19305. if err != nil {
  19306. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19307. }
  19308. return oldValue.Status, nil
  19309. }
  19310. // AddStatus adds i to the "status" field.
  19311. func (m *PayRechargeMutation) AddStatus(i int) {
  19312. if m.addstatus != nil {
  19313. *m.addstatus += i
  19314. } else {
  19315. m.addstatus = &i
  19316. }
  19317. }
  19318. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19319. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19320. v := m.addstatus
  19321. if v == nil {
  19322. return
  19323. }
  19324. return *v, true
  19325. }
  19326. // ClearStatus clears the value of the "status" field.
  19327. func (m *PayRechargeMutation) ClearStatus() {
  19328. m.status = nil
  19329. m.addstatus = nil
  19330. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19331. }
  19332. // StatusCleared returns if the "status" field was cleared in this mutation.
  19333. func (m *PayRechargeMutation) StatusCleared() bool {
  19334. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19335. return ok
  19336. }
  19337. // ResetStatus resets all changes to the "status" field.
  19338. func (m *PayRechargeMutation) ResetStatus() {
  19339. m.status = nil
  19340. m.addstatus = nil
  19341. delete(m.clearedFields, payrecharge.FieldStatus)
  19342. }
  19343. // SetMoney sets the "money" field.
  19344. func (m *PayRechargeMutation) SetMoney(f float32) {
  19345. m.money = &f
  19346. m.addmoney = nil
  19347. }
  19348. // Money returns the value of the "money" field in the mutation.
  19349. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19350. v := m.money
  19351. if v == nil {
  19352. return
  19353. }
  19354. return *v, true
  19355. }
  19356. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19357. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19359. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19360. if !m.op.Is(OpUpdateOne) {
  19361. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19362. }
  19363. if m.id == nil || m.oldValue == nil {
  19364. return v, errors.New("OldMoney requires an ID field in the mutation")
  19365. }
  19366. oldValue, err := m.oldValue(ctx)
  19367. if err != nil {
  19368. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19369. }
  19370. return oldValue.Money, nil
  19371. }
  19372. // AddMoney adds f to the "money" field.
  19373. func (m *PayRechargeMutation) AddMoney(f float32) {
  19374. if m.addmoney != nil {
  19375. *m.addmoney += f
  19376. } else {
  19377. m.addmoney = &f
  19378. }
  19379. }
  19380. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19381. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19382. v := m.addmoney
  19383. if v == nil {
  19384. return
  19385. }
  19386. return *v, true
  19387. }
  19388. // ClearMoney clears the value of the "money" field.
  19389. func (m *PayRechargeMutation) ClearMoney() {
  19390. m.money = nil
  19391. m.addmoney = nil
  19392. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19393. }
  19394. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19395. func (m *PayRechargeMutation) MoneyCleared() bool {
  19396. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19397. return ok
  19398. }
  19399. // ResetMoney resets all changes to the "money" field.
  19400. func (m *PayRechargeMutation) ResetMoney() {
  19401. m.money = nil
  19402. m.addmoney = nil
  19403. delete(m.clearedFields, payrecharge.FieldMoney)
  19404. }
  19405. // SetOutTradeNo sets the "out_trade_no" field.
  19406. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19407. m.out_trade_no = &s
  19408. }
  19409. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19410. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19411. v := m.out_trade_no
  19412. if v == nil {
  19413. return
  19414. }
  19415. return *v, true
  19416. }
  19417. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19418. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19420. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19421. if !m.op.Is(OpUpdateOne) {
  19422. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19423. }
  19424. if m.id == nil || m.oldValue == nil {
  19425. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19426. }
  19427. oldValue, err := m.oldValue(ctx)
  19428. if err != nil {
  19429. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19430. }
  19431. return oldValue.OutTradeNo, nil
  19432. }
  19433. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19434. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19435. m.out_trade_no = nil
  19436. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19437. }
  19438. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19439. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19440. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19441. return ok
  19442. }
  19443. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19444. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19445. m.out_trade_no = nil
  19446. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19447. }
  19448. // SetOrganizationID sets the "organization_id" field.
  19449. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19450. m.organization_id = &u
  19451. m.addorganization_id = nil
  19452. }
  19453. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19454. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19455. v := m.organization_id
  19456. if v == nil {
  19457. return
  19458. }
  19459. return *v, true
  19460. }
  19461. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19462. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19464. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19465. if !m.op.Is(OpUpdateOne) {
  19466. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19467. }
  19468. if m.id == nil || m.oldValue == nil {
  19469. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19470. }
  19471. oldValue, err := m.oldValue(ctx)
  19472. if err != nil {
  19473. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19474. }
  19475. return oldValue.OrganizationID, nil
  19476. }
  19477. // AddOrganizationID adds u to the "organization_id" field.
  19478. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19479. if m.addorganization_id != nil {
  19480. *m.addorganization_id += u
  19481. } else {
  19482. m.addorganization_id = &u
  19483. }
  19484. }
  19485. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19486. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19487. v := m.addorganization_id
  19488. if v == nil {
  19489. return
  19490. }
  19491. return *v, true
  19492. }
  19493. // ResetOrganizationID resets all changes to the "organization_id" field.
  19494. func (m *PayRechargeMutation) ResetOrganizationID() {
  19495. m.organization_id = nil
  19496. m.addorganization_id = nil
  19497. }
  19498. // Where appends a list predicates to the PayRechargeMutation builder.
  19499. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19500. m.predicates = append(m.predicates, ps...)
  19501. }
  19502. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19503. // users can use type-assertion to append predicates that do not depend on any generated package.
  19504. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19505. p := make([]predicate.PayRecharge, len(ps))
  19506. for i := range ps {
  19507. p[i] = ps[i]
  19508. }
  19509. m.Where(p...)
  19510. }
  19511. // Op returns the operation name.
  19512. func (m *PayRechargeMutation) Op() Op {
  19513. return m.op
  19514. }
  19515. // SetOp allows setting the mutation operation.
  19516. func (m *PayRechargeMutation) SetOp(op Op) {
  19517. m.op = op
  19518. }
  19519. // Type returns the node type of this mutation (PayRecharge).
  19520. func (m *PayRechargeMutation) Type() string {
  19521. return m.typ
  19522. }
  19523. // Fields returns all fields that were changed during this mutation. Note that in
  19524. // order to get all numeric fields that were incremented/decremented, call
  19525. // AddedFields().
  19526. func (m *PayRechargeMutation) Fields() []string {
  19527. fields := make([]string, 0, 9)
  19528. if m.created_at != nil {
  19529. fields = append(fields, payrecharge.FieldCreatedAt)
  19530. }
  19531. if m.updated_at != nil {
  19532. fields = append(fields, payrecharge.FieldUpdatedAt)
  19533. }
  19534. if m.deleted_at != nil {
  19535. fields = append(fields, payrecharge.FieldDeletedAt)
  19536. }
  19537. if m.user_id != nil {
  19538. fields = append(fields, payrecharge.FieldUserID)
  19539. }
  19540. if m.number != nil {
  19541. fields = append(fields, payrecharge.FieldNumber)
  19542. }
  19543. if m.status != nil {
  19544. fields = append(fields, payrecharge.FieldStatus)
  19545. }
  19546. if m.money != nil {
  19547. fields = append(fields, payrecharge.FieldMoney)
  19548. }
  19549. if m.out_trade_no != nil {
  19550. fields = append(fields, payrecharge.FieldOutTradeNo)
  19551. }
  19552. if m.organization_id != nil {
  19553. fields = append(fields, payrecharge.FieldOrganizationID)
  19554. }
  19555. return fields
  19556. }
  19557. // Field returns the value of a field with the given name. The second boolean
  19558. // return value indicates that this field was not set, or was not defined in the
  19559. // schema.
  19560. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19561. switch name {
  19562. case payrecharge.FieldCreatedAt:
  19563. return m.CreatedAt()
  19564. case payrecharge.FieldUpdatedAt:
  19565. return m.UpdatedAt()
  19566. case payrecharge.FieldDeletedAt:
  19567. return m.DeletedAt()
  19568. case payrecharge.FieldUserID:
  19569. return m.UserID()
  19570. case payrecharge.FieldNumber:
  19571. return m.Number()
  19572. case payrecharge.FieldStatus:
  19573. return m.Status()
  19574. case payrecharge.FieldMoney:
  19575. return m.Money()
  19576. case payrecharge.FieldOutTradeNo:
  19577. return m.OutTradeNo()
  19578. case payrecharge.FieldOrganizationID:
  19579. return m.OrganizationID()
  19580. }
  19581. return nil, false
  19582. }
  19583. // OldField returns the old value of the field from the database. An error is
  19584. // returned if the mutation operation is not UpdateOne, or the query to the
  19585. // database failed.
  19586. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19587. switch name {
  19588. case payrecharge.FieldCreatedAt:
  19589. return m.OldCreatedAt(ctx)
  19590. case payrecharge.FieldUpdatedAt:
  19591. return m.OldUpdatedAt(ctx)
  19592. case payrecharge.FieldDeletedAt:
  19593. return m.OldDeletedAt(ctx)
  19594. case payrecharge.FieldUserID:
  19595. return m.OldUserID(ctx)
  19596. case payrecharge.FieldNumber:
  19597. return m.OldNumber(ctx)
  19598. case payrecharge.FieldStatus:
  19599. return m.OldStatus(ctx)
  19600. case payrecharge.FieldMoney:
  19601. return m.OldMoney(ctx)
  19602. case payrecharge.FieldOutTradeNo:
  19603. return m.OldOutTradeNo(ctx)
  19604. case payrecharge.FieldOrganizationID:
  19605. return m.OldOrganizationID(ctx)
  19606. }
  19607. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19608. }
  19609. // SetField sets the value of a field with the given name. It returns an error if
  19610. // the field is not defined in the schema, or if the type mismatched the field
  19611. // type.
  19612. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19613. switch name {
  19614. case payrecharge.FieldCreatedAt:
  19615. v, ok := value.(time.Time)
  19616. if !ok {
  19617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19618. }
  19619. m.SetCreatedAt(v)
  19620. return nil
  19621. case payrecharge.FieldUpdatedAt:
  19622. v, ok := value.(time.Time)
  19623. if !ok {
  19624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19625. }
  19626. m.SetUpdatedAt(v)
  19627. return nil
  19628. case payrecharge.FieldDeletedAt:
  19629. v, ok := value.(time.Time)
  19630. if !ok {
  19631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19632. }
  19633. m.SetDeletedAt(v)
  19634. return nil
  19635. case payrecharge.FieldUserID:
  19636. v, ok := value.(string)
  19637. if !ok {
  19638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19639. }
  19640. m.SetUserID(v)
  19641. return nil
  19642. case payrecharge.FieldNumber:
  19643. v, ok := value.(float32)
  19644. if !ok {
  19645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19646. }
  19647. m.SetNumber(v)
  19648. return nil
  19649. case payrecharge.FieldStatus:
  19650. v, ok := value.(int)
  19651. if !ok {
  19652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19653. }
  19654. m.SetStatus(v)
  19655. return nil
  19656. case payrecharge.FieldMoney:
  19657. v, ok := value.(float32)
  19658. if !ok {
  19659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19660. }
  19661. m.SetMoney(v)
  19662. return nil
  19663. case payrecharge.FieldOutTradeNo:
  19664. v, ok := value.(string)
  19665. if !ok {
  19666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19667. }
  19668. m.SetOutTradeNo(v)
  19669. return nil
  19670. case payrecharge.FieldOrganizationID:
  19671. v, ok := value.(uint64)
  19672. if !ok {
  19673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19674. }
  19675. m.SetOrganizationID(v)
  19676. return nil
  19677. }
  19678. return fmt.Errorf("unknown PayRecharge field %s", name)
  19679. }
  19680. // AddedFields returns all numeric fields that were incremented/decremented during
  19681. // this mutation.
  19682. func (m *PayRechargeMutation) AddedFields() []string {
  19683. var fields []string
  19684. if m.addnumber != nil {
  19685. fields = append(fields, payrecharge.FieldNumber)
  19686. }
  19687. if m.addstatus != nil {
  19688. fields = append(fields, payrecharge.FieldStatus)
  19689. }
  19690. if m.addmoney != nil {
  19691. fields = append(fields, payrecharge.FieldMoney)
  19692. }
  19693. if m.addorganization_id != nil {
  19694. fields = append(fields, payrecharge.FieldOrganizationID)
  19695. }
  19696. return fields
  19697. }
  19698. // AddedField returns the numeric value that was incremented/decremented on a field
  19699. // with the given name. The second boolean return value indicates that this field
  19700. // was not set, or was not defined in the schema.
  19701. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19702. switch name {
  19703. case payrecharge.FieldNumber:
  19704. return m.AddedNumber()
  19705. case payrecharge.FieldStatus:
  19706. return m.AddedStatus()
  19707. case payrecharge.FieldMoney:
  19708. return m.AddedMoney()
  19709. case payrecharge.FieldOrganizationID:
  19710. return m.AddedOrganizationID()
  19711. }
  19712. return nil, false
  19713. }
  19714. // AddField adds the value to the field with the given name. It returns an error if
  19715. // the field is not defined in the schema, or if the type mismatched the field
  19716. // type.
  19717. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19718. switch name {
  19719. case payrecharge.FieldNumber:
  19720. v, ok := value.(float32)
  19721. if !ok {
  19722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19723. }
  19724. m.AddNumber(v)
  19725. return nil
  19726. case payrecharge.FieldStatus:
  19727. v, ok := value.(int)
  19728. if !ok {
  19729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19730. }
  19731. m.AddStatus(v)
  19732. return nil
  19733. case payrecharge.FieldMoney:
  19734. v, ok := value.(float32)
  19735. if !ok {
  19736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19737. }
  19738. m.AddMoney(v)
  19739. return nil
  19740. case payrecharge.FieldOrganizationID:
  19741. v, ok := value.(int64)
  19742. if !ok {
  19743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19744. }
  19745. m.AddOrganizationID(v)
  19746. return nil
  19747. }
  19748. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19749. }
  19750. // ClearedFields returns all nullable fields that were cleared during this
  19751. // mutation.
  19752. func (m *PayRechargeMutation) ClearedFields() []string {
  19753. var fields []string
  19754. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19755. fields = append(fields, payrecharge.FieldDeletedAt)
  19756. }
  19757. if m.FieldCleared(payrecharge.FieldStatus) {
  19758. fields = append(fields, payrecharge.FieldStatus)
  19759. }
  19760. if m.FieldCleared(payrecharge.FieldMoney) {
  19761. fields = append(fields, payrecharge.FieldMoney)
  19762. }
  19763. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19764. fields = append(fields, payrecharge.FieldOutTradeNo)
  19765. }
  19766. return fields
  19767. }
  19768. // FieldCleared returns a boolean indicating if a field with the given name was
  19769. // cleared in this mutation.
  19770. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19771. _, ok := m.clearedFields[name]
  19772. return ok
  19773. }
  19774. // ClearField clears the value of the field with the given name. It returns an
  19775. // error if the field is not defined in the schema.
  19776. func (m *PayRechargeMutation) ClearField(name string) error {
  19777. switch name {
  19778. case payrecharge.FieldDeletedAt:
  19779. m.ClearDeletedAt()
  19780. return nil
  19781. case payrecharge.FieldStatus:
  19782. m.ClearStatus()
  19783. return nil
  19784. case payrecharge.FieldMoney:
  19785. m.ClearMoney()
  19786. return nil
  19787. case payrecharge.FieldOutTradeNo:
  19788. m.ClearOutTradeNo()
  19789. return nil
  19790. }
  19791. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19792. }
  19793. // ResetField resets all changes in the mutation for the field with the given name.
  19794. // It returns an error if the field is not defined in the schema.
  19795. func (m *PayRechargeMutation) ResetField(name string) error {
  19796. switch name {
  19797. case payrecharge.FieldCreatedAt:
  19798. m.ResetCreatedAt()
  19799. return nil
  19800. case payrecharge.FieldUpdatedAt:
  19801. m.ResetUpdatedAt()
  19802. return nil
  19803. case payrecharge.FieldDeletedAt:
  19804. m.ResetDeletedAt()
  19805. return nil
  19806. case payrecharge.FieldUserID:
  19807. m.ResetUserID()
  19808. return nil
  19809. case payrecharge.FieldNumber:
  19810. m.ResetNumber()
  19811. return nil
  19812. case payrecharge.FieldStatus:
  19813. m.ResetStatus()
  19814. return nil
  19815. case payrecharge.FieldMoney:
  19816. m.ResetMoney()
  19817. return nil
  19818. case payrecharge.FieldOutTradeNo:
  19819. m.ResetOutTradeNo()
  19820. return nil
  19821. case payrecharge.FieldOrganizationID:
  19822. m.ResetOrganizationID()
  19823. return nil
  19824. }
  19825. return fmt.Errorf("unknown PayRecharge field %s", name)
  19826. }
  19827. // AddedEdges returns all edge names that were set/added in this mutation.
  19828. func (m *PayRechargeMutation) AddedEdges() []string {
  19829. edges := make([]string, 0, 0)
  19830. return edges
  19831. }
  19832. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19833. // name in this mutation.
  19834. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19835. return nil
  19836. }
  19837. // RemovedEdges returns all edge names that were removed in this mutation.
  19838. func (m *PayRechargeMutation) RemovedEdges() []string {
  19839. edges := make([]string, 0, 0)
  19840. return edges
  19841. }
  19842. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19843. // the given name in this mutation.
  19844. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19845. return nil
  19846. }
  19847. // ClearedEdges returns all edge names that were cleared in this mutation.
  19848. func (m *PayRechargeMutation) ClearedEdges() []string {
  19849. edges := make([]string, 0, 0)
  19850. return edges
  19851. }
  19852. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19853. // was cleared in this mutation.
  19854. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19855. return false
  19856. }
  19857. // ClearEdge clears the value of the edge with the given name. It returns an error
  19858. // if that edge is not defined in the schema.
  19859. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19860. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19861. }
  19862. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19863. // It returns an error if the edge is not defined in the schema.
  19864. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19865. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19866. }
  19867. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19868. type ServerMutation struct {
  19869. config
  19870. op Op
  19871. typ string
  19872. id *uint64
  19873. created_at *time.Time
  19874. updated_at *time.Time
  19875. status *uint8
  19876. addstatus *int8
  19877. deleted_at *time.Time
  19878. name *string
  19879. public_ip *string
  19880. private_ip *string
  19881. admin_port *string
  19882. clearedFields map[string]struct{}
  19883. wxs map[uint64]struct{}
  19884. removedwxs map[uint64]struct{}
  19885. clearedwxs bool
  19886. done bool
  19887. oldValue func(context.Context) (*Server, error)
  19888. predicates []predicate.Server
  19889. }
  19890. var _ ent.Mutation = (*ServerMutation)(nil)
  19891. // serverOption allows management of the mutation configuration using functional options.
  19892. type serverOption func(*ServerMutation)
  19893. // newServerMutation creates new mutation for the Server entity.
  19894. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19895. m := &ServerMutation{
  19896. config: c,
  19897. op: op,
  19898. typ: TypeServer,
  19899. clearedFields: make(map[string]struct{}),
  19900. }
  19901. for _, opt := range opts {
  19902. opt(m)
  19903. }
  19904. return m
  19905. }
  19906. // withServerID sets the ID field of the mutation.
  19907. func withServerID(id uint64) serverOption {
  19908. return func(m *ServerMutation) {
  19909. var (
  19910. err error
  19911. once sync.Once
  19912. value *Server
  19913. )
  19914. m.oldValue = func(ctx context.Context) (*Server, error) {
  19915. once.Do(func() {
  19916. if m.done {
  19917. err = errors.New("querying old values post mutation is not allowed")
  19918. } else {
  19919. value, err = m.Client().Server.Get(ctx, id)
  19920. }
  19921. })
  19922. return value, err
  19923. }
  19924. m.id = &id
  19925. }
  19926. }
  19927. // withServer sets the old Server of the mutation.
  19928. func withServer(node *Server) serverOption {
  19929. return func(m *ServerMutation) {
  19930. m.oldValue = func(context.Context) (*Server, error) {
  19931. return node, nil
  19932. }
  19933. m.id = &node.ID
  19934. }
  19935. }
  19936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19937. // executed in a transaction (ent.Tx), a transactional client is returned.
  19938. func (m ServerMutation) Client() *Client {
  19939. client := &Client{config: m.config}
  19940. client.init()
  19941. return client
  19942. }
  19943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19944. // it returns an error otherwise.
  19945. func (m ServerMutation) Tx() (*Tx, error) {
  19946. if _, ok := m.driver.(*txDriver); !ok {
  19947. return nil, errors.New("ent: mutation is not running in a transaction")
  19948. }
  19949. tx := &Tx{config: m.config}
  19950. tx.init()
  19951. return tx, nil
  19952. }
  19953. // SetID sets the value of the id field. Note that this
  19954. // operation is only accepted on creation of Server entities.
  19955. func (m *ServerMutation) SetID(id uint64) {
  19956. m.id = &id
  19957. }
  19958. // ID returns the ID value in the mutation. Note that the ID is only available
  19959. // if it was provided to the builder or after it was returned from the database.
  19960. func (m *ServerMutation) ID() (id uint64, exists bool) {
  19961. if m.id == nil {
  19962. return
  19963. }
  19964. return *m.id, true
  19965. }
  19966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19967. // That means, if the mutation is applied within a transaction with an isolation level such
  19968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19969. // or updated by the mutation.
  19970. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  19971. switch {
  19972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19973. id, exists := m.ID()
  19974. if exists {
  19975. return []uint64{id}, nil
  19976. }
  19977. fallthrough
  19978. case m.op.Is(OpUpdate | OpDelete):
  19979. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  19980. default:
  19981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19982. }
  19983. }
  19984. // SetCreatedAt sets the "created_at" field.
  19985. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  19986. m.created_at = &t
  19987. }
  19988. // CreatedAt returns the value of the "created_at" field in the mutation.
  19989. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  19990. v := m.created_at
  19991. if v == nil {
  19992. return
  19993. }
  19994. return *v, true
  19995. }
  19996. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  19997. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19999. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20000. if !m.op.Is(OpUpdateOne) {
  20001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20002. }
  20003. if m.id == nil || m.oldValue == nil {
  20004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20005. }
  20006. oldValue, err := m.oldValue(ctx)
  20007. if err != nil {
  20008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20009. }
  20010. return oldValue.CreatedAt, nil
  20011. }
  20012. // ResetCreatedAt resets all changes to the "created_at" field.
  20013. func (m *ServerMutation) ResetCreatedAt() {
  20014. m.created_at = nil
  20015. }
  20016. // SetUpdatedAt sets the "updated_at" field.
  20017. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20018. m.updated_at = &t
  20019. }
  20020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20021. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20022. v := m.updated_at
  20023. if v == nil {
  20024. return
  20025. }
  20026. return *v, true
  20027. }
  20028. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20029. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20031. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20032. if !m.op.Is(OpUpdateOne) {
  20033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20034. }
  20035. if m.id == nil || m.oldValue == nil {
  20036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20037. }
  20038. oldValue, err := m.oldValue(ctx)
  20039. if err != nil {
  20040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20041. }
  20042. return oldValue.UpdatedAt, nil
  20043. }
  20044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20045. func (m *ServerMutation) ResetUpdatedAt() {
  20046. m.updated_at = nil
  20047. }
  20048. // SetStatus sets the "status" field.
  20049. func (m *ServerMutation) SetStatus(u uint8) {
  20050. m.status = &u
  20051. m.addstatus = nil
  20052. }
  20053. // Status returns the value of the "status" field in the mutation.
  20054. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20055. v := m.status
  20056. if v == nil {
  20057. return
  20058. }
  20059. return *v, true
  20060. }
  20061. // OldStatus returns the old "status" field's value of the Server entity.
  20062. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20064. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20065. if !m.op.Is(OpUpdateOne) {
  20066. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20067. }
  20068. if m.id == nil || m.oldValue == nil {
  20069. return v, errors.New("OldStatus requires an ID field in the mutation")
  20070. }
  20071. oldValue, err := m.oldValue(ctx)
  20072. if err != nil {
  20073. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20074. }
  20075. return oldValue.Status, nil
  20076. }
  20077. // AddStatus adds u to the "status" field.
  20078. func (m *ServerMutation) AddStatus(u int8) {
  20079. if m.addstatus != nil {
  20080. *m.addstatus += u
  20081. } else {
  20082. m.addstatus = &u
  20083. }
  20084. }
  20085. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20086. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20087. v := m.addstatus
  20088. if v == nil {
  20089. return
  20090. }
  20091. return *v, true
  20092. }
  20093. // ClearStatus clears the value of the "status" field.
  20094. func (m *ServerMutation) ClearStatus() {
  20095. m.status = nil
  20096. m.addstatus = nil
  20097. m.clearedFields[server.FieldStatus] = struct{}{}
  20098. }
  20099. // StatusCleared returns if the "status" field was cleared in this mutation.
  20100. func (m *ServerMutation) StatusCleared() bool {
  20101. _, ok := m.clearedFields[server.FieldStatus]
  20102. return ok
  20103. }
  20104. // ResetStatus resets all changes to the "status" field.
  20105. func (m *ServerMutation) ResetStatus() {
  20106. m.status = nil
  20107. m.addstatus = nil
  20108. delete(m.clearedFields, server.FieldStatus)
  20109. }
  20110. // SetDeletedAt sets the "deleted_at" field.
  20111. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20112. m.deleted_at = &t
  20113. }
  20114. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20115. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20116. v := m.deleted_at
  20117. if v == nil {
  20118. return
  20119. }
  20120. return *v, true
  20121. }
  20122. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20123. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20125. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20126. if !m.op.Is(OpUpdateOne) {
  20127. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20128. }
  20129. if m.id == nil || m.oldValue == nil {
  20130. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20131. }
  20132. oldValue, err := m.oldValue(ctx)
  20133. if err != nil {
  20134. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20135. }
  20136. return oldValue.DeletedAt, nil
  20137. }
  20138. // ClearDeletedAt clears the value of the "deleted_at" field.
  20139. func (m *ServerMutation) ClearDeletedAt() {
  20140. m.deleted_at = nil
  20141. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20142. }
  20143. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20144. func (m *ServerMutation) DeletedAtCleared() bool {
  20145. _, ok := m.clearedFields[server.FieldDeletedAt]
  20146. return ok
  20147. }
  20148. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20149. func (m *ServerMutation) ResetDeletedAt() {
  20150. m.deleted_at = nil
  20151. delete(m.clearedFields, server.FieldDeletedAt)
  20152. }
  20153. // SetName sets the "name" field.
  20154. func (m *ServerMutation) SetName(s string) {
  20155. m.name = &s
  20156. }
  20157. // Name returns the value of the "name" field in the mutation.
  20158. func (m *ServerMutation) Name() (r string, exists bool) {
  20159. v := m.name
  20160. if v == nil {
  20161. return
  20162. }
  20163. return *v, true
  20164. }
  20165. // OldName returns the old "name" field's value of the Server entity.
  20166. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20168. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20169. if !m.op.Is(OpUpdateOne) {
  20170. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20171. }
  20172. if m.id == nil || m.oldValue == nil {
  20173. return v, errors.New("OldName requires an ID field in the mutation")
  20174. }
  20175. oldValue, err := m.oldValue(ctx)
  20176. if err != nil {
  20177. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20178. }
  20179. return oldValue.Name, nil
  20180. }
  20181. // ResetName resets all changes to the "name" field.
  20182. func (m *ServerMutation) ResetName() {
  20183. m.name = nil
  20184. }
  20185. // SetPublicIP sets the "public_ip" field.
  20186. func (m *ServerMutation) SetPublicIP(s string) {
  20187. m.public_ip = &s
  20188. }
  20189. // PublicIP returns the value of the "public_ip" field in the mutation.
  20190. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20191. v := m.public_ip
  20192. if v == nil {
  20193. return
  20194. }
  20195. return *v, true
  20196. }
  20197. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20198. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20200. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20201. if !m.op.Is(OpUpdateOne) {
  20202. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20203. }
  20204. if m.id == nil || m.oldValue == nil {
  20205. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20206. }
  20207. oldValue, err := m.oldValue(ctx)
  20208. if err != nil {
  20209. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20210. }
  20211. return oldValue.PublicIP, nil
  20212. }
  20213. // ResetPublicIP resets all changes to the "public_ip" field.
  20214. func (m *ServerMutation) ResetPublicIP() {
  20215. m.public_ip = nil
  20216. }
  20217. // SetPrivateIP sets the "private_ip" field.
  20218. func (m *ServerMutation) SetPrivateIP(s string) {
  20219. m.private_ip = &s
  20220. }
  20221. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20222. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20223. v := m.private_ip
  20224. if v == nil {
  20225. return
  20226. }
  20227. return *v, true
  20228. }
  20229. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20230. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20232. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20233. if !m.op.Is(OpUpdateOne) {
  20234. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20235. }
  20236. if m.id == nil || m.oldValue == nil {
  20237. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20238. }
  20239. oldValue, err := m.oldValue(ctx)
  20240. if err != nil {
  20241. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20242. }
  20243. return oldValue.PrivateIP, nil
  20244. }
  20245. // ResetPrivateIP resets all changes to the "private_ip" field.
  20246. func (m *ServerMutation) ResetPrivateIP() {
  20247. m.private_ip = nil
  20248. }
  20249. // SetAdminPort sets the "admin_port" field.
  20250. func (m *ServerMutation) SetAdminPort(s string) {
  20251. m.admin_port = &s
  20252. }
  20253. // AdminPort returns the value of the "admin_port" field in the mutation.
  20254. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20255. v := m.admin_port
  20256. if v == nil {
  20257. return
  20258. }
  20259. return *v, true
  20260. }
  20261. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20262. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20264. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20265. if !m.op.Is(OpUpdateOne) {
  20266. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20267. }
  20268. if m.id == nil || m.oldValue == nil {
  20269. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20270. }
  20271. oldValue, err := m.oldValue(ctx)
  20272. if err != nil {
  20273. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20274. }
  20275. return oldValue.AdminPort, nil
  20276. }
  20277. // ResetAdminPort resets all changes to the "admin_port" field.
  20278. func (m *ServerMutation) ResetAdminPort() {
  20279. m.admin_port = nil
  20280. }
  20281. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20282. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20283. if m.wxs == nil {
  20284. m.wxs = make(map[uint64]struct{})
  20285. }
  20286. for i := range ids {
  20287. m.wxs[ids[i]] = struct{}{}
  20288. }
  20289. }
  20290. // ClearWxs clears the "wxs" edge to the Wx entity.
  20291. func (m *ServerMutation) ClearWxs() {
  20292. m.clearedwxs = true
  20293. }
  20294. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20295. func (m *ServerMutation) WxsCleared() bool {
  20296. return m.clearedwxs
  20297. }
  20298. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20299. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20300. if m.removedwxs == nil {
  20301. m.removedwxs = make(map[uint64]struct{})
  20302. }
  20303. for i := range ids {
  20304. delete(m.wxs, ids[i])
  20305. m.removedwxs[ids[i]] = struct{}{}
  20306. }
  20307. }
  20308. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20309. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20310. for id := range m.removedwxs {
  20311. ids = append(ids, id)
  20312. }
  20313. return
  20314. }
  20315. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20316. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20317. for id := range m.wxs {
  20318. ids = append(ids, id)
  20319. }
  20320. return
  20321. }
  20322. // ResetWxs resets all changes to the "wxs" edge.
  20323. func (m *ServerMutation) ResetWxs() {
  20324. m.wxs = nil
  20325. m.clearedwxs = false
  20326. m.removedwxs = nil
  20327. }
  20328. // Where appends a list predicates to the ServerMutation builder.
  20329. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20330. m.predicates = append(m.predicates, ps...)
  20331. }
  20332. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20333. // users can use type-assertion to append predicates that do not depend on any generated package.
  20334. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20335. p := make([]predicate.Server, len(ps))
  20336. for i := range ps {
  20337. p[i] = ps[i]
  20338. }
  20339. m.Where(p...)
  20340. }
  20341. // Op returns the operation name.
  20342. func (m *ServerMutation) Op() Op {
  20343. return m.op
  20344. }
  20345. // SetOp allows setting the mutation operation.
  20346. func (m *ServerMutation) SetOp(op Op) {
  20347. m.op = op
  20348. }
  20349. // Type returns the node type of this mutation (Server).
  20350. func (m *ServerMutation) Type() string {
  20351. return m.typ
  20352. }
  20353. // Fields returns all fields that were changed during this mutation. Note that in
  20354. // order to get all numeric fields that were incremented/decremented, call
  20355. // AddedFields().
  20356. func (m *ServerMutation) Fields() []string {
  20357. fields := make([]string, 0, 8)
  20358. if m.created_at != nil {
  20359. fields = append(fields, server.FieldCreatedAt)
  20360. }
  20361. if m.updated_at != nil {
  20362. fields = append(fields, server.FieldUpdatedAt)
  20363. }
  20364. if m.status != nil {
  20365. fields = append(fields, server.FieldStatus)
  20366. }
  20367. if m.deleted_at != nil {
  20368. fields = append(fields, server.FieldDeletedAt)
  20369. }
  20370. if m.name != nil {
  20371. fields = append(fields, server.FieldName)
  20372. }
  20373. if m.public_ip != nil {
  20374. fields = append(fields, server.FieldPublicIP)
  20375. }
  20376. if m.private_ip != nil {
  20377. fields = append(fields, server.FieldPrivateIP)
  20378. }
  20379. if m.admin_port != nil {
  20380. fields = append(fields, server.FieldAdminPort)
  20381. }
  20382. return fields
  20383. }
  20384. // Field returns the value of a field with the given name. The second boolean
  20385. // return value indicates that this field was not set, or was not defined in the
  20386. // schema.
  20387. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20388. switch name {
  20389. case server.FieldCreatedAt:
  20390. return m.CreatedAt()
  20391. case server.FieldUpdatedAt:
  20392. return m.UpdatedAt()
  20393. case server.FieldStatus:
  20394. return m.Status()
  20395. case server.FieldDeletedAt:
  20396. return m.DeletedAt()
  20397. case server.FieldName:
  20398. return m.Name()
  20399. case server.FieldPublicIP:
  20400. return m.PublicIP()
  20401. case server.FieldPrivateIP:
  20402. return m.PrivateIP()
  20403. case server.FieldAdminPort:
  20404. return m.AdminPort()
  20405. }
  20406. return nil, false
  20407. }
  20408. // OldField returns the old value of the field from the database. An error is
  20409. // returned if the mutation operation is not UpdateOne, or the query to the
  20410. // database failed.
  20411. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20412. switch name {
  20413. case server.FieldCreatedAt:
  20414. return m.OldCreatedAt(ctx)
  20415. case server.FieldUpdatedAt:
  20416. return m.OldUpdatedAt(ctx)
  20417. case server.FieldStatus:
  20418. return m.OldStatus(ctx)
  20419. case server.FieldDeletedAt:
  20420. return m.OldDeletedAt(ctx)
  20421. case server.FieldName:
  20422. return m.OldName(ctx)
  20423. case server.FieldPublicIP:
  20424. return m.OldPublicIP(ctx)
  20425. case server.FieldPrivateIP:
  20426. return m.OldPrivateIP(ctx)
  20427. case server.FieldAdminPort:
  20428. return m.OldAdminPort(ctx)
  20429. }
  20430. return nil, fmt.Errorf("unknown Server field %s", name)
  20431. }
  20432. // SetField sets the value of a field with the given name. It returns an error if
  20433. // the field is not defined in the schema, or if the type mismatched the field
  20434. // type.
  20435. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20436. switch name {
  20437. case server.FieldCreatedAt:
  20438. v, ok := value.(time.Time)
  20439. if !ok {
  20440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20441. }
  20442. m.SetCreatedAt(v)
  20443. return nil
  20444. case server.FieldUpdatedAt:
  20445. v, ok := value.(time.Time)
  20446. if !ok {
  20447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20448. }
  20449. m.SetUpdatedAt(v)
  20450. return nil
  20451. case server.FieldStatus:
  20452. v, ok := value.(uint8)
  20453. if !ok {
  20454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20455. }
  20456. m.SetStatus(v)
  20457. return nil
  20458. case server.FieldDeletedAt:
  20459. v, ok := value.(time.Time)
  20460. if !ok {
  20461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20462. }
  20463. m.SetDeletedAt(v)
  20464. return nil
  20465. case server.FieldName:
  20466. v, ok := value.(string)
  20467. if !ok {
  20468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20469. }
  20470. m.SetName(v)
  20471. return nil
  20472. case server.FieldPublicIP:
  20473. v, ok := value.(string)
  20474. if !ok {
  20475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20476. }
  20477. m.SetPublicIP(v)
  20478. return nil
  20479. case server.FieldPrivateIP:
  20480. v, ok := value.(string)
  20481. if !ok {
  20482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20483. }
  20484. m.SetPrivateIP(v)
  20485. return nil
  20486. case server.FieldAdminPort:
  20487. v, ok := value.(string)
  20488. if !ok {
  20489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20490. }
  20491. m.SetAdminPort(v)
  20492. return nil
  20493. }
  20494. return fmt.Errorf("unknown Server field %s", name)
  20495. }
  20496. // AddedFields returns all numeric fields that were incremented/decremented during
  20497. // this mutation.
  20498. func (m *ServerMutation) AddedFields() []string {
  20499. var fields []string
  20500. if m.addstatus != nil {
  20501. fields = append(fields, server.FieldStatus)
  20502. }
  20503. return fields
  20504. }
  20505. // AddedField returns the numeric value that was incremented/decremented on a field
  20506. // with the given name. The second boolean return value indicates that this field
  20507. // was not set, or was not defined in the schema.
  20508. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20509. switch name {
  20510. case server.FieldStatus:
  20511. return m.AddedStatus()
  20512. }
  20513. return nil, false
  20514. }
  20515. // AddField adds the value to the field with the given name. It returns an error if
  20516. // the field is not defined in the schema, or if the type mismatched the field
  20517. // type.
  20518. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20519. switch name {
  20520. case server.FieldStatus:
  20521. v, ok := value.(int8)
  20522. if !ok {
  20523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20524. }
  20525. m.AddStatus(v)
  20526. return nil
  20527. }
  20528. return fmt.Errorf("unknown Server numeric field %s", name)
  20529. }
  20530. // ClearedFields returns all nullable fields that were cleared during this
  20531. // mutation.
  20532. func (m *ServerMutation) ClearedFields() []string {
  20533. var fields []string
  20534. if m.FieldCleared(server.FieldStatus) {
  20535. fields = append(fields, server.FieldStatus)
  20536. }
  20537. if m.FieldCleared(server.FieldDeletedAt) {
  20538. fields = append(fields, server.FieldDeletedAt)
  20539. }
  20540. return fields
  20541. }
  20542. // FieldCleared returns a boolean indicating if a field with the given name was
  20543. // cleared in this mutation.
  20544. func (m *ServerMutation) FieldCleared(name string) bool {
  20545. _, ok := m.clearedFields[name]
  20546. return ok
  20547. }
  20548. // ClearField clears the value of the field with the given name. It returns an
  20549. // error if the field is not defined in the schema.
  20550. func (m *ServerMutation) ClearField(name string) error {
  20551. switch name {
  20552. case server.FieldStatus:
  20553. m.ClearStatus()
  20554. return nil
  20555. case server.FieldDeletedAt:
  20556. m.ClearDeletedAt()
  20557. return nil
  20558. }
  20559. return fmt.Errorf("unknown Server nullable field %s", name)
  20560. }
  20561. // ResetField resets all changes in the mutation for the field with the given name.
  20562. // It returns an error if the field is not defined in the schema.
  20563. func (m *ServerMutation) ResetField(name string) error {
  20564. switch name {
  20565. case server.FieldCreatedAt:
  20566. m.ResetCreatedAt()
  20567. return nil
  20568. case server.FieldUpdatedAt:
  20569. m.ResetUpdatedAt()
  20570. return nil
  20571. case server.FieldStatus:
  20572. m.ResetStatus()
  20573. return nil
  20574. case server.FieldDeletedAt:
  20575. m.ResetDeletedAt()
  20576. return nil
  20577. case server.FieldName:
  20578. m.ResetName()
  20579. return nil
  20580. case server.FieldPublicIP:
  20581. m.ResetPublicIP()
  20582. return nil
  20583. case server.FieldPrivateIP:
  20584. m.ResetPrivateIP()
  20585. return nil
  20586. case server.FieldAdminPort:
  20587. m.ResetAdminPort()
  20588. return nil
  20589. }
  20590. return fmt.Errorf("unknown Server field %s", name)
  20591. }
  20592. // AddedEdges returns all edge names that were set/added in this mutation.
  20593. func (m *ServerMutation) AddedEdges() []string {
  20594. edges := make([]string, 0, 1)
  20595. if m.wxs != nil {
  20596. edges = append(edges, server.EdgeWxs)
  20597. }
  20598. return edges
  20599. }
  20600. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20601. // name in this mutation.
  20602. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20603. switch name {
  20604. case server.EdgeWxs:
  20605. ids := make([]ent.Value, 0, len(m.wxs))
  20606. for id := range m.wxs {
  20607. ids = append(ids, id)
  20608. }
  20609. return ids
  20610. }
  20611. return nil
  20612. }
  20613. // RemovedEdges returns all edge names that were removed in this mutation.
  20614. func (m *ServerMutation) RemovedEdges() []string {
  20615. edges := make([]string, 0, 1)
  20616. if m.removedwxs != nil {
  20617. edges = append(edges, server.EdgeWxs)
  20618. }
  20619. return edges
  20620. }
  20621. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20622. // the given name in this mutation.
  20623. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20624. switch name {
  20625. case server.EdgeWxs:
  20626. ids := make([]ent.Value, 0, len(m.removedwxs))
  20627. for id := range m.removedwxs {
  20628. ids = append(ids, id)
  20629. }
  20630. return ids
  20631. }
  20632. return nil
  20633. }
  20634. // ClearedEdges returns all edge names that were cleared in this mutation.
  20635. func (m *ServerMutation) ClearedEdges() []string {
  20636. edges := make([]string, 0, 1)
  20637. if m.clearedwxs {
  20638. edges = append(edges, server.EdgeWxs)
  20639. }
  20640. return edges
  20641. }
  20642. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20643. // was cleared in this mutation.
  20644. func (m *ServerMutation) EdgeCleared(name string) bool {
  20645. switch name {
  20646. case server.EdgeWxs:
  20647. return m.clearedwxs
  20648. }
  20649. return false
  20650. }
  20651. // ClearEdge clears the value of the edge with the given name. It returns an error
  20652. // if that edge is not defined in the schema.
  20653. func (m *ServerMutation) ClearEdge(name string) error {
  20654. switch name {
  20655. }
  20656. return fmt.Errorf("unknown Server unique edge %s", name)
  20657. }
  20658. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20659. // It returns an error if the edge is not defined in the schema.
  20660. func (m *ServerMutation) ResetEdge(name string) error {
  20661. switch name {
  20662. case server.EdgeWxs:
  20663. m.ResetWxs()
  20664. return nil
  20665. }
  20666. return fmt.Errorf("unknown Server edge %s", name)
  20667. }
  20668. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20669. type SopNodeMutation struct {
  20670. config
  20671. op Op
  20672. typ string
  20673. id *uint64
  20674. created_at *time.Time
  20675. updated_at *time.Time
  20676. status *uint8
  20677. addstatus *int8
  20678. deleted_at *time.Time
  20679. parent_id *uint64
  20680. addparent_id *int64
  20681. name *string
  20682. condition_type *int
  20683. addcondition_type *int
  20684. condition_list *[]string
  20685. appendcondition_list []string
  20686. no_reply_condition *uint64
  20687. addno_reply_condition *int64
  20688. no_reply_unit *string
  20689. action_message *[]custom_types.Action
  20690. appendaction_message []custom_types.Action
  20691. action_label_add *[]uint64
  20692. appendaction_label_add []uint64
  20693. action_label_del *[]uint64
  20694. appendaction_label_del []uint64
  20695. action_forward **custom_types.ActionForward
  20696. clearedFields map[string]struct{}
  20697. sop_stage *uint64
  20698. clearedsop_stage bool
  20699. node_messages map[uint64]struct{}
  20700. removednode_messages map[uint64]struct{}
  20701. clearednode_messages bool
  20702. done bool
  20703. oldValue func(context.Context) (*SopNode, error)
  20704. predicates []predicate.SopNode
  20705. }
  20706. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20707. // sopnodeOption allows management of the mutation configuration using functional options.
  20708. type sopnodeOption func(*SopNodeMutation)
  20709. // newSopNodeMutation creates new mutation for the SopNode entity.
  20710. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20711. m := &SopNodeMutation{
  20712. config: c,
  20713. op: op,
  20714. typ: TypeSopNode,
  20715. clearedFields: make(map[string]struct{}),
  20716. }
  20717. for _, opt := range opts {
  20718. opt(m)
  20719. }
  20720. return m
  20721. }
  20722. // withSopNodeID sets the ID field of the mutation.
  20723. func withSopNodeID(id uint64) sopnodeOption {
  20724. return func(m *SopNodeMutation) {
  20725. var (
  20726. err error
  20727. once sync.Once
  20728. value *SopNode
  20729. )
  20730. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20731. once.Do(func() {
  20732. if m.done {
  20733. err = errors.New("querying old values post mutation is not allowed")
  20734. } else {
  20735. value, err = m.Client().SopNode.Get(ctx, id)
  20736. }
  20737. })
  20738. return value, err
  20739. }
  20740. m.id = &id
  20741. }
  20742. }
  20743. // withSopNode sets the old SopNode of the mutation.
  20744. func withSopNode(node *SopNode) sopnodeOption {
  20745. return func(m *SopNodeMutation) {
  20746. m.oldValue = func(context.Context) (*SopNode, error) {
  20747. return node, nil
  20748. }
  20749. m.id = &node.ID
  20750. }
  20751. }
  20752. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20753. // executed in a transaction (ent.Tx), a transactional client is returned.
  20754. func (m SopNodeMutation) Client() *Client {
  20755. client := &Client{config: m.config}
  20756. client.init()
  20757. return client
  20758. }
  20759. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20760. // it returns an error otherwise.
  20761. func (m SopNodeMutation) Tx() (*Tx, error) {
  20762. if _, ok := m.driver.(*txDriver); !ok {
  20763. return nil, errors.New("ent: mutation is not running in a transaction")
  20764. }
  20765. tx := &Tx{config: m.config}
  20766. tx.init()
  20767. return tx, nil
  20768. }
  20769. // SetID sets the value of the id field. Note that this
  20770. // operation is only accepted on creation of SopNode entities.
  20771. func (m *SopNodeMutation) SetID(id uint64) {
  20772. m.id = &id
  20773. }
  20774. // ID returns the ID value in the mutation. Note that the ID is only available
  20775. // if it was provided to the builder or after it was returned from the database.
  20776. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20777. if m.id == nil {
  20778. return
  20779. }
  20780. return *m.id, true
  20781. }
  20782. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20783. // That means, if the mutation is applied within a transaction with an isolation level such
  20784. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20785. // or updated by the mutation.
  20786. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20787. switch {
  20788. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20789. id, exists := m.ID()
  20790. if exists {
  20791. return []uint64{id}, nil
  20792. }
  20793. fallthrough
  20794. case m.op.Is(OpUpdate | OpDelete):
  20795. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20796. default:
  20797. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20798. }
  20799. }
  20800. // SetCreatedAt sets the "created_at" field.
  20801. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20802. m.created_at = &t
  20803. }
  20804. // CreatedAt returns the value of the "created_at" field in the mutation.
  20805. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20806. v := m.created_at
  20807. if v == nil {
  20808. return
  20809. }
  20810. return *v, true
  20811. }
  20812. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20813. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20815. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20816. if !m.op.Is(OpUpdateOne) {
  20817. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20818. }
  20819. if m.id == nil || m.oldValue == nil {
  20820. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20821. }
  20822. oldValue, err := m.oldValue(ctx)
  20823. if err != nil {
  20824. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20825. }
  20826. return oldValue.CreatedAt, nil
  20827. }
  20828. // ResetCreatedAt resets all changes to the "created_at" field.
  20829. func (m *SopNodeMutation) ResetCreatedAt() {
  20830. m.created_at = nil
  20831. }
  20832. // SetUpdatedAt sets the "updated_at" field.
  20833. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20834. m.updated_at = &t
  20835. }
  20836. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20837. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20838. v := m.updated_at
  20839. if v == nil {
  20840. return
  20841. }
  20842. return *v, true
  20843. }
  20844. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20845. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20847. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20848. if !m.op.Is(OpUpdateOne) {
  20849. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20850. }
  20851. if m.id == nil || m.oldValue == nil {
  20852. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20853. }
  20854. oldValue, err := m.oldValue(ctx)
  20855. if err != nil {
  20856. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20857. }
  20858. return oldValue.UpdatedAt, nil
  20859. }
  20860. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20861. func (m *SopNodeMutation) ResetUpdatedAt() {
  20862. m.updated_at = nil
  20863. }
  20864. // SetStatus sets the "status" field.
  20865. func (m *SopNodeMutation) SetStatus(u uint8) {
  20866. m.status = &u
  20867. m.addstatus = nil
  20868. }
  20869. // Status returns the value of the "status" field in the mutation.
  20870. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20871. v := m.status
  20872. if v == nil {
  20873. return
  20874. }
  20875. return *v, true
  20876. }
  20877. // OldStatus returns the old "status" field's value of the SopNode entity.
  20878. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20880. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20881. if !m.op.Is(OpUpdateOne) {
  20882. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20883. }
  20884. if m.id == nil || m.oldValue == nil {
  20885. return v, errors.New("OldStatus requires an ID field in the mutation")
  20886. }
  20887. oldValue, err := m.oldValue(ctx)
  20888. if err != nil {
  20889. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20890. }
  20891. return oldValue.Status, nil
  20892. }
  20893. // AddStatus adds u to the "status" field.
  20894. func (m *SopNodeMutation) AddStatus(u int8) {
  20895. if m.addstatus != nil {
  20896. *m.addstatus += u
  20897. } else {
  20898. m.addstatus = &u
  20899. }
  20900. }
  20901. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20902. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20903. v := m.addstatus
  20904. if v == nil {
  20905. return
  20906. }
  20907. return *v, true
  20908. }
  20909. // ClearStatus clears the value of the "status" field.
  20910. func (m *SopNodeMutation) ClearStatus() {
  20911. m.status = nil
  20912. m.addstatus = nil
  20913. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20914. }
  20915. // StatusCleared returns if the "status" field was cleared in this mutation.
  20916. func (m *SopNodeMutation) StatusCleared() bool {
  20917. _, ok := m.clearedFields[sopnode.FieldStatus]
  20918. return ok
  20919. }
  20920. // ResetStatus resets all changes to the "status" field.
  20921. func (m *SopNodeMutation) ResetStatus() {
  20922. m.status = nil
  20923. m.addstatus = nil
  20924. delete(m.clearedFields, sopnode.FieldStatus)
  20925. }
  20926. // SetDeletedAt sets the "deleted_at" field.
  20927. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20928. m.deleted_at = &t
  20929. }
  20930. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20931. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20932. v := m.deleted_at
  20933. if v == nil {
  20934. return
  20935. }
  20936. return *v, true
  20937. }
  20938. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  20939. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20941. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20942. if !m.op.Is(OpUpdateOne) {
  20943. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20944. }
  20945. if m.id == nil || m.oldValue == nil {
  20946. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20947. }
  20948. oldValue, err := m.oldValue(ctx)
  20949. if err != nil {
  20950. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20951. }
  20952. return oldValue.DeletedAt, nil
  20953. }
  20954. // ClearDeletedAt clears the value of the "deleted_at" field.
  20955. func (m *SopNodeMutation) ClearDeletedAt() {
  20956. m.deleted_at = nil
  20957. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  20958. }
  20959. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20960. func (m *SopNodeMutation) DeletedAtCleared() bool {
  20961. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  20962. return ok
  20963. }
  20964. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20965. func (m *SopNodeMutation) ResetDeletedAt() {
  20966. m.deleted_at = nil
  20967. delete(m.clearedFields, sopnode.FieldDeletedAt)
  20968. }
  20969. // SetStageID sets the "stage_id" field.
  20970. func (m *SopNodeMutation) SetStageID(u uint64) {
  20971. m.sop_stage = &u
  20972. }
  20973. // StageID returns the value of the "stage_id" field in the mutation.
  20974. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  20975. v := m.sop_stage
  20976. if v == nil {
  20977. return
  20978. }
  20979. return *v, true
  20980. }
  20981. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  20982. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20984. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  20985. if !m.op.Is(OpUpdateOne) {
  20986. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  20987. }
  20988. if m.id == nil || m.oldValue == nil {
  20989. return v, errors.New("OldStageID requires an ID field in the mutation")
  20990. }
  20991. oldValue, err := m.oldValue(ctx)
  20992. if err != nil {
  20993. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  20994. }
  20995. return oldValue.StageID, nil
  20996. }
  20997. // ResetStageID resets all changes to the "stage_id" field.
  20998. func (m *SopNodeMutation) ResetStageID() {
  20999. m.sop_stage = nil
  21000. }
  21001. // SetParentID sets the "parent_id" field.
  21002. func (m *SopNodeMutation) SetParentID(u uint64) {
  21003. m.parent_id = &u
  21004. m.addparent_id = nil
  21005. }
  21006. // ParentID returns the value of the "parent_id" field in the mutation.
  21007. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21008. v := m.parent_id
  21009. if v == nil {
  21010. return
  21011. }
  21012. return *v, true
  21013. }
  21014. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21015. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21017. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21018. if !m.op.Is(OpUpdateOne) {
  21019. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21020. }
  21021. if m.id == nil || m.oldValue == nil {
  21022. return v, errors.New("OldParentID requires an ID field in the mutation")
  21023. }
  21024. oldValue, err := m.oldValue(ctx)
  21025. if err != nil {
  21026. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21027. }
  21028. return oldValue.ParentID, nil
  21029. }
  21030. // AddParentID adds u to the "parent_id" field.
  21031. func (m *SopNodeMutation) AddParentID(u int64) {
  21032. if m.addparent_id != nil {
  21033. *m.addparent_id += u
  21034. } else {
  21035. m.addparent_id = &u
  21036. }
  21037. }
  21038. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21039. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21040. v := m.addparent_id
  21041. if v == nil {
  21042. return
  21043. }
  21044. return *v, true
  21045. }
  21046. // ResetParentID resets all changes to the "parent_id" field.
  21047. func (m *SopNodeMutation) ResetParentID() {
  21048. m.parent_id = nil
  21049. m.addparent_id = nil
  21050. }
  21051. // SetName sets the "name" field.
  21052. func (m *SopNodeMutation) SetName(s string) {
  21053. m.name = &s
  21054. }
  21055. // Name returns the value of the "name" field in the mutation.
  21056. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21057. v := m.name
  21058. if v == nil {
  21059. return
  21060. }
  21061. return *v, true
  21062. }
  21063. // OldName returns the old "name" field's value of the SopNode entity.
  21064. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21066. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21067. if !m.op.Is(OpUpdateOne) {
  21068. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21069. }
  21070. if m.id == nil || m.oldValue == nil {
  21071. return v, errors.New("OldName requires an ID field in the mutation")
  21072. }
  21073. oldValue, err := m.oldValue(ctx)
  21074. if err != nil {
  21075. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21076. }
  21077. return oldValue.Name, nil
  21078. }
  21079. // ResetName resets all changes to the "name" field.
  21080. func (m *SopNodeMutation) ResetName() {
  21081. m.name = nil
  21082. }
  21083. // SetConditionType sets the "condition_type" field.
  21084. func (m *SopNodeMutation) SetConditionType(i int) {
  21085. m.condition_type = &i
  21086. m.addcondition_type = nil
  21087. }
  21088. // ConditionType returns the value of the "condition_type" field in the mutation.
  21089. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21090. v := m.condition_type
  21091. if v == nil {
  21092. return
  21093. }
  21094. return *v, true
  21095. }
  21096. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21097. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21099. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21100. if !m.op.Is(OpUpdateOne) {
  21101. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21102. }
  21103. if m.id == nil || m.oldValue == nil {
  21104. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21105. }
  21106. oldValue, err := m.oldValue(ctx)
  21107. if err != nil {
  21108. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21109. }
  21110. return oldValue.ConditionType, nil
  21111. }
  21112. // AddConditionType adds i to the "condition_type" field.
  21113. func (m *SopNodeMutation) AddConditionType(i int) {
  21114. if m.addcondition_type != nil {
  21115. *m.addcondition_type += i
  21116. } else {
  21117. m.addcondition_type = &i
  21118. }
  21119. }
  21120. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21121. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21122. v := m.addcondition_type
  21123. if v == nil {
  21124. return
  21125. }
  21126. return *v, true
  21127. }
  21128. // ResetConditionType resets all changes to the "condition_type" field.
  21129. func (m *SopNodeMutation) ResetConditionType() {
  21130. m.condition_type = nil
  21131. m.addcondition_type = nil
  21132. }
  21133. // SetConditionList sets the "condition_list" field.
  21134. func (m *SopNodeMutation) SetConditionList(s []string) {
  21135. m.condition_list = &s
  21136. m.appendcondition_list = nil
  21137. }
  21138. // ConditionList returns the value of the "condition_list" field in the mutation.
  21139. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21140. v := m.condition_list
  21141. if v == nil {
  21142. return
  21143. }
  21144. return *v, true
  21145. }
  21146. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21147. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21149. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21150. if !m.op.Is(OpUpdateOne) {
  21151. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21152. }
  21153. if m.id == nil || m.oldValue == nil {
  21154. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21155. }
  21156. oldValue, err := m.oldValue(ctx)
  21157. if err != nil {
  21158. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21159. }
  21160. return oldValue.ConditionList, nil
  21161. }
  21162. // AppendConditionList adds s to the "condition_list" field.
  21163. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21164. m.appendcondition_list = append(m.appendcondition_list, s...)
  21165. }
  21166. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21167. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21168. if len(m.appendcondition_list) == 0 {
  21169. return nil, false
  21170. }
  21171. return m.appendcondition_list, true
  21172. }
  21173. // ClearConditionList clears the value of the "condition_list" field.
  21174. func (m *SopNodeMutation) ClearConditionList() {
  21175. m.condition_list = nil
  21176. m.appendcondition_list = nil
  21177. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21178. }
  21179. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21180. func (m *SopNodeMutation) ConditionListCleared() bool {
  21181. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21182. return ok
  21183. }
  21184. // ResetConditionList resets all changes to the "condition_list" field.
  21185. func (m *SopNodeMutation) ResetConditionList() {
  21186. m.condition_list = nil
  21187. m.appendcondition_list = nil
  21188. delete(m.clearedFields, sopnode.FieldConditionList)
  21189. }
  21190. // SetNoReplyCondition sets the "no_reply_condition" field.
  21191. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21192. m.no_reply_condition = &u
  21193. m.addno_reply_condition = nil
  21194. }
  21195. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21196. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21197. v := m.no_reply_condition
  21198. if v == nil {
  21199. return
  21200. }
  21201. return *v, true
  21202. }
  21203. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21204. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21206. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21207. if !m.op.Is(OpUpdateOne) {
  21208. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21209. }
  21210. if m.id == nil || m.oldValue == nil {
  21211. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21212. }
  21213. oldValue, err := m.oldValue(ctx)
  21214. if err != nil {
  21215. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21216. }
  21217. return oldValue.NoReplyCondition, nil
  21218. }
  21219. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21220. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21221. if m.addno_reply_condition != nil {
  21222. *m.addno_reply_condition += u
  21223. } else {
  21224. m.addno_reply_condition = &u
  21225. }
  21226. }
  21227. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21228. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21229. v := m.addno_reply_condition
  21230. if v == nil {
  21231. return
  21232. }
  21233. return *v, true
  21234. }
  21235. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21236. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21237. m.no_reply_condition = nil
  21238. m.addno_reply_condition = nil
  21239. }
  21240. // SetNoReplyUnit sets the "no_reply_unit" field.
  21241. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21242. m.no_reply_unit = &s
  21243. }
  21244. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21245. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21246. v := m.no_reply_unit
  21247. if v == nil {
  21248. return
  21249. }
  21250. return *v, true
  21251. }
  21252. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21253. // If the SopNode 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 *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21256. if !m.op.Is(OpUpdateOne) {
  21257. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21258. }
  21259. if m.id == nil || m.oldValue == nil {
  21260. return v, errors.New("OldNoReplyUnit 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 OldNoReplyUnit: %w", err)
  21265. }
  21266. return oldValue.NoReplyUnit, nil
  21267. }
  21268. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21269. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21270. m.no_reply_unit = nil
  21271. }
  21272. // SetActionMessage sets the "action_message" field.
  21273. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21274. m.action_message = &ct
  21275. m.appendaction_message = nil
  21276. }
  21277. // ActionMessage returns the value of the "action_message" field in the mutation.
  21278. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21279. v := m.action_message
  21280. if v == nil {
  21281. return
  21282. }
  21283. return *v, true
  21284. }
  21285. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21286. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21288. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21289. if !m.op.Is(OpUpdateOne) {
  21290. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21291. }
  21292. if m.id == nil || m.oldValue == nil {
  21293. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21294. }
  21295. oldValue, err := m.oldValue(ctx)
  21296. if err != nil {
  21297. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21298. }
  21299. return oldValue.ActionMessage, nil
  21300. }
  21301. // AppendActionMessage adds ct to the "action_message" field.
  21302. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21303. m.appendaction_message = append(m.appendaction_message, ct...)
  21304. }
  21305. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21306. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21307. if len(m.appendaction_message) == 0 {
  21308. return nil, false
  21309. }
  21310. return m.appendaction_message, true
  21311. }
  21312. // ClearActionMessage clears the value of the "action_message" field.
  21313. func (m *SopNodeMutation) ClearActionMessage() {
  21314. m.action_message = nil
  21315. m.appendaction_message = nil
  21316. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21317. }
  21318. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21319. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21320. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21321. return ok
  21322. }
  21323. // ResetActionMessage resets all changes to the "action_message" field.
  21324. func (m *SopNodeMutation) ResetActionMessage() {
  21325. m.action_message = nil
  21326. m.appendaction_message = nil
  21327. delete(m.clearedFields, sopnode.FieldActionMessage)
  21328. }
  21329. // SetActionLabelAdd sets the "action_label_add" field.
  21330. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21331. m.action_label_add = &u
  21332. m.appendaction_label_add = nil
  21333. }
  21334. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21335. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21336. v := m.action_label_add
  21337. if v == nil {
  21338. return
  21339. }
  21340. return *v, true
  21341. }
  21342. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21343. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21345. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21346. if !m.op.Is(OpUpdateOne) {
  21347. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21348. }
  21349. if m.id == nil || m.oldValue == nil {
  21350. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21351. }
  21352. oldValue, err := m.oldValue(ctx)
  21353. if err != nil {
  21354. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21355. }
  21356. return oldValue.ActionLabelAdd, nil
  21357. }
  21358. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21359. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21360. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21361. }
  21362. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21363. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21364. if len(m.appendaction_label_add) == 0 {
  21365. return nil, false
  21366. }
  21367. return m.appendaction_label_add, true
  21368. }
  21369. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21370. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21371. m.action_label_add = nil
  21372. m.appendaction_label_add = nil
  21373. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21374. }
  21375. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21376. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21377. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21378. return ok
  21379. }
  21380. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21381. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21382. m.action_label_add = nil
  21383. m.appendaction_label_add = nil
  21384. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21385. }
  21386. // SetActionLabelDel sets the "action_label_del" field.
  21387. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21388. m.action_label_del = &u
  21389. m.appendaction_label_del = nil
  21390. }
  21391. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21392. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21393. v := m.action_label_del
  21394. if v == nil {
  21395. return
  21396. }
  21397. return *v, true
  21398. }
  21399. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21400. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21402. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21403. if !m.op.Is(OpUpdateOne) {
  21404. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21405. }
  21406. if m.id == nil || m.oldValue == nil {
  21407. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21408. }
  21409. oldValue, err := m.oldValue(ctx)
  21410. if err != nil {
  21411. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21412. }
  21413. return oldValue.ActionLabelDel, nil
  21414. }
  21415. // AppendActionLabelDel adds u to the "action_label_del" field.
  21416. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21417. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21418. }
  21419. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21420. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21421. if len(m.appendaction_label_del) == 0 {
  21422. return nil, false
  21423. }
  21424. return m.appendaction_label_del, true
  21425. }
  21426. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21427. func (m *SopNodeMutation) ClearActionLabelDel() {
  21428. m.action_label_del = nil
  21429. m.appendaction_label_del = nil
  21430. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21431. }
  21432. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21433. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21434. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21435. return ok
  21436. }
  21437. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21438. func (m *SopNodeMutation) ResetActionLabelDel() {
  21439. m.action_label_del = nil
  21440. m.appendaction_label_del = nil
  21441. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21442. }
  21443. // SetActionForward sets the "action_forward" field.
  21444. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21445. m.action_forward = &ctf
  21446. }
  21447. // ActionForward returns the value of the "action_forward" field in the mutation.
  21448. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21449. v := m.action_forward
  21450. if v == nil {
  21451. return
  21452. }
  21453. return *v, true
  21454. }
  21455. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21456. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21458. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21459. if !m.op.Is(OpUpdateOne) {
  21460. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21461. }
  21462. if m.id == nil || m.oldValue == nil {
  21463. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21464. }
  21465. oldValue, err := m.oldValue(ctx)
  21466. if err != nil {
  21467. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21468. }
  21469. return oldValue.ActionForward, nil
  21470. }
  21471. // ClearActionForward clears the value of the "action_forward" field.
  21472. func (m *SopNodeMutation) ClearActionForward() {
  21473. m.action_forward = nil
  21474. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21475. }
  21476. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21477. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21478. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21479. return ok
  21480. }
  21481. // ResetActionForward resets all changes to the "action_forward" field.
  21482. func (m *SopNodeMutation) ResetActionForward() {
  21483. m.action_forward = nil
  21484. delete(m.clearedFields, sopnode.FieldActionForward)
  21485. }
  21486. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21487. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21488. m.sop_stage = &id
  21489. }
  21490. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21491. func (m *SopNodeMutation) ClearSopStage() {
  21492. m.clearedsop_stage = true
  21493. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21494. }
  21495. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21496. func (m *SopNodeMutation) SopStageCleared() bool {
  21497. return m.clearedsop_stage
  21498. }
  21499. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21500. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21501. if m.sop_stage != nil {
  21502. return *m.sop_stage, true
  21503. }
  21504. return
  21505. }
  21506. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21507. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21508. // SopStageID instead. It exists only for internal usage by the builders.
  21509. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21510. if id := m.sop_stage; id != nil {
  21511. ids = append(ids, *id)
  21512. }
  21513. return
  21514. }
  21515. // ResetSopStage resets all changes to the "sop_stage" edge.
  21516. func (m *SopNodeMutation) ResetSopStage() {
  21517. m.sop_stage = nil
  21518. m.clearedsop_stage = false
  21519. }
  21520. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21521. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21522. if m.node_messages == nil {
  21523. m.node_messages = make(map[uint64]struct{})
  21524. }
  21525. for i := range ids {
  21526. m.node_messages[ids[i]] = struct{}{}
  21527. }
  21528. }
  21529. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21530. func (m *SopNodeMutation) ClearNodeMessages() {
  21531. m.clearednode_messages = true
  21532. }
  21533. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21534. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21535. return m.clearednode_messages
  21536. }
  21537. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21538. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21539. if m.removednode_messages == nil {
  21540. m.removednode_messages = make(map[uint64]struct{})
  21541. }
  21542. for i := range ids {
  21543. delete(m.node_messages, ids[i])
  21544. m.removednode_messages[ids[i]] = struct{}{}
  21545. }
  21546. }
  21547. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21548. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21549. for id := range m.removednode_messages {
  21550. ids = append(ids, id)
  21551. }
  21552. return
  21553. }
  21554. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21555. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21556. for id := range m.node_messages {
  21557. ids = append(ids, id)
  21558. }
  21559. return
  21560. }
  21561. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21562. func (m *SopNodeMutation) ResetNodeMessages() {
  21563. m.node_messages = nil
  21564. m.clearednode_messages = false
  21565. m.removednode_messages = nil
  21566. }
  21567. // Where appends a list predicates to the SopNodeMutation builder.
  21568. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21569. m.predicates = append(m.predicates, ps...)
  21570. }
  21571. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21572. // users can use type-assertion to append predicates that do not depend on any generated package.
  21573. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21574. p := make([]predicate.SopNode, len(ps))
  21575. for i := range ps {
  21576. p[i] = ps[i]
  21577. }
  21578. m.Where(p...)
  21579. }
  21580. // Op returns the operation name.
  21581. func (m *SopNodeMutation) Op() Op {
  21582. return m.op
  21583. }
  21584. // SetOp allows setting the mutation operation.
  21585. func (m *SopNodeMutation) SetOp(op Op) {
  21586. m.op = op
  21587. }
  21588. // Type returns the node type of this mutation (SopNode).
  21589. func (m *SopNodeMutation) Type() string {
  21590. return m.typ
  21591. }
  21592. // Fields returns all fields that were changed during this mutation. Note that in
  21593. // order to get all numeric fields that were incremented/decremented, call
  21594. // AddedFields().
  21595. func (m *SopNodeMutation) Fields() []string {
  21596. fields := make([]string, 0, 15)
  21597. if m.created_at != nil {
  21598. fields = append(fields, sopnode.FieldCreatedAt)
  21599. }
  21600. if m.updated_at != nil {
  21601. fields = append(fields, sopnode.FieldUpdatedAt)
  21602. }
  21603. if m.status != nil {
  21604. fields = append(fields, sopnode.FieldStatus)
  21605. }
  21606. if m.deleted_at != nil {
  21607. fields = append(fields, sopnode.FieldDeletedAt)
  21608. }
  21609. if m.sop_stage != nil {
  21610. fields = append(fields, sopnode.FieldStageID)
  21611. }
  21612. if m.parent_id != nil {
  21613. fields = append(fields, sopnode.FieldParentID)
  21614. }
  21615. if m.name != nil {
  21616. fields = append(fields, sopnode.FieldName)
  21617. }
  21618. if m.condition_type != nil {
  21619. fields = append(fields, sopnode.FieldConditionType)
  21620. }
  21621. if m.condition_list != nil {
  21622. fields = append(fields, sopnode.FieldConditionList)
  21623. }
  21624. if m.no_reply_condition != nil {
  21625. fields = append(fields, sopnode.FieldNoReplyCondition)
  21626. }
  21627. if m.no_reply_unit != nil {
  21628. fields = append(fields, sopnode.FieldNoReplyUnit)
  21629. }
  21630. if m.action_message != nil {
  21631. fields = append(fields, sopnode.FieldActionMessage)
  21632. }
  21633. if m.action_label_add != nil {
  21634. fields = append(fields, sopnode.FieldActionLabelAdd)
  21635. }
  21636. if m.action_label_del != nil {
  21637. fields = append(fields, sopnode.FieldActionLabelDel)
  21638. }
  21639. if m.action_forward != nil {
  21640. fields = append(fields, sopnode.FieldActionForward)
  21641. }
  21642. return fields
  21643. }
  21644. // Field returns the value of a field with the given name. The second boolean
  21645. // return value indicates that this field was not set, or was not defined in the
  21646. // schema.
  21647. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21648. switch name {
  21649. case sopnode.FieldCreatedAt:
  21650. return m.CreatedAt()
  21651. case sopnode.FieldUpdatedAt:
  21652. return m.UpdatedAt()
  21653. case sopnode.FieldStatus:
  21654. return m.Status()
  21655. case sopnode.FieldDeletedAt:
  21656. return m.DeletedAt()
  21657. case sopnode.FieldStageID:
  21658. return m.StageID()
  21659. case sopnode.FieldParentID:
  21660. return m.ParentID()
  21661. case sopnode.FieldName:
  21662. return m.Name()
  21663. case sopnode.FieldConditionType:
  21664. return m.ConditionType()
  21665. case sopnode.FieldConditionList:
  21666. return m.ConditionList()
  21667. case sopnode.FieldNoReplyCondition:
  21668. return m.NoReplyCondition()
  21669. case sopnode.FieldNoReplyUnit:
  21670. return m.NoReplyUnit()
  21671. case sopnode.FieldActionMessage:
  21672. return m.ActionMessage()
  21673. case sopnode.FieldActionLabelAdd:
  21674. return m.ActionLabelAdd()
  21675. case sopnode.FieldActionLabelDel:
  21676. return m.ActionLabelDel()
  21677. case sopnode.FieldActionForward:
  21678. return m.ActionForward()
  21679. }
  21680. return nil, false
  21681. }
  21682. // OldField returns the old value of the field from the database. An error is
  21683. // returned if the mutation operation is not UpdateOne, or the query to the
  21684. // database failed.
  21685. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21686. switch name {
  21687. case sopnode.FieldCreatedAt:
  21688. return m.OldCreatedAt(ctx)
  21689. case sopnode.FieldUpdatedAt:
  21690. return m.OldUpdatedAt(ctx)
  21691. case sopnode.FieldStatus:
  21692. return m.OldStatus(ctx)
  21693. case sopnode.FieldDeletedAt:
  21694. return m.OldDeletedAt(ctx)
  21695. case sopnode.FieldStageID:
  21696. return m.OldStageID(ctx)
  21697. case sopnode.FieldParentID:
  21698. return m.OldParentID(ctx)
  21699. case sopnode.FieldName:
  21700. return m.OldName(ctx)
  21701. case sopnode.FieldConditionType:
  21702. return m.OldConditionType(ctx)
  21703. case sopnode.FieldConditionList:
  21704. return m.OldConditionList(ctx)
  21705. case sopnode.FieldNoReplyCondition:
  21706. return m.OldNoReplyCondition(ctx)
  21707. case sopnode.FieldNoReplyUnit:
  21708. return m.OldNoReplyUnit(ctx)
  21709. case sopnode.FieldActionMessage:
  21710. return m.OldActionMessage(ctx)
  21711. case sopnode.FieldActionLabelAdd:
  21712. return m.OldActionLabelAdd(ctx)
  21713. case sopnode.FieldActionLabelDel:
  21714. return m.OldActionLabelDel(ctx)
  21715. case sopnode.FieldActionForward:
  21716. return m.OldActionForward(ctx)
  21717. }
  21718. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21719. }
  21720. // SetField sets the value of a field with the given name. It returns an error if
  21721. // the field is not defined in the schema, or if the type mismatched the field
  21722. // type.
  21723. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21724. switch name {
  21725. case sopnode.FieldCreatedAt:
  21726. v, ok := value.(time.Time)
  21727. if !ok {
  21728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21729. }
  21730. m.SetCreatedAt(v)
  21731. return nil
  21732. case sopnode.FieldUpdatedAt:
  21733. v, ok := value.(time.Time)
  21734. if !ok {
  21735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21736. }
  21737. m.SetUpdatedAt(v)
  21738. return nil
  21739. case sopnode.FieldStatus:
  21740. v, ok := value.(uint8)
  21741. if !ok {
  21742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21743. }
  21744. m.SetStatus(v)
  21745. return nil
  21746. case sopnode.FieldDeletedAt:
  21747. v, ok := value.(time.Time)
  21748. if !ok {
  21749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21750. }
  21751. m.SetDeletedAt(v)
  21752. return nil
  21753. case sopnode.FieldStageID:
  21754. v, ok := value.(uint64)
  21755. if !ok {
  21756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21757. }
  21758. m.SetStageID(v)
  21759. return nil
  21760. case sopnode.FieldParentID:
  21761. v, ok := value.(uint64)
  21762. if !ok {
  21763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21764. }
  21765. m.SetParentID(v)
  21766. return nil
  21767. case sopnode.FieldName:
  21768. v, ok := value.(string)
  21769. if !ok {
  21770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21771. }
  21772. m.SetName(v)
  21773. return nil
  21774. case sopnode.FieldConditionType:
  21775. v, ok := value.(int)
  21776. if !ok {
  21777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21778. }
  21779. m.SetConditionType(v)
  21780. return nil
  21781. case sopnode.FieldConditionList:
  21782. v, ok := value.([]string)
  21783. if !ok {
  21784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21785. }
  21786. m.SetConditionList(v)
  21787. return nil
  21788. case sopnode.FieldNoReplyCondition:
  21789. v, ok := value.(uint64)
  21790. if !ok {
  21791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21792. }
  21793. m.SetNoReplyCondition(v)
  21794. return nil
  21795. case sopnode.FieldNoReplyUnit:
  21796. v, ok := value.(string)
  21797. if !ok {
  21798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21799. }
  21800. m.SetNoReplyUnit(v)
  21801. return nil
  21802. case sopnode.FieldActionMessage:
  21803. v, ok := value.([]custom_types.Action)
  21804. if !ok {
  21805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21806. }
  21807. m.SetActionMessage(v)
  21808. return nil
  21809. case sopnode.FieldActionLabelAdd:
  21810. v, ok := value.([]uint64)
  21811. if !ok {
  21812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21813. }
  21814. m.SetActionLabelAdd(v)
  21815. return nil
  21816. case sopnode.FieldActionLabelDel:
  21817. v, ok := value.([]uint64)
  21818. if !ok {
  21819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21820. }
  21821. m.SetActionLabelDel(v)
  21822. return nil
  21823. case sopnode.FieldActionForward:
  21824. v, ok := value.(*custom_types.ActionForward)
  21825. if !ok {
  21826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21827. }
  21828. m.SetActionForward(v)
  21829. return nil
  21830. }
  21831. return fmt.Errorf("unknown SopNode field %s", name)
  21832. }
  21833. // AddedFields returns all numeric fields that were incremented/decremented during
  21834. // this mutation.
  21835. func (m *SopNodeMutation) AddedFields() []string {
  21836. var fields []string
  21837. if m.addstatus != nil {
  21838. fields = append(fields, sopnode.FieldStatus)
  21839. }
  21840. if m.addparent_id != nil {
  21841. fields = append(fields, sopnode.FieldParentID)
  21842. }
  21843. if m.addcondition_type != nil {
  21844. fields = append(fields, sopnode.FieldConditionType)
  21845. }
  21846. if m.addno_reply_condition != nil {
  21847. fields = append(fields, sopnode.FieldNoReplyCondition)
  21848. }
  21849. return fields
  21850. }
  21851. // AddedField returns the numeric value that was incremented/decremented on a field
  21852. // with the given name. The second boolean return value indicates that this field
  21853. // was not set, or was not defined in the schema.
  21854. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21855. switch name {
  21856. case sopnode.FieldStatus:
  21857. return m.AddedStatus()
  21858. case sopnode.FieldParentID:
  21859. return m.AddedParentID()
  21860. case sopnode.FieldConditionType:
  21861. return m.AddedConditionType()
  21862. case sopnode.FieldNoReplyCondition:
  21863. return m.AddedNoReplyCondition()
  21864. }
  21865. return nil, false
  21866. }
  21867. // AddField adds the value to the field with the given name. It returns an error if
  21868. // the field is not defined in the schema, or if the type mismatched the field
  21869. // type.
  21870. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21871. switch name {
  21872. case sopnode.FieldStatus:
  21873. v, ok := value.(int8)
  21874. if !ok {
  21875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21876. }
  21877. m.AddStatus(v)
  21878. return nil
  21879. case sopnode.FieldParentID:
  21880. v, ok := value.(int64)
  21881. if !ok {
  21882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21883. }
  21884. m.AddParentID(v)
  21885. return nil
  21886. case sopnode.FieldConditionType:
  21887. v, ok := value.(int)
  21888. if !ok {
  21889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21890. }
  21891. m.AddConditionType(v)
  21892. return nil
  21893. case sopnode.FieldNoReplyCondition:
  21894. v, ok := value.(int64)
  21895. if !ok {
  21896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21897. }
  21898. m.AddNoReplyCondition(v)
  21899. return nil
  21900. }
  21901. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21902. }
  21903. // ClearedFields returns all nullable fields that were cleared during this
  21904. // mutation.
  21905. func (m *SopNodeMutation) ClearedFields() []string {
  21906. var fields []string
  21907. if m.FieldCleared(sopnode.FieldStatus) {
  21908. fields = append(fields, sopnode.FieldStatus)
  21909. }
  21910. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21911. fields = append(fields, sopnode.FieldDeletedAt)
  21912. }
  21913. if m.FieldCleared(sopnode.FieldConditionList) {
  21914. fields = append(fields, sopnode.FieldConditionList)
  21915. }
  21916. if m.FieldCleared(sopnode.FieldActionMessage) {
  21917. fields = append(fields, sopnode.FieldActionMessage)
  21918. }
  21919. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21920. fields = append(fields, sopnode.FieldActionLabelAdd)
  21921. }
  21922. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21923. fields = append(fields, sopnode.FieldActionLabelDel)
  21924. }
  21925. if m.FieldCleared(sopnode.FieldActionForward) {
  21926. fields = append(fields, sopnode.FieldActionForward)
  21927. }
  21928. return fields
  21929. }
  21930. // FieldCleared returns a boolean indicating if a field with the given name was
  21931. // cleared in this mutation.
  21932. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21933. _, ok := m.clearedFields[name]
  21934. return ok
  21935. }
  21936. // ClearField clears the value of the field with the given name. It returns an
  21937. // error if the field is not defined in the schema.
  21938. func (m *SopNodeMutation) ClearField(name string) error {
  21939. switch name {
  21940. case sopnode.FieldStatus:
  21941. m.ClearStatus()
  21942. return nil
  21943. case sopnode.FieldDeletedAt:
  21944. m.ClearDeletedAt()
  21945. return nil
  21946. case sopnode.FieldConditionList:
  21947. m.ClearConditionList()
  21948. return nil
  21949. case sopnode.FieldActionMessage:
  21950. m.ClearActionMessage()
  21951. return nil
  21952. case sopnode.FieldActionLabelAdd:
  21953. m.ClearActionLabelAdd()
  21954. return nil
  21955. case sopnode.FieldActionLabelDel:
  21956. m.ClearActionLabelDel()
  21957. return nil
  21958. case sopnode.FieldActionForward:
  21959. m.ClearActionForward()
  21960. return nil
  21961. }
  21962. return fmt.Errorf("unknown SopNode nullable field %s", name)
  21963. }
  21964. // ResetField resets all changes in the mutation for the field with the given name.
  21965. // It returns an error if the field is not defined in the schema.
  21966. func (m *SopNodeMutation) ResetField(name string) error {
  21967. switch name {
  21968. case sopnode.FieldCreatedAt:
  21969. m.ResetCreatedAt()
  21970. return nil
  21971. case sopnode.FieldUpdatedAt:
  21972. m.ResetUpdatedAt()
  21973. return nil
  21974. case sopnode.FieldStatus:
  21975. m.ResetStatus()
  21976. return nil
  21977. case sopnode.FieldDeletedAt:
  21978. m.ResetDeletedAt()
  21979. return nil
  21980. case sopnode.FieldStageID:
  21981. m.ResetStageID()
  21982. return nil
  21983. case sopnode.FieldParentID:
  21984. m.ResetParentID()
  21985. return nil
  21986. case sopnode.FieldName:
  21987. m.ResetName()
  21988. return nil
  21989. case sopnode.FieldConditionType:
  21990. m.ResetConditionType()
  21991. return nil
  21992. case sopnode.FieldConditionList:
  21993. m.ResetConditionList()
  21994. return nil
  21995. case sopnode.FieldNoReplyCondition:
  21996. m.ResetNoReplyCondition()
  21997. return nil
  21998. case sopnode.FieldNoReplyUnit:
  21999. m.ResetNoReplyUnit()
  22000. return nil
  22001. case sopnode.FieldActionMessage:
  22002. m.ResetActionMessage()
  22003. return nil
  22004. case sopnode.FieldActionLabelAdd:
  22005. m.ResetActionLabelAdd()
  22006. return nil
  22007. case sopnode.FieldActionLabelDel:
  22008. m.ResetActionLabelDel()
  22009. return nil
  22010. case sopnode.FieldActionForward:
  22011. m.ResetActionForward()
  22012. return nil
  22013. }
  22014. return fmt.Errorf("unknown SopNode field %s", name)
  22015. }
  22016. // AddedEdges returns all edge names that were set/added in this mutation.
  22017. func (m *SopNodeMutation) AddedEdges() []string {
  22018. edges := make([]string, 0, 2)
  22019. if m.sop_stage != nil {
  22020. edges = append(edges, sopnode.EdgeSopStage)
  22021. }
  22022. if m.node_messages != nil {
  22023. edges = append(edges, sopnode.EdgeNodeMessages)
  22024. }
  22025. return edges
  22026. }
  22027. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22028. // name in this mutation.
  22029. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22030. switch name {
  22031. case sopnode.EdgeSopStage:
  22032. if id := m.sop_stage; id != nil {
  22033. return []ent.Value{*id}
  22034. }
  22035. case sopnode.EdgeNodeMessages:
  22036. ids := make([]ent.Value, 0, len(m.node_messages))
  22037. for id := range m.node_messages {
  22038. ids = append(ids, id)
  22039. }
  22040. return ids
  22041. }
  22042. return nil
  22043. }
  22044. // RemovedEdges returns all edge names that were removed in this mutation.
  22045. func (m *SopNodeMutation) RemovedEdges() []string {
  22046. edges := make([]string, 0, 2)
  22047. if m.removednode_messages != nil {
  22048. edges = append(edges, sopnode.EdgeNodeMessages)
  22049. }
  22050. return edges
  22051. }
  22052. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22053. // the given name in this mutation.
  22054. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22055. switch name {
  22056. case sopnode.EdgeNodeMessages:
  22057. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22058. for id := range m.removednode_messages {
  22059. ids = append(ids, id)
  22060. }
  22061. return ids
  22062. }
  22063. return nil
  22064. }
  22065. // ClearedEdges returns all edge names that were cleared in this mutation.
  22066. func (m *SopNodeMutation) ClearedEdges() []string {
  22067. edges := make([]string, 0, 2)
  22068. if m.clearedsop_stage {
  22069. edges = append(edges, sopnode.EdgeSopStage)
  22070. }
  22071. if m.clearednode_messages {
  22072. edges = append(edges, sopnode.EdgeNodeMessages)
  22073. }
  22074. return edges
  22075. }
  22076. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22077. // was cleared in this mutation.
  22078. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22079. switch name {
  22080. case sopnode.EdgeSopStage:
  22081. return m.clearedsop_stage
  22082. case sopnode.EdgeNodeMessages:
  22083. return m.clearednode_messages
  22084. }
  22085. return false
  22086. }
  22087. // ClearEdge clears the value of the edge with the given name. It returns an error
  22088. // if that edge is not defined in the schema.
  22089. func (m *SopNodeMutation) ClearEdge(name string) error {
  22090. switch name {
  22091. case sopnode.EdgeSopStage:
  22092. m.ClearSopStage()
  22093. return nil
  22094. }
  22095. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22096. }
  22097. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22098. // It returns an error if the edge is not defined in the schema.
  22099. func (m *SopNodeMutation) ResetEdge(name string) error {
  22100. switch name {
  22101. case sopnode.EdgeSopStage:
  22102. m.ResetSopStage()
  22103. return nil
  22104. case sopnode.EdgeNodeMessages:
  22105. m.ResetNodeMessages()
  22106. return nil
  22107. }
  22108. return fmt.Errorf("unknown SopNode edge %s", name)
  22109. }
  22110. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22111. type SopStageMutation struct {
  22112. config
  22113. op Op
  22114. typ string
  22115. id *uint64
  22116. created_at *time.Time
  22117. updated_at *time.Time
  22118. status *uint8
  22119. addstatus *int8
  22120. deleted_at *time.Time
  22121. name *string
  22122. condition_type *int
  22123. addcondition_type *int
  22124. condition_operator *int
  22125. addcondition_operator *int
  22126. condition_list *[]custom_types.Condition
  22127. appendcondition_list []custom_types.Condition
  22128. action_message *[]custom_types.Action
  22129. appendaction_message []custom_types.Action
  22130. action_label_add *[]uint64
  22131. appendaction_label_add []uint64
  22132. action_label_del *[]uint64
  22133. appendaction_label_del []uint64
  22134. action_forward **custom_types.ActionForward
  22135. index_sort *int
  22136. addindex_sort *int
  22137. clearedFields map[string]struct{}
  22138. sop_task *uint64
  22139. clearedsop_task bool
  22140. stage_nodes map[uint64]struct{}
  22141. removedstage_nodes map[uint64]struct{}
  22142. clearedstage_nodes bool
  22143. stage_messages map[uint64]struct{}
  22144. removedstage_messages map[uint64]struct{}
  22145. clearedstage_messages bool
  22146. done bool
  22147. oldValue func(context.Context) (*SopStage, error)
  22148. predicates []predicate.SopStage
  22149. }
  22150. var _ ent.Mutation = (*SopStageMutation)(nil)
  22151. // sopstageOption allows management of the mutation configuration using functional options.
  22152. type sopstageOption func(*SopStageMutation)
  22153. // newSopStageMutation creates new mutation for the SopStage entity.
  22154. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22155. m := &SopStageMutation{
  22156. config: c,
  22157. op: op,
  22158. typ: TypeSopStage,
  22159. clearedFields: make(map[string]struct{}),
  22160. }
  22161. for _, opt := range opts {
  22162. opt(m)
  22163. }
  22164. return m
  22165. }
  22166. // withSopStageID sets the ID field of the mutation.
  22167. func withSopStageID(id uint64) sopstageOption {
  22168. return func(m *SopStageMutation) {
  22169. var (
  22170. err error
  22171. once sync.Once
  22172. value *SopStage
  22173. )
  22174. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22175. once.Do(func() {
  22176. if m.done {
  22177. err = errors.New("querying old values post mutation is not allowed")
  22178. } else {
  22179. value, err = m.Client().SopStage.Get(ctx, id)
  22180. }
  22181. })
  22182. return value, err
  22183. }
  22184. m.id = &id
  22185. }
  22186. }
  22187. // withSopStage sets the old SopStage of the mutation.
  22188. func withSopStage(node *SopStage) sopstageOption {
  22189. return func(m *SopStageMutation) {
  22190. m.oldValue = func(context.Context) (*SopStage, error) {
  22191. return node, nil
  22192. }
  22193. m.id = &node.ID
  22194. }
  22195. }
  22196. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22197. // executed in a transaction (ent.Tx), a transactional client is returned.
  22198. func (m SopStageMutation) Client() *Client {
  22199. client := &Client{config: m.config}
  22200. client.init()
  22201. return client
  22202. }
  22203. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22204. // it returns an error otherwise.
  22205. func (m SopStageMutation) Tx() (*Tx, error) {
  22206. if _, ok := m.driver.(*txDriver); !ok {
  22207. return nil, errors.New("ent: mutation is not running in a transaction")
  22208. }
  22209. tx := &Tx{config: m.config}
  22210. tx.init()
  22211. return tx, nil
  22212. }
  22213. // SetID sets the value of the id field. Note that this
  22214. // operation is only accepted on creation of SopStage entities.
  22215. func (m *SopStageMutation) SetID(id uint64) {
  22216. m.id = &id
  22217. }
  22218. // ID returns the ID value in the mutation. Note that the ID is only available
  22219. // if it was provided to the builder or after it was returned from the database.
  22220. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22221. if m.id == nil {
  22222. return
  22223. }
  22224. return *m.id, true
  22225. }
  22226. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22227. // That means, if the mutation is applied within a transaction with an isolation level such
  22228. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22229. // or updated by the mutation.
  22230. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22231. switch {
  22232. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22233. id, exists := m.ID()
  22234. if exists {
  22235. return []uint64{id}, nil
  22236. }
  22237. fallthrough
  22238. case m.op.Is(OpUpdate | OpDelete):
  22239. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22240. default:
  22241. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22242. }
  22243. }
  22244. // SetCreatedAt sets the "created_at" field.
  22245. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22246. m.created_at = &t
  22247. }
  22248. // CreatedAt returns the value of the "created_at" field in the mutation.
  22249. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22250. v := m.created_at
  22251. if v == nil {
  22252. return
  22253. }
  22254. return *v, true
  22255. }
  22256. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22257. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22259. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22260. if !m.op.Is(OpUpdateOne) {
  22261. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22262. }
  22263. if m.id == nil || m.oldValue == nil {
  22264. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22265. }
  22266. oldValue, err := m.oldValue(ctx)
  22267. if err != nil {
  22268. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22269. }
  22270. return oldValue.CreatedAt, nil
  22271. }
  22272. // ResetCreatedAt resets all changes to the "created_at" field.
  22273. func (m *SopStageMutation) ResetCreatedAt() {
  22274. m.created_at = nil
  22275. }
  22276. // SetUpdatedAt sets the "updated_at" field.
  22277. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22278. m.updated_at = &t
  22279. }
  22280. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22281. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22282. v := m.updated_at
  22283. if v == nil {
  22284. return
  22285. }
  22286. return *v, true
  22287. }
  22288. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22289. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22291. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22292. if !m.op.Is(OpUpdateOne) {
  22293. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22294. }
  22295. if m.id == nil || m.oldValue == nil {
  22296. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22297. }
  22298. oldValue, err := m.oldValue(ctx)
  22299. if err != nil {
  22300. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22301. }
  22302. return oldValue.UpdatedAt, nil
  22303. }
  22304. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22305. func (m *SopStageMutation) ResetUpdatedAt() {
  22306. m.updated_at = nil
  22307. }
  22308. // SetStatus sets the "status" field.
  22309. func (m *SopStageMutation) SetStatus(u uint8) {
  22310. m.status = &u
  22311. m.addstatus = nil
  22312. }
  22313. // Status returns the value of the "status" field in the mutation.
  22314. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22315. v := m.status
  22316. if v == nil {
  22317. return
  22318. }
  22319. return *v, true
  22320. }
  22321. // OldStatus returns the old "status" field's value of the SopStage entity.
  22322. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22324. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22325. if !m.op.Is(OpUpdateOne) {
  22326. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22327. }
  22328. if m.id == nil || m.oldValue == nil {
  22329. return v, errors.New("OldStatus requires an ID field in the mutation")
  22330. }
  22331. oldValue, err := m.oldValue(ctx)
  22332. if err != nil {
  22333. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22334. }
  22335. return oldValue.Status, nil
  22336. }
  22337. // AddStatus adds u to the "status" field.
  22338. func (m *SopStageMutation) AddStatus(u int8) {
  22339. if m.addstatus != nil {
  22340. *m.addstatus += u
  22341. } else {
  22342. m.addstatus = &u
  22343. }
  22344. }
  22345. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22346. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22347. v := m.addstatus
  22348. if v == nil {
  22349. return
  22350. }
  22351. return *v, true
  22352. }
  22353. // ClearStatus clears the value of the "status" field.
  22354. func (m *SopStageMutation) ClearStatus() {
  22355. m.status = nil
  22356. m.addstatus = nil
  22357. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22358. }
  22359. // StatusCleared returns if the "status" field was cleared in this mutation.
  22360. func (m *SopStageMutation) StatusCleared() bool {
  22361. _, ok := m.clearedFields[sopstage.FieldStatus]
  22362. return ok
  22363. }
  22364. // ResetStatus resets all changes to the "status" field.
  22365. func (m *SopStageMutation) ResetStatus() {
  22366. m.status = nil
  22367. m.addstatus = nil
  22368. delete(m.clearedFields, sopstage.FieldStatus)
  22369. }
  22370. // SetDeletedAt sets the "deleted_at" field.
  22371. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22372. m.deleted_at = &t
  22373. }
  22374. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22375. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22376. v := m.deleted_at
  22377. if v == nil {
  22378. return
  22379. }
  22380. return *v, true
  22381. }
  22382. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22383. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22385. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22386. if !m.op.Is(OpUpdateOne) {
  22387. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22388. }
  22389. if m.id == nil || m.oldValue == nil {
  22390. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22391. }
  22392. oldValue, err := m.oldValue(ctx)
  22393. if err != nil {
  22394. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22395. }
  22396. return oldValue.DeletedAt, nil
  22397. }
  22398. // ClearDeletedAt clears the value of the "deleted_at" field.
  22399. func (m *SopStageMutation) ClearDeletedAt() {
  22400. m.deleted_at = nil
  22401. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22402. }
  22403. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22404. func (m *SopStageMutation) DeletedAtCleared() bool {
  22405. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22406. return ok
  22407. }
  22408. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22409. func (m *SopStageMutation) ResetDeletedAt() {
  22410. m.deleted_at = nil
  22411. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22412. }
  22413. // SetTaskID sets the "task_id" field.
  22414. func (m *SopStageMutation) SetTaskID(u uint64) {
  22415. m.sop_task = &u
  22416. }
  22417. // TaskID returns the value of the "task_id" field in the mutation.
  22418. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22419. v := m.sop_task
  22420. if v == nil {
  22421. return
  22422. }
  22423. return *v, true
  22424. }
  22425. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22426. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22428. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22429. if !m.op.Is(OpUpdateOne) {
  22430. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22431. }
  22432. if m.id == nil || m.oldValue == nil {
  22433. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22434. }
  22435. oldValue, err := m.oldValue(ctx)
  22436. if err != nil {
  22437. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22438. }
  22439. return oldValue.TaskID, nil
  22440. }
  22441. // ResetTaskID resets all changes to the "task_id" field.
  22442. func (m *SopStageMutation) ResetTaskID() {
  22443. m.sop_task = nil
  22444. }
  22445. // SetName sets the "name" field.
  22446. func (m *SopStageMutation) SetName(s string) {
  22447. m.name = &s
  22448. }
  22449. // Name returns the value of the "name" field in the mutation.
  22450. func (m *SopStageMutation) Name() (r string, exists bool) {
  22451. v := m.name
  22452. if v == nil {
  22453. return
  22454. }
  22455. return *v, true
  22456. }
  22457. // OldName returns the old "name" field's value of the SopStage entity.
  22458. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22460. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22461. if !m.op.Is(OpUpdateOne) {
  22462. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22463. }
  22464. if m.id == nil || m.oldValue == nil {
  22465. return v, errors.New("OldName requires an ID field in the mutation")
  22466. }
  22467. oldValue, err := m.oldValue(ctx)
  22468. if err != nil {
  22469. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22470. }
  22471. return oldValue.Name, nil
  22472. }
  22473. // ResetName resets all changes to the "name" field.
  22474. func (m *SopStageMutation) ResetName() {
  22475. m.name = nil
  22476. }
  22477. // SetConditionType sets the "condition_type" field.
  22478. func (m *SopStageMutation) SetConditionType(i int) {
  22479. m.condition_type = &i
  22480. m.addcondition_type = nil
  22481. }
  22482. // ConditionType returns the value of the "condition_type" field in the mutation.
  22483. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22484. v := m.condition_type
  22485. if v == nil {
  22486. return
  22487. }
  22488. return *v, true
  22489. }
  22490. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22491. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22493. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22494. if !m.op.Is(OpUpdateOne) {
  22495. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22496. }
  22497. if m.id == nil || m.oldValue == nil {
  22498. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22499. }
  22500. oldValue, err := m.oldValue(ctx)
  22501. if err != nil {
  22502. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22503. }
  22504. return oldValue.ConditionType, nil
  22505. }
  22506. // AddConditionType adds i to the "condition_type" field.
  22507. func (m *SopStageMutation) AddConditionType(i int) {
  22508. if m.addcondition_type != nil {
  22509. *m.addcondition_type += i
  22510. } else {
  22511. m.addcondition_type = &i
  22512. }
  22513. }
  22514. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22515. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22516. v := m.addcondition_type
  22517. if v == nil {
  22518. return
  22519. }
  22520. return *v, true
  22521. }
  22522. // ResetConditionType resets all changes to the "condition_type" field.
  22523. func (m *SopStageMutation) ResetConditionType() {
  22524. m.condition_type = nil
  22525. m.addcondition_type = nil
  22526. }
  22527. // SetConditionOperator sets the "condition_operator" field.
  22528. func (m *SopStageMutation) SetConditionOperator(i int) {
  22529. m.condition_operator = &i
  22530. m.addcondition_operator = nil
  22531. }
  22532. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22533. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22534. v := m.condition_operator
  22535. if v == nil {
  22536. return
  22537. }
  22538. return *v, true
  22539. }
  22540. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22541. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22543. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22544. if !m.op.Is(OpUpdateOne) {
  22545. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22546. }
  22547. if m.id == nil || m.oldValue == nil {
  22548. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22549. }
  22550. oldValue, err := m.oldValue(ctx)
  22551. if err != nil {
  22552. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22553. }
  22554. return oldValue.ConditionOperator, nil
  22555. }
  22556. // AddConditionOperator adds i to the "condition_operator" field.
  22557. func (m *SopStageMutation) AddConditionOperator(i int) {
  22558. if m.addcondition_operator != nil {
  22559. *m.addcondition_operator += i
  22560. } else {
  22561. m.addcondition_operator = &i
  22562. }
  22563. }
  22564. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22565. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22566. v := m.addcondition_operator
  22567. if v == nil {
  22568. return
  22569. }
  22570. return *v, true
  22571. }
  22572. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22573. func (m *SopStageMutation) ResetConditionOperator() {
  22574. m.condition_operator = nil
  22575. m.addcondition_operator = nil
  22576. }
  22577. // SetConditionList sets the "condition_list" field.
  22578. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22579. m.condition_list = &ct
  22580. m.appendcondition_list = nil
  22581. }
  22582. // ConditionList returns the value of the "condition_list" field in the mutation.
  22583. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22584. v := m.condition_list
  22585. if v == nil {
  22586. return
  22587. }
  22588. return *v, true
  22589. }
  22590. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22591. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22593. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22594. if !m.op.Is(OpUpdateOne) {
  22595. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22596. }
  22597. if m.id == nil || m.oldValue == nil {
  22598. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22599. }
  22600. oldValue, err := m.oldValue(ctx)
  22601. if err != nil {
  22602. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22603. }
  22604. return oldValue.ConditionList, nil
  22605. }
  22606. // AppendConditionList adds ct to the "condition_list" field.
  22607. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22608. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22609. }
  22610. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22611. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22612. if len(m.appendcondition_list) == 0 {
  22613. return nil, false
  22614. }
  22615. return m.appendcondition_list, true
  22616. }
  22617. // ResetConditionList resets all changes to the "condition_list" field.
  22618. func (m *SopStageMutation) ResetConditionList() {
  22619. m.condition_list = nil
  22620. m.appendcondition_list = nil
  22621. }
  22622. // SetActionMessage sets the "action_message" field.
  22623. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22624. m.action_message = &ct
  22625. m.appendaction_message = nil
  22626. }
  22627. // ActionMessage returns the value of the "action_message" field in the mutation.
  22628. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22629. v := m.action_message
  22630. if v == nil {
  22631. return
  22632. }
  22633. return *v, true
  22634. }
  22635. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22636. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22638. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22639. if !m.op.Is(OpUpdateOne) {
  22640. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22641. }
  22642. if m.id == nil || m.oldValue == nil {
  22643. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22644. }
  22645. oldValue, err := m.oldValue(ctx)
  22646. if err != nil {
  22647. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22648. }
  22649. return oldValue.ActionMessage, nil
  22650. }
  22651. // AppendActionMessage adds ct to the "action_message" field.
  22652. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22653. m.appendaction_message = append(m.appendaction_message, ct...)
  22654. }
  22655. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22656. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22657. if len(m.appendaction_message) == 0 {
  22658. return nil, false
  22659. }
  22660. return m.appendaction_message, true
  22661. }
  22662. // ClearActionMessage clears the value of the "action_message" field.
  22663. func (m *SopStageMutation) ClearActionMessage() {
  22664. m.action_message = nil
  22665. m.appendaction_message = nil
  22666. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22667. }
  22668. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22669. func (m *SopStageMutation) ActionMessageCleared() bool {
  22670. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22671. return ok
  22672. }
  22673. // ResetActionMessage resets all changes to the "action_message" field.
  22674. func (m *SopStageMutation) ResetActionMessage() {
  22675. m.action_message = nil
  22676. m.appendaction_message = nil
  22677. delete(m.clearedFields, sopstage.FieldActionMessage)
  22678. }
  22679. // SetActionLabelAdd sets the "action_label_add" field.
  22680. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22681. m.action_label_add = &u
  22682. m.appendaction_label_add = nil
  22683. }
  22684. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22685. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22686. v := m.action_label_add
  22687. if v == nil {
  22688. return
  22689. }
  22690. return *v, true
  22691. }
  22692. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22693. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22695. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22696. if !m.op.Is(OpUpdateOne) {
  22697. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22698. }
  22699. if m.id == nil || m.oldValue == nil {
  22700. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22701. }
  22702. oldValue, err := m.oldValue(ctx)
  22703. if err != nil {
  22704. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22705. }
  22706. return oldValue.ActionLabelAdd, nil
  22707. }
  22708. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22709. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22710. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22711. }
  22712. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22713. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22714. if len(m.appendaction_label_add) == 0 {
  22715. return nil, false
  22716. }
  22717. return m.appendaction_label_add, true
  22718. }
  22719. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22720. func (m *SopStageMutation) ClearActionLabelAdd() {
  22721. m.action_label_add = nil
  22722. m.appendaction_label_add = nil
  22723. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22724. }
  22725. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22726. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22727. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22728. return ok
  22729. }
  22730. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22731. func (m *SopStageMutation) ResetActionLabelAdd() {
  22732. m.action_label_add = nil
  22733. m.appendaction_label_add = nil
  22734. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22735. }
  22736. // SetActionLabelDel sets the "action_label_del" field.
  22737. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22738. m.action_label_del = &u
  22739. m.appendaction_label_del = nil
  22740. }
  22741. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22742. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22743. v := m.action_label_del
  22744. if v == nil {
  22745. return
  22746. }
  22747. return *v, true
  22748. }
  22749. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22750. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22752. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22753. if !m.op.Is(OpUpdateOne) {
  22754. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22755. }
  22756. if m.id == nil || m.oldValue == nil {
  22757. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22758. }
  22759. oldValue, err := m.oldValue(ctx)
  22760. if err != nil {
  22761. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22762. }
  22763. return oldValue.ActionLabelDel, nil
  22764. }
  22765. // AppendActionLabelDel adds u to the "action_label_del" field.
  22766. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22767. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22768. }
  22769. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22770. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22771. if len(m.appendaction_label_del) == 0 {
  22772. return nil, false
  22773. }
  22774. return m.appendaction_label_del, true
  22775. }
  22776. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22777. func (m *SopStageMutation) ClearActionLabelDel() {
  22778. m.action_label_del = nil
  22779. m.appendaction_label_del = nil
  22780. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22781. }
  22782. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22783. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22784. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22785. return ok
  22786. }
  22787. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22788. func (m *SopStageMutation) ResetActionLabelDel() {
  22789. m.action_label_del = nil
  22790. m.appendaction_label_del = nil
  22791. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22792. }
  22793. // SetActionForward sets the "action_forward" field.
  22794. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22795. m.action_forward = &ctf
  22796. }
  22797. // ActionForward returns the value of the "action_forward" field in the mutation.
  22798. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22799. v := m.action_forward
  22800. if v == nil {
  22801. return
  22802. }
  22803. return *v, true
  22804. }
  22805. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22806. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22808. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22809. if !m.op.Is(OpUpdateOne) {
  22810. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22811. }
  22812. if m.id == nil || m.oldValue == nil {
  22813. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22814. }
  22815. oldValue, err := m.oldValue(ctx)
  22816. if err != nil {
  22817. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22818. }
  22819. return oldValue.ActionForward, nil
  22820. }
  22821. // ClearActionForward clears the value of the "action_forward" field.
  22822. func (m *SopStageMutation) ClearActionForward() {
  22823. m.action_forward = nil
  22824. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22825. }
  22826. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22827. func (m *SopStageMutation) ActionForwardCleared() bool {
  22828. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22829. return ok
  22830. }
  22831. // ResetActionForward resets all changes to the "action_forward" field.
  22832. func (m *SopStageMutation) ResetActionForward() {
  22833. m.action_forward = nil
  22834. delete(m.clearedFields, sopstage.FieldActionForward)
  22835. }
  22836. // SetIndexSort sets the "index_sort" field.
  22837. func (m *SopStageMutation) SetIndexSort(i int) {
  22838. m.index_sort = &i
  22839. m.addindex_sort = nil
  22840. }
  22841. // IndexSort returns the value of the "index_sort" field in the mutation.
  22842. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22843. v := m.index_sort
  22844. if v == nil {
  22845. return
  22846. }
  22847. return *v, true
  22848. }
  22849. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22850. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22852. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22853. if !m.op.Is(OpUpdateOne) {
  22854. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22855. }
  22856. if m.id == nil || m.oldValue == nil {
  22857. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22858. }
  22859. oldValue, err := m.oldValue(ctx)
  22860. if err != nil {
  22861. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22862. }
  22863. return oldValue.IndexSort, nil
  22864. }
  22865. // AddIndexSort adds i to the "index_sort" field.
  22866. func (m *SopStageMutation) AddIndexSort(i int) {
  22867. if m.addindex_sort != nil {
  22868. *m.addindex_sort += i
  22869. } else {
  22870. m.addindex_sort = &i
  22871. }
  22872. }
  22873. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22874. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22875. v := m.addindex_sort
  22876. if v == nil {
  22877. return
  22878. }
  22879. return *v, true
  22880. }
  22881. // ClearIndexSort clears the value of the "index_sort" field.
  22882. func (m *SopStageMutation) ClearIndexSort() {
  22883. m.index_sort = nil
  22884. m.addindex_sort = nil
  22885. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22886. }
  22887. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22888. func (m *SopStageMutation) IndexSortCleared() bool {
  22889. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22890. return ok
  22891. }
  22892. // ResetIndexSort resets all changes to the "index_sort" field.
  22893. func (m *SopStageMutation) ResetIndexSort() {
  22894. m.index_sort = nil
  22895. m.addindex_sort = nil
  22896. delete(m.clearedFields, sopstage.FieldIndexSort)
  22897. }
  22898. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22899. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22900. m.sop_task = &id
  22901. }
  22902. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22903. func (m *SopStageMutation) ClearSopTask() {
  22904. m.clearedsop_task = true
  22905. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22906. }
  22907. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22908. func (m *SopStageMutation) SopTaskCleared() bool {
  22909. return m.clearedsop_task
  22910. }
  22911. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22912. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22913. if m.sop_task != nil {
  22914. return *m.sop_task, true
  22915. }
  22916. return
  22917. }
  22918. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22919. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22920. // SopTaskID instead. It exists only for internal usage by the builders.
  22921. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22922. if id := m.sop_task; id != nil {
  22923. ids = append(ids, *id)
  22924. }
  22925. return
  22926. }
  22927. // ResetSopTask resets all changes to the "sop_task" edge.
  22928. func (m *SopStageMutation) ResetSopTask() {
  22929. m.sop_task = nil
  22930. m.clearedsop_task = false
  22931. }
  22932. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22933. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22934. if m.stage_nodes == nil {
  22935. m.stage_nodes = make(map[uint64]struct{})
  22936. }
  22937. for i := range ids {
  22938. m.stage_nodes[ids[i]] = struct{}{}
  22939. }
  22940. }
  22941. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  22942. func (m *SopStageMutation) ClearStageNodes() {
  22943. m.clearedstage_nodes = true
  22944. }
  22945. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  22946. func (m *SopStageMutation) StageNodesCleared() bool {
  22947. return m.clearedstage_nodes
  22948. }
  22949. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  22950. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  22951. if m.removedstage_nodes == nil {
  22952. m.removedstage_nodes = make(map[uint64]struct{})
  22953. }
  22954. for i := range ids {
  22955. delete(m.stage_nodes, ids[i])
  22956. m.removedstage_nodes[ids[i]] = struct{}{}
  22957. }
  22958. }
  22959. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  22960. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  22961. for id := range m.removedstage_nodes {
  22962. ids = append(ids, id)
  22963. }
  22964. return
  22965. }
  22966. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  22967. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  22968. for id := range m.stage_nodes {
  22969. ids = append(ids, id)
  22970. }
  22971. return
  22972. }
  22973. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  22974. func (m *SopStageMutation) ResetStageNodes() {
  22975. m.stage_nodes = nil
  22976. m.clearedstage_nodes = false
  22977. m.removedstage_nodes = nil
  22978. }
  22979. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  22980. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  22981. if m.stage_messages == nil {
  22982. m.stage_messages = make(map[uint64]struct{})
  22983. }
  22984. for i := range ids {
  22985. m.stage_messages[ids[i]] = struct{}{}
  22986. }
  22987. }
  22988. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  22989. func (m *SopStageMutation) ClearStageMessages() {
  22990. m.clearedstage_messages = true
  22991. }
  22992. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  22993. func (m *SopStageMutation) StageMessagesCleared() bool {
  22994. return m.clearedstage_messages
  22995. }
  22996. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  22997. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  22998. if m.removedstage_messages == nil {
  22999. m.removedstage_messages = make(map[uint64]struct{})
  23000. }
  23001. for i := range ids {
  23002. delete(m.stage_messages, ids[i])
  23003. m.removedstage_messages[ids[i]] = struct{}{}
  23004. }
  23005. }
  23006. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23007. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23008. for id := range m.removedstage_messages {
  23009. ids = append(ids, id)
  23010. }
  23011. return
  23012. }
  23013. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23014. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23015. for id := range m.stage_messages {
  23016. ids = append(ids, id)
  23017. }
  23018. return
  23019. }
  23020. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23021. func (m *SopStageMutation) ResetStageMessages() {
  23022. m.stage_messages = nil
  23023. m.clearedstage_messages = false
  23024. m.removedstage_messages = nil
  23025. }
  23026. // Where appends a list predicates to the SopStageMutation builder.
  23027. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23028. m.predicates = append(m.predicates, ps...)
  23029. }
  23030. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23031. // users can use type-assertion to append predicates that do not depend on any generated package.
  23032. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23033. p := make([]predicate.SopStage, len(ps))
  23034. for i := range ps {
  23035. p[i] = ps[i]
  23036. }
  23037. m.Where(p...)
  23038. }
  23039. // Op returns the operation name.
  23040. func (m *SopStageMutation) Op() Op {
  23041. return m.op
  23042. }
  23043. // SetOp allows setting the mutation operation.
  23044. func (m *SopStageMutation) SetOp(op Op) {
  23045. m.op = op
  23046. }
  23047. // Type returns the node type of this mutation (SopStage).
  23048. func (m *SopStageMutation) Type() string {
  23049. return m.typ
  23050. }
  23051. // Fields returns all fields that were changed during this mutation. Note that in
  23052. // order to get all numeric fields that were incremented/decremented, call
  23053. // AddedFields().
  23054. func (m *SopStageMutation) Fields() []string {
  23055. fields := make([]string, 0, 14)
  23056. if m.created_at != nil {
  23057. fields = append(fields, sopstage.FieldCreatedAt)
  23058. }
  23059. if m.updated_at != nil {
  23060. fields = append(fields, sopstage.FieldUpdatedAt)
  23061. }
  23062. if m.status != nil {
  23063. fields = append(fields, sopstage.FieldStatus)
  23064. }
  23065. if m.deleted_at != nil {
  23066. fields = append(fields, sopstage.FieldDeletedAt)
  23067. }
  23068. if m.sop_task != nil {
  23069. fields = append(fields, sopstage.FieldTaskID)
  23070. }
  23071. if m.name != nil {
  23072. fields = append(fields, sopstage.FieldName)
  23073. }
  23074. if m.condition_type != nil {
  23075. fields = append(fields, sopstage.FieldConditionType)
  23076. }
  23077. if m.condition_operator != nil {
  23078. fields = append(fields, sopstage.FieldConditionOperator)
  23079. }
  23080. if m.condition_list != nil {
  23081. fields = append(fields, sopstage.FieldConditionList)
  23082. }
  23083. if m.action_message != nil {
  23084. fields = append(fields, sopstage.FieldActionMessage)
  23085. }
  23086. if m.action_label_add != nil {
  23087. fields = append(fields, sopstage.FieldActionLabelAdd)
  23088. }
  23089. if m.action_label_del != nil {
  23090. fields = append(fields, sopstage.FieldActionLabelDel)
  23091. }
  23092. if m.action_forward != nil {
  23093. fields = append(fields, sopstage.FieldActionForward)
  23094. }
  23095. if m.index_sort != nil {
  23096. fields = append(fields, sopstage.FieldIndexSort)
  23097. }
  23098. return fields
  23099. }
  23100. // Field returns the value of a field with the given name. The second boolean
  23101. // return value indicates that this field was not set, or was not defined in the
  23102. // schema.
  23103. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23104. switch name {
  23105. case sopstage.FieldCreatedAt:
  23106. return m.CreatedAt()
  23107. case sopstage.FieldUpdatedAt:
  23108. return m.UpdatedAt()
  23109. case sopstage.FieldStatus:
  23110. return m.Status()
  23111. case sopstage.FieldDeletedAt:
  23112. return m.DeletedAt()
  23113. case sopstage.FieldTaskID:
  23114. return m.TaskID()
  23115. case sopstage.FieldName:
  23116. return m.Name()
  23117. case sopstage.FieldConditionType:
  23118. return m.ConditionType()
  23119. case sopstage.FieldConditionOperator:
  23120. return m.ConditionOperator()
  23121. case sopstage.FieldConditionList:
  23122. return m.ConditionList()
  23123. case sopstage.FieldActionMessage:
  23124. return m.ActionMessage()
  23125. case sopstage.FieldActionLabelAdd:
  23126. return m.ActionLabelAdd()
  23127. case sopstage.FieldActionLabelDel:
  23128. return m.ActionLabelDel()
  23129. case sopstage.FieldActionForward:
  23130. return m.ActionForward()
  23131. case sopstage.FieldIndexSort:
  23132. return m.IndexSort()
  23133. }
  23134. return nil, false
  23135. }
  23136. // OldField returns the old value of the field from the database. An error is
  23137. // returned if the mutation operation is not UpdateOne, or the query to the
  23138. // database failed.
  23139. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23140. switch name {
  23141. case sopstage.FieldCreatedAt:
  23142. return m.OldCreatedAt(ctx)
  23143. case sopstage.FieldUpdatedAt:
  23144. return m.OldUpdatedAt(ctx)
  23145. case sopstage.FieldStatus:
  23146. return m.OldStatus(ctx)
  23147. case sopstage.FieldDeletedAt:
  23148. return m.OldDeletedAt(ctx)
  23149. case sopstage.FieldTaskID:
  23150. return m.OldTaskID(ctx)
  23151. case sopstage.FieldName:
  23152. return m.OldName(ctx)
  23153. case sopstage.FieldConditionType:
  23154. return m.OldConditionType(ctx)
  23155. case sopstage.FieldConditionOperator:
  23156. return m.OldConditionOperator(ctx)
  23157. case sopstage.FieldConditionList:
  23158. return m.OldConditionList(ctx)
  23159. case sopstage.FieldActionMessage:
  23160. return m.OldActionMessage(ctx)
  23161. case sopstage.FieldActionLabelAdd:
  23162. return m.OldActionLabelAdd(ctx)
  23163. case sopstage.FieldActionLabelDel:
  23164. return m.OldActionLabelDel(ctx)
  23165. case sopstage.FieldActionForward:
  23166. return m.OldActionForward(ctx)
  23167. case sopstage.FieldIndexSort:
  23168. return m.OldIndexSort(ctx)
  23169. }
  23170. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23171. }
  23172. // SetField sets the value of a field with the given name. It returns an error if
  23173. // the field is not defined in the schema, or if the type mismatched the field
  23174. // type.
  23175. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23176. switch name {
  23177. case sopstage.FieldCreatedAt:
  23178. v, ok := value.(time.Time)
  23179. if !ok {
  23180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23181. }
  23182. m.SetCreatedAt(v)
  23183. return nil
  23184. case sopstage.FieldUpdatedAt:
  23185. v, ok := value.(time.Time)
  23186. if !ok {
  23187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23188. }
  23189. m.SetUpdatedAt(v)
  23190. return nil
  23191. case sopstage.FieldStatus:
  23192. v, ok := value.(uint8)
  23193. if !ok {
  23194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23195. }
  23196. m.SetStatus(v)
  23197. return nil
  23198. case sopstage.FieldDeletedAt:
  23199. v, ok := value.(time.Time)
  23200. if !ok {
  23201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23202. }
  23203. m.SetDeletedAt(v)
  23204. return nil
  23205. case sopstage.FieldTaskID:
  23206. v, ok := value.(uint64)
  23207. if !ok {
  23208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23209. }
  23210. m.SetTaskID(v)
  23211. return nil
  23212. case sopstage.FieldName:
  23213. v, ok := value.(string)
  23214. if !ok {
  23215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23216. }
  23217. m.SetName(v)
  23218. return nil
  23219. case sopstage.FieldConditionType:
  23220. v, ok := value.(int)
  23221. if !ok {
  23222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23223. }
  23224. m.SetConditionType(v)
  23225. return nil
  23226. case sopstage.FieldConditionOperator:
  23227. v, ok := value.(int)
  23228. if !ok {
  23229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23230. }
  23231. m.SetConditionOperator(v)
  23232. return nil
  23233. case sopstage.FieldConditionList:
  23234. v, ok := value.([]custom_types.Condition)
  23235. if !ok {
  23236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23237. }
  23238. m.SetConditionList(v)
  23239. return nil
  23240. case sopstage.FieldActionMessage:
  23241. v, ok := value.([]custom_types.Action)
  23242. if !ok {
  23243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23244. }
  23245. m.SetActionMessage(v)
  23246. return nil
  23247. case sopstage.FieldActionLabelAdd:
  23248. v, ok := value.([]uint64)
  23249. if !ok {
  23250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23251. }
  23252. m.SetActionLabelAdd(v)
  23253. return nil
  23254. case sopstage.FieldActionLabelDel:
  23255. v, ok := value.([]uint64)
  23256. if !ok {
  23257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23258. }
  23259. m.SetActionLabelDel(v)
  23260. return nil
  23261. case sopstage.FieldActionForward:
  23262. v, ok := value.(*custom_types.ActionForward)
  23263. if !ok {
  23264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23265. }
  23266. m.SetActionForward(v)
  23267. return nil
  23268. case sopstage.FieldIndexSort:
  23269. v, ok := value.(int)
  23270. if !ok {
  23271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23272. }
  23273. m.SetIndexSort(v)
  23274. return nil
  23275. }
  23276. return fmt.Errorf("unknown SopStage field %s", name)
  23277. }
  23278. // AddedFields returns all numeric fields that were incremented/decremented during
  23279. // this mutation.
  23280. func (m *SopStageMutation) AddedFields() []string {
  23281. var fields []string
  23282. if m.addstatus != nil {
  23283. fields = append(fields, sopstage.FieldStatus)
  23284. }
  23285. if m.addcondition_type != nil {
  23286. fields = append(fields, sopstage.FieldConditionType)
  23287. }
  23288. if m.addcondition_operator != nil {
  23289. fields = append(fields, sopstage.FieldConditionOperator)
  23290. }
  23291. if m.addindex_sort != nil {
  23292. fields = append(fields, sopstage.FieldIndexSort)
  23293. }
  23294. return fields
  23295. }
  23296. // AddedField returns the numeric value that was incremented/decremented on a field
  23297. // with the given name. The second boolean return value indicates that this field
  23298. // was not set, or was not defined in the schema.
  23299. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23300. switch name {
  23301. case sopstage.FieldStatus:
  23302. return m.AddedStatus()
  23303. case sopstage.FieldConditionType:
  23304. return m.AddedConditionType()
  23305. case sopstage.FieldConditionOperator:
  23306. return m.AddedConditionOperator()
  23307. case sopstage.FieldIndexSort:
  23308. return m.AddedIndexSort()
  23309. }
  23310. return nil, false
  23311. }
  23312. // AddField adds the value to the field with the given name. It returns an error if
  23313. // the field is not defined in the schema, or if the type mismatched the field
  23314. // type.
  23315. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23316. switch name {
  23317. case sopstage.FieldStatus:
  23318. v, ok := value.(int8)
  23319. if !ok {
  23320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23321. }
  23322. m.AddStatus(v)
  23323. return nil
  23324. case sopstage.FieldConditionType:
  23325. v, ok := value.(int)
  23326. if !ok {
  23327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23328. }
  23329. m.AddConditionType(v)
  23330. return nil
  23331. case sopstage.FieldConditionOperator:
  23332. v, ok := value.(int)
  23333. if !ok {
  23334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23335. }
  23336. m.AddConditionOperator(v)
  23337. return nil
  23338. case sopstage.FieldIndexSort:
  23339. v, ok := value.(int)
  23340. if !ok {
  23341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23342. }
  23343. m.AddIndexSort(v)
  23344. return nil
  23345. }
  23346. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23347. }
  23348. // ClearedFields returns all nullable fields that were cleared during this
  23349. // mutation.
  23350. func (m *SopStageMutation) ClearedFields() []string {
  23351. var fields []string
  23352. if m.FieldCleared(sopstage.FieldStatus) {
  23353. fields = append(fields, sopstage.FieldStatus)
  23354. }
  23355. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23356. fields = append(fields, sopstage.FieldDeletedAt)
  23357. }
  23358. if m.FieldCleared(sopstage.FieldActionMessage) {
  23359. fields = append(fields, sopstage.FieldActionMessage)
  23360. }
  23361. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23362. fields = append(fields, sopstage.FieldActionLabelAdd)
  23363. }
  23364. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23365. fields = append(fields, sopstage.FieldActionLabelDel)
  23366. }
  23367. if m.FieldCleared(sopstage.FieldActionForward) {
  23368. fields = append(fields, sopstage.FieldActionForward)
  23369. }
  23370. if m.FieldCleared(sopstage.FieldIndexSort) {
  23371. fields = append(fields, sopstage.FieldIndexSort)
  23372. }
  23373. return fields
  23374. }
  23375. // FieldCleared returns a boolean indicating if a field with the given name was
  23376. // cleared in this mutation.
  23377. func (m *SopStageMutation) FieldCleared(name string) bool {
  23378. _, ok := m.clearedFields[name]
  23379. return ok
  23380. }
  23381. // ClearField clears the value of the field with the given name. It returns an
  23382. // error if the field is not defined in the schema.
  23383. func (m *SopStageMutation) ClearField(name string) error {
  23384. switch name {
  23385. case sopstage.FieldStatus:
  23386. m.ClearStatus()
  23387. return nil
  23388. case sopstage.FieldDeletedAt:
  23389. m.ClearDeletedAt()
  23390. return nil
  23391. case sopstage.FieldActionMessage:
  23392. m.ClearActionMessage()
  23393. return nil
  23394. case sopstage.FieldActionLabelAdd:
  23395. m.ClearActionLabelAdd()
  23396. return nil
  23397. case sopstage.FieldActionLabelDel:
  23398. m.ClearActionLabelDel()
  23399. return nil
  23400. case sopstage.FieldActionForward:
  23401. m.ClearActionForward()
  23402. return nil
  23403. case sopstage.FieldIndexSort:
  23404. m.ClearIndexSort()
  23405. return nil
  23406. }
  23407. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23408. }
  23409. // ResetField resets all changes in the mutation for the field with the given name.
  23410. // It returns an error if the field is not defined in the schema.
  23411. func (m *SopStageMutation) ResetField(name string) error {
  23412. switch name {
  23413. case sopstage.FieldCreatedAt:
  23414. m.ResetCreatedAt()
  23415. return nil
  23416. case sopstage.FieldUpdatedAt:
  23417. m.ResetUpdatedAt()
  23418. return nil
  23419. case sopstage.FieldStatus:
  23420. m.ResetStatus()
  23421. return nil
  23422. case sopstage.FieldDeletedAt:
  23423. m.ResetDeletedAt()
  23424. return nil
  23425. case sopstage.FieldTaskID:
  23426. m.ResetTaskID()
  23427. return nil
  23428. case sopstage.FieldName:
  23429. m.ResetName()
  23430. return nil
  23431. case sopstage.FieldConditionType:
  23432. m.ResetConditionType()
  23433. return nil
  23434. case sopstage.FieldConditionOperator:
  23435. m.ResetConditionOperator()
  23436. return nil
  23437. case sopstage.FieldConditionList:
  23438. m.ResetConditionList()
  23439. return nil
  23440. case sopstage.FieldActionMessage:
  23441. m.ResetActionMessage()
  23442. return nil
  23443. case sopstage.FieldActionLabelAdd:
  23444. m.ResetActionLabelAdd()
  23445. return nil
  23446. case sopstage.FieldActionLabelDel:
  23447. m.ResetActionLabelDel()
  23448. return nil
  23449. case sopstage.FieldActionForward:
  23450. m.ResetActionForward()
  23451. return nil
  23452. case sopstage.FieldIndexSort:
  23453. m.ResetIndexSort()
  23454. return nil
  23455. }
  23456. return fmt.Errorf("unknown SopStage field %s", name)
  23457. }
  23458. // AddedEdges returns all edge names that were set/added in this mutation.
  23459. func (m *SopStageMutation) AddedEdges() []string {
  23460. edges := make([]string, 0, 3)
  23461. if m.sop_task != nil {
  23462. edges = append(edges, sopstage.EdgeSopTask)
  23463. }
  23464. if m.stage_nodes != nil {
  23465. edges = append(edges, sopstage.EdgeStageNodes)
  23466. }
  23467. if m.stage_messages != nil {
  23468. edges = append(edges, sopstage.EdgeStageMessages)
  23469. }
  23470. return edges
  23471. }
  23472. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23473. // name in this mutation.
  23474. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23475. switch name {
  23476. case sopstage.EdgeSopTask:
  23477. if id := m.sop_task; id != nil {
  23478. return []ent.Value{*id}
  23479. }
  23480. case sopstage.EdgeStageNodes:
  23481. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23482. for id := range m.stage_nodes {
  23483. ids = append(ids, id)
  23484. }
  23485. return ids
  23486. case sopstage.EdgeStageMessages:
  23487. ids := make([]ent.Value, 0, len(m.stage_messages))
  23488. for id := range m.stage_messages {
  23489. ids = append(ids, id)
  23490. }
  23491. return ids
  23492. }
  23493. return nil
  23494. }
  23495. // RemovedEdges returns all edge names that were removed in this mutation.
  23496. func (m *SopStageMutation) RemovedEdges() []string {
  23497. edges := make([]string, 0, 3)
  23498. if m.removedstage_nodes != nil {
  23499. edges = append(edges, sopstage.EdgeStageNodes)
  23500. }
  23501. if m.removedstage_messages != nil {
  23502. edges = append(edges, sopstage.EdgeStageMessages)
  23503. }
  23504. return edges
  23505. }
  23506. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23507. // the given name in this mutation.
  23508. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23509. switch name {
  23510. case sopstage.EdgeStageNodes:
  23511. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23512. for id := range m.removedstage_nodes {
  23513. ids = append(ids, id)
  23514. }
  23515. return ids
  23516. case sopstage.EdgeStageMessages:
  23517. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23518. for id := range m.removedstage_messages {
  23519. ids = append(ids, id)
  23520. }
  23521. return ids
  23522. }
  23523. return nil
  23524. }
  23525. // ClearedEdges returns all edge names that were cleared in this mutation.
  23526. func (m *SopStageMutation) ClearedEdges() []string {
  23527. edges := make([]string, 0, 3)
  23528. if m.clearedsop_task {
  23529. edges = append(edges, sopstage.EdgeSopTask)
  23530. }
  23531. if m.clearedstage_nodes {
  23532. edges = append(edges, sopstage.EdgeStageNodes)
  23533. }
  23534. if m.clearedstage_messages {
  23535. edges = append(edges, sopstage.EdgeStageMessages)
  23536. }
  23537. return edges
  23538. }
  23539. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23540. // was cleared in this mutation.
  23541. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23542. switch name {
  23543. case sopstage.EdgeSopTask:
  23544. return m.clearedsop_task
  23545. case sopstage.EdgeStageNodes:
  23546. return m.clearedstage_nodes
  23547. case sopstage.EdgeStageMessages:
  23548. return m.clearedstage_messages
  23549. }
  23550. return false
  23551. }
  23552. // ClearEdge clears the value of the edge with the given name. It returns an error
  23553. // if that edge is not defined in the schema.
  23554. func (m *SopStageMutation) ClearEdge(name string) error {
  23555. switch name {
  23556. case sopstage.EdgeSopTask:
  23557. m.ClearSopTask()
  23558. return nil
  23559. }
  23560. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23561. }
  23562. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23563. // It returns an error if the edge is not defined in the schema.
  23564. func (m *SopStageMutation) ResetEdge(name string) error {
  23565. switch name {
  23566. case sopstage.EdgeSopTask:
  23567. m.ResetSopTask()
  23568. return nil
  23569. case sopstage.EdgeStageNodes:
  23570. m.ResetStageNodes()
  23571. return nil
  23572. case sopstage.EdgeStageMessages:
  23573. m.ResetStageMessages()
  23574. return nil
  23575. }
  23576. return fmt.Errorf("unknown SopStage edge %s", name)
  23577. }
  23578. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23579. type SopTaskMutation struct {
  23580. config
  23581. op Op
  23582. typ string
  23583. id *uint64
  23584. created_at *time.Time
  23585. updated_at *time.Time
  23586. status *uint8
  23587. addstatus *int8
  23588. deleted_at *time.Time
  23589. name *string
  23590. bot_wxid_list *[]string
  23591. appendbot_wxid_list []string
  23592. _type *int
  23593. add_type *int
  23594. plan_start_time *time.Time
  23595. plan_end_time *time.Time
  23596. creator_id *string
  23597. organization_id *uint64
  23598. addorganization_id *int64
  23599. token *[]string
  23600. appendtoken []string
  23601. clearedFields map[string]struct{}
  23602. task_stages map[uint64]struct{}
  23603. removedtask_stages map[uint64]struct{}
  23604. clearedtask_stages bool
  23605. done bool
  23606. oldValue func(context.Context) (*SopTask, error)
  23607. predicates []predicate.SopTask
  23608. }
  23609. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23610. // soptaskOption allows management of the mutation configuration using functional options.
  23611. type soptaskOption func(*SopTaskMutation)
  23612. // newSopTaskMutation creates new mutation for the SopTask entity.
  23613. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23614. m := &SopTaskMutation{
  23615. config: c,
  23616. op: op,
  23617. typ: TypeSopTask,
  23618. clearedFields: make(map[string]struct{}),
  23619. }
  23620. for _, opt := range opts {
  23621. opt(m)
  23622. }
  23623. return m
  23624. }
  23625. // withSopTaskID sets the ID field of the mutation.
  23626. func withSopTaskID(id uint64) soptaskOption {
  23627. return func(m *SopTaskMutation) {
  23628. var (
  23629. err error
  23630. once sync.Once
  23631. value *SopTask
  23632. )
  23633. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23634. once.Do(func() {
  23635. if m.done {
  23636. err = errors.New("querying old values post mutation is not allowed")
  23637. } else {
  23638. value, err = m.Client().SopTask.Get(ctx, id)
  23639. }
  23640. })
  23641. return value, err
  23642. }
  23643. m.id = &id
  23644. }
  23645. }
  23646. // withSopTask sets the old SopTask of the mutation.
  23647. func withSopTask(node *SopTask) soptaskOption {
  23648. return func(m *SopTaskMutation) {
  23649. m.oldValue = func(context.Context) (*SopTask, error) {
  23650. return node, nil
  23651. }
  23652. m.id = &node.ID
  23653. }
  23654. }
  23655. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23656. // executed in a transaction (ent.Tx), a transactional client is returned.
  23657. func (m SopTaskMutation) Client() *Client {
  23658. client := &Client{config: m.config}
  23659. client.init()
  23660. return client
  23661. }
  23662. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23663. // it returns an error otherwise.
  23664. func (m SopTaskMutation) Tx() (*Tx, error) {
  23665. if _, ok := m.driver.(*txDriver); !ok {
  23666. return nil, errors.New("ent: mutation is not running in a transaction")
  23667. }
  23668. tx := &Tx{config: m.config}
  23669. tx.init()
  23670. return tx, nil
  23671. }
  23672. // SetID sets the value of the id field. Note that this
  23673. // operation is only accepted on creation of SopTask entities.
  23674. func (m *SopTaskMutation) SetID(id uint64) {
  23675. m.id = &id
  23676. }
  23677. // ID returns the ID value in the mutation. Note that the ID is only available
  23678. // if it was provided to the builder or after it was returned from the database.
  23679. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23680. if m.id == nil {
  23681. return
  23682. }
  23683. return *m.id, true
  23684. }
  23685. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23686. // That means, if the mutation is applied within a transaction with an isolation level such
  23687. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23688. // or updated by the mutation.
  23689. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23690. switch {
  23691. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23692. id, exists := m.ID()
  23693. if exists {
  23694. return []uint64{id}, nil
  23695. }
  23696. fallthrough
  23697. case m.op.Is(OpUpdate | OpDelete):
  23698. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23699. default:
  23700. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23701. }
  23702. }
  23703. // SetCreatedAt sets the "created_at" field.
  23704. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23705. m.created_at = &t
  23706. }
  23707. // CreatedAt returns the value of the "created_at" field in the mutation.
  23708. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23709. v := m.created_at
  23710. if v == nil {
  23711. return
  23712. }
  23713. return *v, true
  23714. }
  23715. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23716. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23718. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23719. if !m.op.Is(OpUpdateOne) {
  23720. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23721. }
  23722. if m.id == nil || m.oldValue == nil {
  23723. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23724. }
  23725. oldValue, err := m.oldValue(ctx)
  23726. if err != nil {
  23727. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23728. }
  23729. return oldValue.CreatedAt, nil
  23730. }
  23731. // ResetCreatedAt resets all changes to the "created_at" field.
  23732. func (m *SopTaskMutation) ResetCreatedAt() {
  23733. m.created_at = nil
  23734. }
  23735. // SetUpdatedAt sets the "updated_at" field.
  23736. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23737. m.updated_at = &t
  23738. }
  23739. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23740. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23741. v := m.updated_at
  23742. if v == nil {
  23743. return
  23744. }
  23745. return *v, true
  23746. }
  23747. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23748. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23750. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23751. if !m.op.Is(OpUpdateOne) {
  23752. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23753. }
  23754. if m.id == nil || m.oldValue == nil {
  23755. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23756. }
  23757. oldValue, err := m.oldValue(ctx)
  23758. if err != nil {
  23759. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23760. }
  23761. return oldValue.UpdatedAt, nil
  23762. }
  23763. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23764. func (m *SopTaskMutation) ResetUpdatedAt() {
  23765. m.updated_at = nil
  23766. }
  23767. // SetStatus sets the "status" field.
  23768. func (m *SopTaskMutation) SetStatus(u uint8) {
  23769. m.status = &u
  23770. m.addstatus = nil
  23771. }
  23772. // Status returns the value of the "status" field in the mutation.
  23773. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23774. v := m.status
  23775. if v == nil {
  23776. return
  23777. }
  23778. return *v, true
  23779. }
  23780. // OldStatus returns the old "status" field's value of the SopTask entity.
  23781. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23783. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23784. if !m.op.Is(OpUpdateOne) {
  23785. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23786. }
  23787. if m.id == nil || m.oldValue == nil {
  23788. return v, errors.New("OldStatus requires an ID field in the mutation")
  23789. }
  23790. oldValue, err := m.oldValue(ctx)
  23791. if err != nil {
  23792. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23793. }
  23794. return oldValue.Status, nil
  23795. }
  23796. // AddStatus adds u to the "status" field.
  23797. func (m *SopTaskMutation) AddStatus(u int8) {
  23798. if m.addstatus != nil {
  23799. *m.addstatus += u
  23800. } else {
  23801. m.addstatus = &u
  23802. }
  23803. }
  23804. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23805. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23806. v := m.addstatus
  23807. if v == nil {
  23808. return
  23809. }
  23810. return *v, true
  23811. }
  23812. // ClearStatus clears the value of the "status" field.
  23813. func (m *SopTaskMutation) ClearStatus() {
  23814. m.status = nil
  23815. m.addstatus = nil
  23816. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23817. }
  23818. // StatusCleared returns if the "status" field was cleared in this mutation.
  23819. func (m *SopTaskMutation) StatusCleared() bool {
  23820. _, ok := m.clearedFields[soptask.FieldStatus]
  23821. return ok
  23822. }
  23823. // ResetStatus resets all changes to the "status" field.
  23824. func (m *SopTaskMutation) ResetStatus() {
  23825. m.status = nil
  23826. m.addstatus = nil
  23827. delete(m.clearedFields, soptask.FieldStatus)
  23828. }
  23829. // SetDeletedAt sets the "deleted_at" field.
  23830. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23831. m.deleted_at = &t
  23832. }
  23833. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23834. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23835. v := m.deleted_at
  23836. if v == nil {
  23837. return
  23838. }
  23839. return *v, true
  23840. }
  23841. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23842. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23844. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23845. if !m.op.Is(OpUpdateOne) {
  23846. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23847. }
  23848. if m.id == nil || m.oldValue == nil {
  23849. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23850. }
  23851. oldValue, err := m.oldValue(ctx)
  23852. if err != nil {
  23853. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23854. }
  23855. return oldValue.DeletedAt, nil
  23856. }
  23857. // ClearDeletedAt clears the value of the "deleted_at" field.
  23858. func (m *SopTaskMutation) ClearDeletedAt() {
  23859. m.deleted_at = nil
  23860. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23861. }
  23862. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23863. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23864. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23865. return ok
  23866. }
  23867. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23868. func (m *SopTaskMutation) ResetDeletedAt() {
  23869. m.deleted_at = nil
  23870. delete(m.clearedFields, soptask.FieldDeletedAt)
  23871. }
  23872. // SetName sets the "name" field.
  23873. func (m *SopTaskMutation) SetName(s string) {
  23874. m.name = &s
  23875. }
  23876. // Name returns the value of the "name" field in the mutation.
  23877. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23878. v := m.name
  23879. if v == nil {
  23880. return
  23881. }
  23882. return *v, true
  23883. }
  23884. // OldName returns the old "name" field's value of the SopTask entity.
  23885. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23887. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23888. if !m.op.Is(OpUpdateOne) {
  23889. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23890. }
  23891. if m.id == nil || m.oldValue == nil {
  23892. return v, errors.New("OldName requires an ID field in the mutation")
  23893. }
  23894. oldValue, err := m.oldValue(ctx)
  23895. if err != nil {
  23896. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23897. }
  23898. return oldValue.Name, nil
  23899. }
  23900. // ResetName resets all changes to the "name" field.
  23901. func (m *SopTaskMutation) ResetName() {
  23902. m.name = nil
  23903. }
  23904. // SetBotWxidList sets the "bot_wxid_list" field.
  23905. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23906. m.bot_wxid_list = &s
  23907. m.appendbot_wxid_list = nil
  23908. }
  23909. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23910. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23911. v := m.bot_wxid_list
  23912. if v == nil {
  23913. return
  23914. }
  23915. return *v, true
  23916. }
  23917. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23918. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23920. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23921. if !m.op.Is(OpUpdateOne) {
  23922. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23923. }
  23924. if m.id == nil || m.oldValue == nil {
  23925. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23926. }
  23927. oldValue, err := m.oldValue(ctx)
  23928. if err != nil {
  23929. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23930. }
  23931. return oldValue.BotWxidList, nil
  23932. }
  23933. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23934. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23935. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  23936. }
  23937. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  23938. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  23939. if len(m.appendbot_wxid_list) == 0 {
  23940. return nil, false
  23941. }
  23942. return m.appendbot_wxid_list, true
  23943. }
  23944. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  23945. func (m *SopTaskMutation) ClearBotWxidList() {
  23946. m.bot_wxid_list = nil
  23947. m.appendbot_wxid_list = nil
  23948. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  23949. }
  23950. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  23951. func (m *SopTaskMutation) BotWxidListCleared() bool {
  23952. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  23953. return ok
  23954. }
  23955. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  23956. func (m *SopTaskMutation) ResetBotWxidList() {
  23957. m.bot_wxid_list = nil
  23958. m.appendbot_wxid_list = nil
  23959. delete(m.clearedFields, soptask.FieldBotWxidList)
  23960. }
  23961. // SetType sets the "type" field.
  23962. func (m *SopTaskMutation) SetType(i int) {
  23963. m._type = &i
  23964. m.add_type = nil
  23965. }
  23966. // GetType returns the value of the "type" field in the mutation.
  23967. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  23968. v := m._type
  23969. if v == nil {
  23970. return
  23971. }
  23972. return *v, true
  23973. }
  23974. // OldType returns the old "type" field's value of the SopTask entity.
  23975. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23977. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  23978. if !m.op.Is(OpUpdateOne) {
  23979. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23980. }
  23981. if m.id == nil || m.oldValue == nil {
  23982. return v, errors.New("OldType requires an ID field in the mutation")
  23983. }
  23984. oldValue, err := m.oldValue(ctx)
  23985. if err != nil {
  23986. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23987. }
  23988. return oldValue.Type, nil
  23989. }
  23990. // AddType adds i to the "type" field.
  23991. func (m *SopTaskMutation) AddType(i int) {
  23992. if m.add_type != nil {
  23993. *m.add_type += i
  23994. } else {
  23995. m.add_type = &i
  23996. }
  23997. }
  23998. // AddedType returns the value that was added to the "type" field in this mutation.
  23999. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24000. v := m.add_type
  24001. if v == nil {
  24002. return
  24003. }
  24004. return *v, true
  24005. }
  24006. // ResetType resets all changes to the "type" field.
  24007. func (m *SopTaskMutation) ResetType() {
  24008. m._type = nil
  24009. m.add_type = nil
  24010. }
  24011. // SetPlanStartTime sets the "plan_start_time" field.
  24012. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24013. m.plan_start_time = &t
  24014. }
  24015. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24016. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24017. v := m.plan_start_time
  24018. if v == nil {
  24019. return
  24020. }
  24021. return *v, true
  24022. }
  24023. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  24024. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24026. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24027. if !m.op.Is(OpUpdateOne) {
  24028. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24029. }
  24030. if m.id == nil || m.oldValue == nil {
  24031. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24032. }
  24033. oldValue, err := m.oldValue(ctx)
  24034. if err != nil {
  24035. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24036. }
  24037. return oldValue.PlanStartTime, nil
  24038. }
  24039. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24040. func (m *SopTaskMutation) ClearPlanStartTime() {
  24041. m.plan_start_time = nil
  24042. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24043. }
  24044. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24045. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24046. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24047. return ok
  24048. }
  24049. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24050. func (m *SopTaskMutation) ResetPlanStartTime() {
  24051. m.plan_start_time = nil
  24052. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24053. }
  24054. // SetPlanEndTime sets the "plan_end_time" field.
  24055. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24056. m.plan_end_time = &t
  24057. }
  24058. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24059. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24060. v := m.plan_end_time
  24061. if v == nil {
  24062. return
  24063. }
  24064. return *v, true
  24065. }
  24066. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24067. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24069. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24070. if !m.op.Is(OpUpdateOne) {
  24071. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24072. }
  24073. if m.id == nil || m.oldValue == nil {
  24074. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24075. }
  24076. oldValue, err := m.oldValue(ctx)
  24077. if err != nil {
  24078. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24079. }
  24080. return oldValue.PlanEndTime, nil
  24081. }
  24082. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24083. func (m *SopTaskMutation) ClearPlanEndTime() {
  24084. m.plan_end_time = nil
  24085. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24086. }
  24087. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24088. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24089. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24090. return ok
  24091. }
  24092. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24093. func (m *SopTaskMutation) ResetPlanEndTime() {
  24094. m.plan_end_time = nil
  24095. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24096. }
  24097. // SetCreatorID sets the "creator_id" field.
  24098. func (m *SopTaskMutation) SetCreatorID(s string) {
  24099. m.creator_id = &s
  24100. }
  24101. // CreatorID returns the value of the "creator_id" field in the mutation.
  24102. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24103. v := m.creator_id
  24104. if v == nil {
  24105. return
  24106. }
  24107. return *v, true
  24108. }
  24109. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24110. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24112. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24113. if !m.op.Is(OpUpdateOne) {
  24114. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24115. }
  24116. if m.id == nil || m.oldValue == nil {
  24117. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24118. }
  24119. oldValue, err := m.oldValue(ctx)
  24120. if err != nil {
  24121. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24122. }
  24123. return oldValue.CreatorID, nil
  24124. }
  24125. // ClearCreatorID clears the value of the "creator_id" field.
  24126. func (m *SopTaskMutation) ClearCreatorID() {
  24127. m.creator_id = nil
  24128. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24129. }
  24130. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24131. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24132. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24133. return ok
  24134. }
  24135. // ResetCreatorID resets all changes to the "creator_id" field.
  24136. func (m *SopTaskMutation) ResetCreatorID() {
  24137. m.creator_id = nil
  24138. delete(m.clearedFields, soptask.FieldCreatorID)
  24139. }
  24140. // SetOrganizationID sets the "organization_id" field.
  24141. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24142. m.organization_id = &u
  24143. m.addorganization_id = nil
  24144. }
  24145. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24146. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24147. v := m.organization_id
  24148. if v == nil {
  24149. return
  24150. }
  24151. return *v, true
  24152. }
  24153. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24154. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24156. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24157. if !m.op.Is(OpUpdateOne) {
  24158. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24159. }
  24160. if m.id == nil || m.oldValue == nil {
  24161. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24162. }
  24163. oldValue, err := m.oldValue(ctx)
  24164. if err != nil {
  24165. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24166. }
  24167. return oldValue.OrganizationID, nil
  24168. }
  24169. // AddOrganizationID adds u to the "organization_id" field.
  24170. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24171. if m.addorganization_id != nil {
  24172. *m.addorganization_id += u
  24173. } else {
  24174. m.addorganization_id = &u
  24175. }
  24176. }
  24177. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24178. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24179. v := m.addorganization_id
  24180. if v == nil {
  24181. return
  24182. }
  24183. return *v, true
  24184. }
  24185. // ClearOrganizationID clears the value of the "organization_id" field.
  24186. func (m *SopTaskMutation) ClearOrganizationID() {
  24187. m.organization_id = nil
  24188. m.addorganization_id = nil
  24189. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24190. }
  24191. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24192. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24193. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24194. return ok
  24195. }
  24196. // ResetOrganizationID resets all changes to the "organization_id" field.
  24197. func (m *SopTaskMutation) ResetOrganizationID() {
  24198. m.organization_id = nil
  24199. m.addorganization_id = nil
  24200. delete(m.clearedFields, soptask.FieldOrganizationID)
  24201. }
  24202. // SetToken sets the "token" field.
  24203. func (m *SopTaskMutation) SetToken(s []string) {
  24204. m.token = &s
  24205. m.appendtoken = nil
  24206. }
  24207. // Token returns the value of the "token" field in the mutation.
  24208. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24209. v := m.token
  24210. if v == nil {
  24211. return
  24212. }
  24213. return *v, true
  24214. }
  24215. // OldToken returns the old "token" field's value of the SopTask entity.
  24216. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24218. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24219. if !m.op.Is(OpUpdateOne) {
  24220. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24221. }
  24222. if m.id == nil || m.oldValue == nil {
  24223. return v, errors.New("OldToken requires an ID field in the mutation")
  24224. }
  24225. oldValue, err := m.oldValue(ctx)
  24226. if err != nil {
  24227. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24228. }
  24229. return oldValue.Token, nil
  24230. }
  24231. // AppendToken adds s to the "token" field.
  24232. func (m *SopTaskMutation) AppendToken(s []string) {
  24233. m.appendtoken = append(m.appendtoken, s...)
  24234. }
  24235. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24236. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24237. if len(m.appendtoken) == 0 {
  24238. return nil, false
  24239. }
  24240. return m.appendtoken, true
  24241. }
  24242. // ClearToken clears the value of the "token" field.
  24243. func (m *SopTaskMutation) ClearToken() {
  24244. m.token = nil
  24245. m.appendtoken = nil
  24246. m.clearedFields[soptask.FieldToken] = struct{}{}
  24247. }
  24248. // TokenCleared returns if the "token" field was cleared in this mutation.
  24249. func (m *SopTaskMutation) TokenCleared() bool {
  24250. _, ok := m.clearedFields[soptask.FieldToken]
  24251. return ok
  24252. }
  24253. // ResetToken resets all changes to the "token" field.
  24254. func (m *SopTaskMutation) ResetToken() {
  24255. m.token = nil
  24256. m.appendtoken = nil
  24257. delete(m.clearedFields, soptask.FieldToken)
  24258. }
  24259. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24260. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24261. if m.task_stages == nil {
  24262. m.task_stages = make(map[uint64]struct{})
  24263. }
  24264. for i := range ids {
  24265. m.task_stages[ids[i]] = struct{}{}
  24266. }
  24267. }
  24268. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24269. func (m *SopTaskMutation) ClearTaskStages() {
  24270. m.clearedtask_stages = true
  24271. }
  24272. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24273. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24274. return m.clearedtask_stages
  24275. }
  24276. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24277. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24278. if m.removedtask_stages == nil {
  24279. m.removedtask_stages = make(map[uint64]struct{})
  24280. }
  24281. for i := range ids {
  24282. delete(m.task_stages, ids[i])
  24283. m.removedtask_stages[ids[i]] = struct{}{}
  24284. }
  24285. }
  24286. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24287. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24288. for id := range m.removedtask_stages {
  24289. ids = append(ids, id)
  24290. }
  24291. return
  24292. }
  24293. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24294. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24295. for id := range m.task_stages {
  24296. ids = append(ids, id)
  24297. }
  24298. return
  24299. }
  24300. // ResetTaskStages resets all changes to the "task_stages" edge.
  24301. func (m *SopTaskMutation) ResetTaskStages() {
  24302. m.task_stages = nil
  24303. m.clearedtask_stages = false
  24304. m.removedtask_stages = nil
  24305. }
  24306. // Where appends a list predicates to the SopTaskMutation builder.
  24307. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24308. m.predicates = append(m.predicates, ps...)
  24309. }
  24310. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24311. // users can use type-assertion to append predicates that do not depend on any generated package.
  24312. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24313. p := make([]predicate.SopTask, len(ps))
  24314. for i := range ps {
  24315. p[i] = ps[i]
  24316. }
  24317. m.Where(p...)
  24318. }
  24319. // Op returns the operation name.
  24320. func (m *SopTaskMutation) Op() Op {
  24321. return m.op
  24322. }
  24323. // SetOp allows setting the mutation operation.
  24324. func (m *SopTaskMutation) SetOp(op Op) {
  24325. m.op = op
  24326. }
  24327. // Type returns the node type of this mutation (SopTask).
  24328. func (m *SopTaskMutation) Type() string {
  24329. return m.typ
  24330. }
  24331. // Fields returns all fields that were changed during this mutation. Note that in
  24332. // order to get all numeric fields that were incremented/decremented, call
  24333. // AddedFields().
  24334. func (m *SopTaskMutation) Fields() []string {
  24335. fields := make([]string, 0, 12)
  24336. if m.created_at != nil {
  24337. fields = append(fields, soptask.FieldCreatedAt)
  24338. }
  24339. if m.updated_at != nil {
  24340. fields = append(fields, soptask.FieldUpdatedAt)
  24341. }
  24342. if m.status != nil {
  24343. fields = append(fields, soptask.FieldStatus)
  24344. }
  24345. if m.deleted_at != nil {
  24346. fields = append(fields, soptask.FieldDeletedAt)
  24347. }
  24348. if m.name != nil {
  24349. fields = append(fields, soptask.FieldName)
  24350. }
  24351. if m.bot_wxid_list != nil {
  24352. fields = append(fields, soptask.FieldBotWxidList)
  24353. }
  24354. if m._type != nil {
  24355. fields = append(fields, soptask.FieldType)
  24356. }
  24357. if m.plan_start_time != nil {
  24358. fields = append(fields, soptask.FieldPlanStartTime)
  24359. }
  24360. if m.plan_end_time != nil {
  24361. fields = append(fields, soptask.FieldPlanEndTime)
  24362. }
  24363. if m.creator_id != nil {
  24364. fields = append(fields, soptask.FieldCreatorID)
  24365. }
  24366. if m.organization_id != nil {
  24367. fields = append(fields, soptask.FieldOrganizationID)
  24368. }
  24369. if m.token != nil {
  24370. fields = append(fields, soptask.FieldToken)
  24371. }
  24372. return fields
  24373. }
  24374. // Field returns the value of a field with the given name. The second boolean
  24375. // return value indicates that this field was not set, or was not defined in the
  24376. // schema.
  24377. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24378. switch name {
  24379. case soptask.FieldCreatedAt:
  24380. return m.CreatedAt()
  24381. case soptask.FieldUpdatedAt:
  24382. return m.UpdatedAt()
  24383. case soptask.FieldStatus:
  24384. return m.Status()
  24385. case soptask.FieldDeletedAt:
  24386. return m.DeletedAt()
  24387. case soptask.FieldName:
  24388. return m.Name()
  24389. case soptask.FieldBotWxidList:
  24390. return m.BotWxidList()
  24391. case soptask.FieldType:
  24392. return m.GetType()
  24393. case soptask.FieldPlanStartTime:
  24394. return m.PlanStartTime()
  24395. case soptask.FieldPlanEndTime:
  24396. return m.PlanEndTime()
  24397. case soptask.FieldCreatorID:
  24398. return m.CreatorID()
  24399. case soptask.FieldOrganizationID:
  24400. return m.OrganizationID()
  24401. case soptask.FieldToken:
  24402. return m.Token()
  24403. }
  24404. return nil, false
  24405. }
  24406. // OldField returns the old value of the field from the database. An error is
  24407. // returned if the mutation operation is not UpdateOne, or the query to the
  24408. // database failed.
  24409. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24410. switch name {
  24411. case soptask.FieldCreatedAt:
  24412. return m.OldCreatedAt(ctx)
  24413. case soptask.FieldUpdatedAt:
  24414. return m.OldUpdatedAt(ctx)
  24415. case soptask.FieldStatus:
  24416. return m.OldStatus(ctx)
  24417. case soptask.FieldDeletedAt:
  24418. return m.OldDeletedAt(ctx)
  24419. case soptask.FieldName:
  24420. return m.OldName(ctx)
  24421. case soptask.FieldBotWxidList:
  24422. return m.OldBotWxidList(ctx)
  24423. case soptask.FieldType:
  24424. return m.OldType(ctx)
  24425. case soptask.FieldPlanStartTime:
  24426. return m.OldPlanStartTime(ctx)
  24427. case soptask.FieldPlanEndTime:
  24428. return m.OldPlanEndTime(ctx)
  24429. case soptask.FieldCreatorID:
  24430. return m.OldCreatorID(ctx)
  24431. case soptask.FieldOrganizationID:
  24432. return m.OldOrganizationID(ctx)
  24433. case soptask.FieldToken:
  24434. return m.OldToken(ctx)
  24435. }
  24436. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24437. }
  24438. // SetField sets the value of a field with the given name. It returns an error if
  24439. // the field is not defined in the schema, or if the type mismatched the field
  24440. // type.
  24441. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24442. switch name {
  24443. case soptask.FieldCreatedAt:
  24444. v, ok := value.(time.Time)
  24445. if !ok {
  24446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24447. }
  24448. m.SetCreatedAt(v)
  24449. return nil
  24450. case soptask.FieldUpdatedAt:
  24451. v, ok := value.(time.Time)
  24452. if !ok {
  24453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24454. }
  24455. m.SetUpdatedAt(v)
  24456. return nil
  24457. case soptask.FieldStatus:
  24458. v, ok := value.(uint8)
  24459. if !ok {
  24460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24461. }
  24462. m.SetStatus(v)
  24463. return nil
  24464. case soptask.FieldDeletedAt:
  24465. v, ok := value.(time.Time)
  24466. if !ok {
  24467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24468. }
  24469. m.SetDeletedAt(v)
  24470. return nil
  24471. case soptask.FieldName:
  24472. v, ok := value.(string)
  24473. if !ok {
  24474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24475. }
  24476. m.SetName(v)
  24477. return nil
  24478. case soptask.FieldBotWxidList:
  24479. v, ok := value.([]string)
  24480. if !ok {
  24481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24482. }
  24483. m.SetBotWxidList(v)
  24484. return nil
  24485. case soptask.FieldType:
  24486. v, ok := value.(int)
  24487. if !ok {
  24488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24489. }
  24490. m.SetType(v)
  24491. return nil
  24492. case soptask.FieldPlanStartTime:
  24493. v, ok := value.(time.Time)
  24494. if !ok {
  24495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24496. }
  24497. m.SetPlanStartTime(v)
  24498. return nil
  24499. case soptask.FieldPlanEndTime:
  24500. v, ok := value.(time.Time)
  24501. if !ok {
  24502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24503. }
  24504. m.SetPlanEndTime(v)
  24505. return nil
  24506. case soptask.FieldCreatorID:
  24507. v, ok := value.(string)
  24508. if !ok {
  24509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24510. }
  24511. m.SetCreatorID(v)
  24512. return nil
  24513. case soptask.FieldOrganizationID:
  24514. v, ok := value.(uint64)
  24515. if !ok {
  24516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24517. }
  24518. m.SetOrganizationID(v)
  24519. return nil
  24520. case soptask.FieldToken:
  24521. v, ok := value.([]string)
  24522. if !ok {
  24523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24524. }
  24525. m.SetToken(v)
  24526. return nil
  24527. }
  24528. return fmt.Errorf("unknown SopTask field %s", name)
  24529. }
  24530. // AddedFields returns all numeric fields that were incremented/decremented during
  24531. // this mutation.
  24532. func (m *SopTaskMutation) AddedFields() []string {
  24533. var fields []string
  24534. if m.addstatus != nil {
  24535. fields = append(fields, soptask.FieldStatus)
  24536. }
  24537. if m.add_type != nil {
  24538. fields = append(fields, soptask.FieldType)
  24539. }
  24540. if m.addorganization_id != nil {
  24541. fields = append(fields, soptask.FieldOrganizationID)
  24542. }
  24543. return fields
  24544. }
  24545. // AddedField returns the numeric value that was incremented/decremented on a field
  24546. // with the given name. The second boolean return value indicates that this field
  24547. // was not set, or was not defined in the schema.
  24548. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24549. switch name {
  24550. case soptask.FieldStatus:
  24551. return m.AddedStatus()
  24552. case soptask.FieldType:
  24553. return m.AddedType()
  24554. case soptask.FieldOrganizationID:
  24555. return m.AddedOrganizationID()
  24556. }
  24557. return nil, false
  24558. }
  24559. // AddField adds the value to the field with the given name. It returns an error if
  24560. // the field is not defined in the schema, or if the type mismatched the field
  24561. // type.
  24562. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24563. switch name {
  24564. case soptask.FieldStatus:
  24565. v, ok := value.(int8)
  24566. if !ok {
  24567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24568. }
  24569. m.AddStatus(v)
  24570. return nil
  24571. case soptask.FieldType:
  24572. v, ok := value.(int)
  24573. if !ok {
  24574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24575. }
  24576. m.AddType(v)
  24577. return nil
  24578. case soptask.FieldOrganizationID:
  24579. v, ok := value.(int64)
  24580. if !ok {
  24581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24582. }
  24583. m.AddOrganizationID(v)
  24584. return nil
  24585. }
  24586. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24587. }
  24588. // ClearedFields returns all nullable fields that were cleared during this
  24589. // mutation.
  24590. func (m *SopTaskMutation) ClearedFields() []string {
  24591. var fields []string
  24592. if m.FieldCleared(soptask.FieldStatus) {
  24593. fields = append(fields, soptask.FieldStatus)
  24594. }
  24595. if m.FieldCleared(soptask.FieldDeletedAt) {
  24596. fields = append(fields, soptask.FieldDeletedAt)
  24597. }
  24598. if m.FieldCleared(soptask.FieldBotWxidList) {
  24599. fields = append(fields, soptask.FieldBotWxidList)
  24600. }
  24601. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24602. fields = append(fields, soptask.FieldPlanStartTime)
  24603. }
  24604. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24605. fields = append(fields, soptask.FieldPlanEndTime)
  24606. }
  24607. if m.FieldCleared(soptask.FieldCreatorID) {
  24608. fields = append(fields, soptask.FieldCreatorID)
  24609. }
  24610. if m.FieldCleared(soptask.FieldOrganizationID) {
  24611. fields = append(fields, soptask.FieldOrganizationID)
  24612. }
  24613. if m.FieldCleared(soptask.FieldToken) {
  24614. fields = append(fields, soptask.FieldToken)
  24615. }
  24616. return fields
  24617. }
  24618. // FieldCleared returns a boolean indicating if a field with the given name was
  24619. // cleared in this mutation.
  24620. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24621. _, ok := m.clearedFields[name]
  24622. return ok
  24623. }
  24624. // ClearField clears the value of the field with the given name. It returns an
  24625. // error if the field is not defined in the schema.
  24626. func (m *SopTaskMutation) ClearField(name string) error {
  24627. switch name {
  24628. case soptask.FieldStatus:
  24629. m.ClearStatus()
  24630. return nil
  24631. case soptask.FieldDeletedAt:
  24632. m.ClearDeletedAt()
  24633. return nil
  24634. case soptask.FieldBotWxidList:
  24635. m.ClearBotWxidList()
  24636. return nil
  24637. case soptask.FieldPlanStartTime:
  24638. m.ClearPlanStartTime()
  24639. return nil
  24640. case soptask.FieldPlanEndTime:
  24641. m.ClearPlanEndTime()
  24642. return nil
  24643. case soptask.FieldCreatorID:
  24644. m.ClearCreatorID()
  24645. return nil
  24646. case soptask.FieldOrganizationID:
  24647. m.ClearOrganizationID()
  24648. return nil
  24649. case soptask.FieldToken:
  24650. m.ClearToken()
  24651. return nil
  24652. }
  24653. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24654. }
  24655. // ResetField resets all changes in the mutation for the field with the given name.
  24656. // It returns an error if the field is not defined in the schema.
  24657. func (m *SopTaskMutation) ResetField(name string) error {
  24658. switch name {
  24659. case soptask.FieldCreatedAt:
  24660. m.ResetCreatedAt()
  24661. return nil
  24662. case soptask.FieldUpdatedAt:
  24663. m.ResetUpdatedAt()
  24664. return nil
  24665. case soptask.FieldStatus:
  24666. m.ResetStatus()
  24667. return nil
  24668. case soptask.FieldDeletedAt:
  24669. m.ResetDeletedAt()
  24670. return nil
  24671. case soptask.FieldName:
  24672. m.ResetName()
  24673. return nil
  24674. case soptask.FieldBotWxidList:
  24675. m.ResetBotWxidList()
  24676. return nil
  24677. case soptask.FieldType:
  24678. m.ResetType()
  24679. return nil
  24680. case soptask.FieldPlanStartTime:
  24681. m.ResetPlanStartTime()
  24682. return nil
  24683. case soptask.FieldPlanEndTime:
  24684. m.ResetPlanEndTime()
  24685. return nil
  24686. case soptask.FieldCreatorID:
  24687. m.ResetCreatorID()
  24688. return nil
  24689. case soptask.FieldOrganizationID:
  24690. m.ResetOrganizationID()
  24691. return nil
  24692. case soptask.FieldToken:
  24693. m.ResetToken()
  24694. return nil
  24695. }
  24696. return fmt.Errorf("unknown SopTask field %s", name)
  24697. }
  24698. // AddedEdges returns all edge names that were set/added in this mutation.
  24699. func (m *SopTaskMutation) AddedEdges() []string {
  24700. edges := make([]string, 0, 1)
  24701. if m.task_stages != nil {
  24702. edges = append(edges, soptask.EdgeTaskStages)
  24703. }
  24704. return edges
  24705. }
  24706. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24707. // name in this mutation.
  24708. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24709. switch name {
  24710. case soptask.EdgeTaskStages:
  24711. ids := make([]ent.Value, 0, len(m.task_stages))
  24712. for id := range m.task_stages {
  24713. ids = append(ids, id)
  24714. }
  24715. return ids
  24716. }
  24717. return nil
  24718. }
  24719. // RemovedEdges returns all edge names that were removed in this mutation.
  24720. func (m *SopTaskMutation) RemovedEdges() []string {
  24721. edges := make([]string, 0, 1)
  24722. if m.removedtask_stages != nil {
  24723. edges = append(edges, soptask.EdgeTaskStages)
  24724. }
  24725. return edges
  24726. }
  24727. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24728. // the given name in this mutation.
  24729. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24730. switch name {
  24731. case soptask.EdgeTaskStages:
  24732. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24733. for id := range m.removedtask_stages {
  24734. ids = append(ids, id)
  24735. }
  24736. return ids
  24737. }
  24738. return nil
  24739. }
  24740. // ClearedEdges returns all edge names that were cleared in this mutation.
  24741. func (m *SopTaskMutation) ClearedEdges() []string {
  24742. edges := make([]string, 0, 1)
  24743. if m.clearedtask_stages {
  24744. edges = append(edges, soptask.EdgeTaskStages)
  24745. }
  24746. return edges
  24747. }
  24748. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24749. // was cleared in this mutation.
  24750. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24751. switch name {
  24752. case soptask.EdgeTaskStages:
  24753. return m.clearedtask_stages
  24754. }
  24755. return false
  24756. }
  24757. // ClearEdge clears the value of the edge with the given name. It returns an error
  24758. // if that edge is not defined in the schema.
  24759. func (m *SopTaskMutation) ClearEdge(name string) error {
  24760. switch name {
  24761. }
  24762. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24763. }
  24764. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24765. // It returns an error if the edge is not defined in the schema.
  24766. func (m *SopTaskMutation) ResetEdge(name string) error {
  24767. switch name {
  24768. case soptask.EdgeTaskStages:
  24769. m.ResetTaskStages()
  24770. return nil
  24771. }
  24772. return fmt.Errorf("unknown SopTask edge %s", name)
  24773. }
  24774. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24775. type TokenMutation struct {
  24776. config
  24777. op Op
  24778. typ string
  24779. id *uint64
  24780. created_at *time.Time
  24781. updated_at *time.Time
  24782. deleted_at *time.Time
  24783. expire_at *time.Time
  24784. token *string
  24785. mac *string
  24786. organization_id *uint64
  24787. addorganization_id *int64
  24788. custom_agent_base *string
  24789. custom_agent_key *string
  24790. openai_base *string
  24791. openai_key *string
  24792. clearedFields map[string]struct{}
  24793. agent *uint64
  24794. clearedagent bool
  24795. done bool
  24796. oldValue func(context.Context) (*Token, error)
  24797. predicates []predicate.Token
  24798. }
  24799. var _ ent.Mutation = (*TokenMutation)(nil)
  24800. // tokenOption allows management of the mutation configuration using functional options.
  24801. type tokenOption func(*TokenMutation)
  24802. // newTokenMutation creates new mutation for the Token entity.
  24803. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24804. m := &TokenMutation{
  24805. config: c,
  24806. op: op,
  24807. typ: TypeToken,
  24808. clearedFields: make(map[string]struct{}),
  24809. }
  24810. for _, opt := range opts {
  24811. opt(m)
  24812. }
  24813. return m
  24814. }
  24815. // withTokenID sets the ID field of the mutation.
  24816. func withTokenID(id uint64) tokenOption {
  24817. return func(m *TokenMutation) {
  24818. var (
  24819. err error
  24820. once sync.Once
  24821. value *Token
  24822. )
  24823. m.oldValue = func(ctx context.Context) (*Token, error) {
  24824. once.Do(func() {
  24825. if m.done {
  24826. err = errors.New("querying old values post mutation is not allowed")
  24827. } else {
  24828. value, err = m.Client().Token.Get(ctx, id)
  24829. }
  24830. })
  24831. return value, err
  24832. }
  24833. m.id = &id
  24834. }
  24835. }
  24836. // withToken sets the old Token of the mutation.
  24837. func withToken(node *Token) tokenOption {
  24838. return func(m *TokenMutation) {
  24839. m.oldValue = func(context.Context) (*Token, error) {
  24840. return node, nil
  24841. }
  24842. m.id = &node.ID
  24843. }
  24844. }
  24845. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24846. // executed in a transaction (ent.Tx), a transactional client is returned.
  24847. func (m TokenMutation) Client() *Client {
  24848. client := &Client{config: m.config}
  24849. client.init()
  24850. return client
  24851. }
  24852. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24853. // it returns an error otherwise.
  24854. func (m TokenMutation) Tx() (*Tx, error) {
  24855. if _, ok := m.driver.(*txDriver); !ok {
  24856. return nil, errors.New("ent: mutation is not running in a transaction")
  24857. }
  24858. tx := &Tx{config: m.config}
  24859. tx.init()
  24860. return tx, nil
  24861. }
  24862. // SetID sets the value of the id field. Note that this
  24863. // operation is only accepted on creation of Token entities.
  24864. func (m *TokenMutation) SetID(id uint64) {
  24865. m.id = &id
  24866. }
  24867. // ID returns the ID value in the mutation. Note that the ID is only available
  24868. // if it was provided to the builder or after it was returned from the database.
  24869. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24870. if m.id == nil {
  24871. return
  24872. }
  24873. return *m.id, true
  24874. }
  24875. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24876. // That means, if the mutation is applied within a transaction with an isolation level such
  24877. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24878. // or updated by the mutation.
  24879. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24880. switch {
  24881. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24882. id, exists := m.ID()
  24883. if exists {
  24884. return []uint64{id}, nil
  24885. }
  24886. fallthrough
  24887. case m.op.Is(OpUpdate | OpDelete):
  24888. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24889. default:
  24890. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24891. }
  24892. }
  24893. // SetCreatedAt sets the "created_at" field.
  24894. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24895. m.created_at = &t
  24896. }
  24897. // CreatedAt returns the value of the "created_at" field in the mutation.
  24898. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24899. v := m.created_at
  24900. if v == nil {
  24901. return
  24902. }
  24903. return *v, true
  24904. }
  24905. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24906. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24908. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24909. if !m.op.Is(OpUpdateOne) {
  24910. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24911. }
  24912. if m.id == nil || m.oldValue == nil {
  24913. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24914. }
  24915. oldValue, err := m.oldValue(ctx)
  24916. if err != nil {
  24917. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24918. }
  24919. return oldValue.CreatedAt, nil
  24920. }
  24921. // ResetCreatedAt resets all changes to the "created_at" field.
  24922. func (m *TokenMutation) ResetCreatedAt() {
  24923. m.created_at = nil
  24924. }
  24925. // SetUpdatedAt sets the "updated_at" field.
  24926. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24927. m.updated_at = &t
  24928. }
  24929. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24930. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24931. v := m.updated_at
  24932. if v == nil {
  24933. return
  24934. }
  24935. return *v, true
  24936. }
  24937. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  24938. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24940. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24941. if !m.op.Is(OpUpdateOne) {
  24942. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24943. }
  24944. if m.id == nil || m.oldValue == nil {
  24945. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24946. }
  24947. oldValue, err := m.oldValue(ctx)
  24948. if err != nil {
  24949. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24950. }
  24951. return oldValue.UpdatedAt, nil
  24952. }
  24953. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24954. func (m *TokenMutation) ResetUpdatedAt() {
  24955. m.updated_at = nil
  24956. }
  24957. // SetDeletedAt sets the "deleted_at" field.
  24958. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  24959. m.deleted_at = &t
  24960. }
  24961. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24962. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  24963. v := m.deleted_at
  24964. if v == nil {
  24965. return
  24966. }
  24967. return *v, true
  24968. }
  24969. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  24970. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24972. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24973. if !m.op.Is(OpUpdateOne) {
  24974. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24975. }
  24976. if m.id == nil || m.oldValue == nil {
  24977. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24978. }
  24979. oldValue, err := m.oldValue(ctx)
  24980. if err != nil {
  24981. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24982. }
  24983. return oldValue.DeletedAt, nil
  24984. }
  24985. // ClearDeletedAt clears the value of the "deleted_at" field.
  24986. func (m *TokenMutation) ClearDeletedAt() {
  24987. m.deleted_at = nil
  24988. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  24989. }
  24990. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24991. func (m *TokenMutation) DeletedAtCleared() bool {
  24992. _, ok := m.clearedFields[token.FieldDeletedAt]
  24993. return ok
  24994. }
  24995. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24996. func (m *TokenMutation) ResetDeletedAt() {
  24997. m.deleted_at = nil
  24998. delete(m.clearedFields, token.FieldDeletedAt)
  24999. }
  25000. // SetExpireAt sets the "expire_at" field.
  25001. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25002. m.expire_at = &t
  25003. }
  25004. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25005. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25006. v := m.expire_at
  25007. if v == nil {
  25008. return
  25009. }
  25010. return *v, true
  25011. }
  25012. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25013. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25015. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25016. if !m.op.Is(OpUpdateOne) {
  25017. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25018. }
  25019. if m.id == nil || m.oldValue == nil {
  25020. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  25021. }
  25022. oldValue, err := m.oldValue(ctx)
  25023. if err != nil {
  25024. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  25025. }
  25026. return oldValue.ExpireAt, nil
  25027. }
  25028. // ClearExpireAt clears the value of the "expire_at" field.
  25029. func (m *TokenMutation) ClearExpireAt() {
  25030. m.expire_at = nil
  25031. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25032. }
  25033. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25034. func (m *TokenMutation) ExpireAtCleared() bool {
  25035. _, ok := m.clearedFields[token.FieldExpireAt]
  25036. return ok
  25037. }
  25038. // ResetExpireAt resets all changes to the "expire_at" field.
  25039. func (m *TokenMutation) ResetExpireAt() {
  25040. m.expire_at = nil
  25041. delete(m.clearedFields, token.FieldExpireAt)
  25042. }
  25043. // SetToken sets the "token" field.
  25044. func (m *TokenMutation) SetToken(s string) {
  25045. m.token = &s
  25046. }
  25047. // Token returns the value of the "token" field in the mutation.
  25048. func (m *TokenMutation) Token() (r string, exists bool) {
  25049. v := m.token
  25050. if v == nil {
  25051. return
  25052. }
  25053. return *v, true
  25054. }
  25055. // OldToken returns the old "token" field's value of the Token entity.
  25056. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25058. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25059. if !m.op.Is(OpUpdateOne) {
  25060. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25061. }
  25062. if m.id == nil || m.oldValue == nil {
  25063. return v, errors.New("OldToken requires an ID field in the mutation")
  25064. }
  25065. oldValue, err := m.oldValue(ctx)
  25066. if err != nil {
  25067. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25068. }
  25069. return oldValue.Token, nil
  25070. }
  25071. // ClearToken clears the value of the "token" field.
  25072. func (m *TokenMutation) ClearToken() {
  25073. m.token = nil
  25074. m.clearedFields[token.FieldToken] = struct{}{}
  25075. }
  25076. // TokenCleared returns if the "token" field was cleared in this mutation.
  25077. func (m *TokenMutation) TokenCleared() bool {
  25078. _, ok := m.clearedFields[token.FieldToken]
  25079. return ok
  25080. }
  25081. // ResetToken resets all changes to the "token" field.
  25082. func (m *TokenMutation) ResetToken() {
  25083. m.token = nil
  25084. delete(m.clearedFields, token.FieldToken)
  25085. }
  25086. // SetMAC sets the "mac" field.
  25087. func (m *TokenMutation) SetMAC(s string) {
  25088. m.mac = &s
  25089. }
  25090. // MAC returns the value of the "mac" field in the mutation.
  25091. func (m *TokenMutation) MAC() (r string, exists bool) {
  25092. v := m.mac
  25093. if v == nil {
  25094. return
  25095. }
  25096. return *v, true
  25097. }
  25098. // OldMAC returns the old "mac" field's value of the Token entity.
  25099. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25101. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25102. if !m.op.Is(OpUpdateOne) {
  25103. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25104. }
  25105. if m.id == nil || m.oldValue == nil {
  25106. return v, errors.New("OldMAC requires an ID field in the mutation")
  25107. }
  25108. oldValue, err := m.oldValue(ctx)
  25109. if err != nil {
  25110. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25111. }
  25112. return oldValue.MAC, nil
  25113. }
  25114. // ClearMAC clears the value of the "mac" field.
  25115. func (m *TokenMutation) ClearMAC() {
  25116. m.mac = nil
  25117. m.clearedFields[token.FieldMAC] = struct{}{}
  25118. }
  25119. // MACCleared returns if the "mac" field was cleared in this mutation.
  25120. func (m *TokenMutation) MACCleared() bool {
  25121. _, ok := m.clearedFields[token.FieldMAC]
  25122. return ok
  25123. }
  25124. // ResetMAC resets all changes to the "mac" field.
  25125. func (m *TokenMutation) ResetMAC() {
  25126. m.mac = nil
  25127. delete(m.clearedFields, token.FieldMAC)
  25128. }
  25129. // SetOrganizationID sets the "organization_id" field.
  25130. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25131. m.organization_id = &u
  25132. m.addorganization_id = nil
  25133. }
  25134. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25135. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25136. v := m.organization_id
  25137. if v == nil {
  25138. return
  25139. }
  25140. return *v, true
  25141. }
  25142. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25143. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25145. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25146. if !m.op.Is(OpUpdateOne) {
  25147. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25148. }
  25149. if m.id == nil || m.oldValue == nil {
  25150. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25151. }
  25152. oldValue, err := m.oldValue(ctx)
  25153. if err != nil {
  25154. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25155. }
  25156. return oldValue.OrganizationID, nil
  25157. }
  25158. // AddOrganizationID adds u to the "organization_id" field.
  25159. func (m *TokenMutation) AddOrganizationID(u int64) {
  25160. if m.addorganization_id != nil {
  25161. *m.addorganization_id += u
  25162. } else {
  25163. m.addorganization_id = &u
  25164. }
  25165. }
  25166. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25167. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25168. v := m.addorganization_id
  25169. if v == nil {
  25170. return
  25171. }
  25172. return *v, true
  25173. }
  25174. // ResetOrganizationID resets all changes to the "organization_id" field.
  25175. func (m *TokenMutation) ResetOrganizationID() {
  25176. m.organization_id = nil
  25177. m.addorganization_id = nil
  25178. }
  25179. // SetAgentID sets the "agent_id" field.
  25180. func (m *TokenMutation) SetAgentID(u uint64) {
  25181. m.agent = &u
  25182. }
  25183. // AgentID returns the value of the "agent_id" field in the mutation.
  25184. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25185. v := m.agent
  25186. if v == nil {
  25187. return
  25188. }
  25189. return *v, true
  25190. }
  25191. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25192. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25194. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25195. if !m.op.Is(OpUpdateOne) {
  25196. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25197. }
  25198. if m.id == nil || m.oldValue == nil {
  25199. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25200. }
  25201. oldValue, err := m.oldValue(ctx)
  25202. if err != nil {
  25203. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25204. }
  25205. return oldValue.AgentID, nil
  25206. }
  25207. // ResetAgentID resets all changes to the "agent_id" field.
  25208. func (m *TokenMutation) ResetAgentID() {
  25209. m.agent = nil
  25210. }
  25211. // SetCustomAgentBase sets the "custom_agent_base" field.
  25212. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25213. m.custom_agent_base = &s
  25214. }
  25215. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25216. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25217. v := m.custom_agent_base
  25218. if v == nil {
  25219. return
  25220. }
  25221. return *v, true
  25222. }
  25223. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25224. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25226. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25227. if !m.op.Is(OpUpdateOne) {
  25228. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25229. }
  25230. if m.id == nil || m.oldValue == nil {
  25231. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25232. }
  25233. oldValue, err := m.oldValue(ctx)
  25234. if err != nil {
  25235. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25236. }
  25237. return oldValue.CustomAgentBase, nil
  25238. }
  25239. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25240. func (m *TokenMutation) ClearCustomAgentBase() {
  25241. m.custom_agent_base = nil
  25242. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25243. }
  25244. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25245. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25246. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25247. return ok
  25248. }
  25249. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25250. func (m *TokenMutation) ResetCustomAgentBase() {
  25251. m.custom_agent_base = nil
  25252. delete(m.clearedFields, token.FieldCustomAgentBase)
  25253. }
  25254. // SetCustomAgentKey sets the "custom_agent_key" field.
  25255. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25256. m.custom_agent_key = &s
  25257. }
  25258. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25259. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25260. v := m.custom_agent_key
  25261. if v == nil {
  25262. return
  25263. }
  25264. return *v, true
  25265. }
  25266. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25267. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25269. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25270. if !m.op.Is(OpUpdateOne) {
  25271. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25272. }
  25273. if m.id == nil || m.oldValue == nil {
  25274. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25275. }
  25276. oldValue, err := m.oldValue(ctx)
  25277. if err != nil {
  25278. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25279. }
  25280. return oldValue.CustomAgentKey, nil
  25281. }
  25282. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25283. func (m *TokenMutation) ClearCustomAgentKey() {
  25284. m.custom_agent_key = nil
  25285. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25286. }
  25287. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25288. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25289. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25290. return ok
  25291. }
  25292. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25293. func (m *TokenMutation) ResetCustomAgentKey() {
  25294. m.custom_agent_key = nil
  25295. delete(m.clearedFields, token.FieldCustomAgentKey)
  25296. }
  25297. // SetOpenaiBase sets the "openai_base" field.
  25298. func (m *TokenMutation) SetOpenaiBase(s string) {
  25299. m.openai_base = &s
  25300. }
  25301. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25302. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25303. v := m.openai_base
  25304. if v == nil {
  25305. return
  25306. }
  25307. return *v, true
  25308. }
  25309. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25310. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25312. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25313. if !m.op.Is(OpUpdateOne) {
  25314. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25315. }
  25316. if m.id == nil || m.oldValue == nil {
  25317. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25318. }
  25319. oldValue, err := m.oldValue(ctx)
  25320. if err != nil {
  25321. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25322. }
  25323. return oldValue.OpenaiBase, nil
  25324. }
  25325. // ClearOpenaiBase clears the value of the "openai_base" field.
  25326. func (m *TokenMutation) ClearOpenaiBase() {
  25327. m.openai_base = nil
  25328. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25329. }
  25330. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25331. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25332. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25333. return ok
  25334. }
  25335. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25336. func (m *TokenMutation) ResetOpenaiBase() {
  25337. m.openai_base = nil
  25338. delete(m.clearedFields, token.FieldOpenaiBase)
  25339. }
  25340. // SetOpenaiKey sets the "openai_key" field.
  25341. func (m *TokenMutation) SetOpenaiKey(s string) {
  25342. m.openai_key = &s
  25343. }
  25344. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25345. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25346. v := m.openai_key
  25347. if v == nil {
  25348. return
  25349. }
  25350. return *v, true
  25351. }
  25352. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25353. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25355. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25356. if !m.op.Is(OpUpdateOne) {
  25357. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25358. }
  25359. if m.id == nil || m.oldValue == nil {
  25360. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25361. }
  25362. oldValue, err := m.oldValue(ctx)
  25363. if err != nil {
  25364. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25365. }
  25366. return oldValue.OpenaiKey, nil
  25367. }
  25368. // ClearOpenaiKey clears the value of the "openai_key" field.
  25369. func (m *TokenMutation) ClearOpenaiKey() {
  25370. m.openai_key = nil
  25371. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25372. }
  25373. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25374. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25375. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25376. return ok
  25377. }
  25378. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25379. func (m *TokenMutation) ResetOpenaiKey() {
  25380. m.openai_key = nil
  25381. delete(m.clearedFields, token.FieldOpenaiKey)
  25382. }
  25383. // ClearAgent clears the "agent" edge to the Agent entity.
  25384. func (m *TokenMutation) ClearAgent() {
  25385. m.clearedagent = true
  25386. m.clearedFields[token.FieldAgentID] = struct{}{}
  25387. }
  25388. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25389. func (m *TokenMutation) AgentCleared() bool {
  25390. return m.clearedagent
  25391. }
  25392. // AgentIDs returns the "agent" edge IDs in the mutation.
  25393. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25394. // AgentID instead. It exists only for internal usage by the builders.
  25395. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25396. if id := m.agent; id != nil {
  25397. ids = append(ids, *id)
  25398. }
  25399. return
  25400. }
  25401. // ResetAgent resets all changes to the "agent" edge.
  25402. func (m *TokenMutation) ResetAgent() {
  25403. m.agent = nil
  25404. m.clearedagent = false
  25405. }
  25406. // Where appends a list predicates to the TokenMutation builder.
  25407. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25408. m.predicates = append(m.predicates, ps...)
  25409. }
  25410. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25411. // users can use type-assertion to append predicates that do not depend on any generated package.
  25412. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25413. p := make([]predicate.Token, len(ps))
  25414. for i := range ps {
  25415. p[i] = ps[i]
  25416. }
  25417. m.Where(p...)
  25418. }
  25419. // Op returns the operation name.
  25420. func (m *TokenMutation) Op() Op {
  25421. return m.op
  25422. }
  25423. // SetOp allows setting the mutation operation.
  25424. func (m *TokenMutation) SetOp(op Op) {
  25425. m.op = op
  25426. }
  25427. // Type returns the node type of this mutation (Token).
  25428. func (m *TokenMutation) Type() string {
  25429. return m.typ
  25430. }
  25431. // Fields returns all fields that were changed during this mutation. Note that in
  25432. // order to get all numeric fields that were incremented/decremented, call
  25433. // AddedFields().
  25434. func (m *TokenMutation) Fields() []string {
  25435. fields := make([]string, 0, 12)
  25436. if m.created_at != nil {
  25437. fields = append(fields, token.FieldCreatedAt)
  25438. }
  25439. if m.updated_at != nil {
  25440. fields = append(fields, token.FieldUpdatedAt)
  25441. }
  25442. if m.deleted_at != nil {
  25443. fields = append(fields, token.FieldDeletedAt)
  25444. }
  25445. if m.expire_at != nil {
  25446. fields = append(fields, token.FieldExpireAt)
  25447. }
  25448. if m.token != nil {
  25449. fields = append(fields, token.FieldToken)
  25450. }
  25451. if m.mac != nil {
  25452. fields = append(fields, token.FieldMAC)
  25453. }
  25454. if m.organization_id != nil {
  25455. fields = append(fields, token.FieldOrganizationID)
  25456. }
  25457. if m.agent != nil {
  25458. fields = append(fields, token.FieldAgentID)
  25459. }
  25460. if m.custom_agent_base != nil {
  25461. fields = append(fields, token.FieldCustomAgentBase)
  25462. }
  25463. if m.custom_agent_key != nil {
  25464. fields = append(fields, token.FieldCustomAgentKey)
  25465. }
  25466. if m.openai_base != nil {
  25467. fields = append(fields, token.FieldOpenaiBase)
  25468. }
  25469. if m.openai_key != nil {
  25470. fields = append(fields, token.FieldOpenaiKey)
  25471. }
  25472. return fields
  25473. }
  25474. // Field returns the value of a field with the given name. The second boolean
  25475. // return value indicates that this field was not set, or was not defined in the
  25476. // schema.
  25477. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25478. switch name {
  25479. case token.FieldCreatedAt:
  25480. return m.CreatedAt()
  25481. case token.FieldUpdatedAt:
  25482. return m.UpdatedAt()
  25483. case token.FieldDeletedAt:
  25484. return m.DeletedAt()
  25485. case token.FieldExpireAt:
  25486. return m.ExpireAt()
  25487. case token.FieldToken:
  25488. return m.Token()
  25489. case token.FieldMAC:
  25490. return m.MAC()
  25491. case token.FieldOrganizationID:
  25492. return m.OrganizationID()
  25493. case token.FieldAgentID:
  25494. return m.AgentID()
  25495. case token.FieldCustomAgentBase:
  25496. return m.CustomAgentBase()
  25497. case token.FieldCustomAgentKey:
  25498. return m.CustomAgentKey()
  25499. case token.FieldOpenaiBase:
  25500. return m.OpenaiBase()
  25501. case token.FieldOpenaiKey:
  25502. return m.OpenaiKey()
  25503. }
  25504. return nil, false
  25505. }
  25506. // OldField returns the old value of the field from the database. An error is
  25507. // returned if the mutation operation is not UpdateOne, or the query to the
  25508. // database failed.
  25509. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25510. switch name {
  25511. case token.FieldCreatedAt:
  25512. return m.OldCreatedAt(ctx)
  25513. case token.FieldUpdatedAt:
  25514. return m.OldUpdatedAt(ctx)
  25515. case token.FieldDeletedAt:
  25516. return m.OldDeletedAt(ctx)
  25517. case token.FieldExpireAt:
  25518. return m.OldExpireAt(ctx)
  25519. case token.FieldToken:
  25520. return m.OldToken(ctx)
  25521. case token.FieldMAC:
  25522. return m.OldMAC(ctx)
  25523. case token.FieldOrganizationID:
  25524. return m.OldOrganizationID(ctx)
  25525. case token.FieldAgentID:
  25526. return m.OldAgentID(ctx)
  25527. case token.FieldCustomAgentBase:
  25528. return m.OldCustomAgentBase(ctx)
  25529. case token.FieldCustomAgentKey:
  25530. return m.OldCustomAgentKey(ctx)
  25531. case token.FieldOpenaiBase:
  25532. return m.OldOpenaiBase(ctx)
  25533. case token.FieldOpenaiKey:
  25534. return m.OldOpenaiKey(ctx)
  25535. }
  25536. return nil, fmt.Errorf("unknown Token field %s", name)
  25537. }
  25538. // SetField sets the value of a field with the given name. It returns an error if
  25539. // the field is not defined in the schema, or if the type mismatched the field
  25540. // type.
  25541. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25542. switch name {
  25543. case token.FieldCreatedAt:
  25544. v, ok := value.(time.Time)
  25545. if !ok {
  25546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25547. }
  25548. m.SetCreatedAt(v)
  25549. return nil
  25550. case token.FieldUpdatedAt:
  25551. v, ok := value.(time.Time)
  25552. if !ok {
  25553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25554. }
  25555. m.SetUpdatedAt(v)
  25556. return nil
  25557. case token.FieldDeletedAt:
  25558. v, ok := value.(time.Time)
  25559. if !ok {
  25560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25561. }
  25562. m.SetDeletedAt(v)
  25563. return nil
  25564. case token.FieldExpireAt:
  25565. v, ok := value.(time.Time)
  25566. if !ok {
  25567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25568. }
  25569. m.SetExpireAt(v)
  25570. return nil
  25571. case token.FieldToken:
  25572. v, ok := value.(string)
  25573. if !ok {
  25574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25575. }
  25576. m.SetToken(v)
  25577. return nil
  25578. case token.FieldMAC:
  25579. v, ok := value.(string)
  25580. if !ok {
  25581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25582. }
  25583. m.SetMAC(v)
  25584. return nil
  25585. case token.FieldOrganizationID:
  25586. v, ok := value.(uint64)
  25587. if !ok {
  25588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25589. }
  25590. m.SetOrganizationID(v)
  25591. return nil
  25592. case token.FieldAgentID:
  25593. v, ok := value.(uint64)
  25594. if !ok {
  25595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25596. }
  25597. m.SetAgentID(v)
  25598. return nil
  25599. case token.FieldCustomAgentBase:
  25600. v, ok := value.(string)
  25601. if !ok {
  25602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25603. }
  25604. m.SetCustomAgentBase(v)
  25605. return nil
  25606. case token.FieldCustomAgentKey:
  25607. v, ok := value.(string)
  25608. if !ok {
  25609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25610. }
  25611. m.SetCustomAgentKey(v)
  25612. return nil
  25613. case token.FieldOpenaiBase:
  25614. v, ok := value.(string)
  25615. if !ok {
  25616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25617. }
  25618. m.SetOpenaiBase(v)
  25619. return nil
  25620. case token.FieldOpenaiKey:
  25621. v, ok := value.(string)
  25622. if !ok {
  25623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25624. }
  25625. m.SetOpenaiKey(v)
  25626. return nil
  25627. }
  25628. return fmt.Errorf("unknown Token field %s", name)
  25629. }
  25630. // AddedFields returns all numeric fields that were incremented/decremented during
  25631. // this mutation.
  25632. func (m *TokenMutation) AddedFields() []string {
  25633. var fields []string
  25634. if m.addorganization_id != nil {
  25635. fields = append(fields, token.FieldOrganizationID)
  25636. }
  25637. return fields
  25638. }
  25639. // AddedField returns the numeric value that was incremented/decremented on a field
  25640. // with the given name. The second boolean return value indicates that this field
  25641. // was not set, or was not defined in the schema.
  25642. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25643. switch name {
  25644. case token.FieldOrganizationID:
  25645. return m.AddedOrganizationID()
  25646. }
  25647. return nil, false
  25648. }
  25649. // AddField adds the value to the field with the given name. It returns an error if
  25650. // the field is not defined in the schema, or if the type mismatched the field
  25651. // type.
  25652. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25653. switch name {
  25654. case token.FieldOrganizationID:
  25655. v, ok := value.(int64)
  25656. if !ok {
  25657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25658. }
  25659. m.AddOrganizationID(v)
  25660. return nil
  25661. }
  25662. return fmt.Errorf("unknown Token numeric field %s", name)
  25663. }
  25664. // ClearedFields returns all nullable fields that were cleared during this
  25665. // mutation.
  25666. func (m *TokenMutation) ClearedFields() []string {
  25667. var fields []string
  25668. if m.FieldCleared(token.FieldDeletedAt) {
  25669. fields = append(fields, token.FieldDeletedAt)
  25670. }
  25671. if m.FieldCleared(token.FieldExpireAt) {
  25672. fields = append(fields, token.FieldExpireAt)
  25673. }
  25674. if m.FieldCleared(token.FieldToken) {
  25675. fields = append(fields, token.FieldToken)
  25676. }
  25677. if m.FieldCleared(token.FieldMAC) {
  25678. fields = append(fields, token.FieldMAC)
  25679. }
  25680. if m.FieldCleared(token.FieldCustomAgentBase) {
  25681. fields = append(fields, token.FieldCustomAgentBase)
  25682. }
  25683. if m.FieldCleared(token.FieldCustomAgentKey) {
  25684. fields = append(fields, token.FieldCustomAgentKey)
  25685. }
  25686. if m.FieldCleared(token.FieldOpenaiBase) {
  25687. fields = append(fields, token.FieldOpenaiBase)
  25688. }
  25689. if m.FieldCleared(token.FieldOpenaiKey) {
  25690. fields = append(fields, token.FieldOpenaiKey)
  25691. }
  25692. return fields
  25693. }
  25694. // FieldCleared returns a boolean indicating if a field with the given name was
  25695. // cleared in this mutation.
  25696. func (m *TokenMutation) FieldCleared(name string) bool {
  25697. _, ok := m.clearedFields[name]
  25698. return ok
  25699. }
  25700. // ClearField clears the value of the field with the given name. It returns an
  25701. // error if the field is not defined in the schema.
  25702. func (m *TokenMutation) ClearField(name string) error {
  25703. switch name {
  25704. case token.FieldDeletedAt:
  25705. m.ClearDeletedAt()
  25706. return nil
  25707. case token.FieldExpireAt:
  25708. m.ClearExpireAt()
  25709. return nil
  25710. case token.FieldToken:
  25711. m.ClearToken()
  25712. return nil
  25713. case token.FieldMAC:
  25714. m.ClearMAC()
  25715. return nil
  25716. case token.FieldCustomAgentBase:
  25717. m.ClearCustomAgentBase()
  25718. return nil
  25719. case token.FieldCustomAgentKey:
  25720. m.ClearCustomAgentKey()
  25721. return nil
  25722. case token.FieldOpenaiBase:
  25723. m.ClearOpenaiBase()
  25724. return nil
  25725. case token.FieldOpenaiKey:
  25726. m.ClearOpenaiKey()
  25727. return nil
  25728. }
  25729. return fmt.Errorf("unknown Token nullable field %s", name)
  25730. }
  25731. // ResetField resets all changes in the mutation for the field with the given name.
  25732. // It returns an error if the field is not defined in the schema.
  25733. func (m *TokenMutation) ResetField(name string) error {
  25734. switch name {
  25735. case token.FieldCreatedAt:
  25736. m.ResetCreatedAt()
  25737. return nil
  25738. case token.FieldUpdatedAt:
  25739. m.ResetUpdatedAt()
  25740. return nil
  25741. case token.FieldDeletedAt:
  25742. m.ResetDeletedAt()
  25743. return nil
  25744. case token.FieldExpireAt:
  25745. m.ResetExpireAt()
  25746. return nil
  25747. case token.FieldToken:
  25748. m.ResetToken()
  25749. return nil
  25750. case token.FieldMAC:
  25751. m.ResetMAC()
  25752. return nil
  25753. case token.FieldOrganizationID:
  25754. m.ResetOrganizationID()
  25755. return nil
  25756. case token.FieldAgentID:
  25757. m.ResetAgentID()
  25758. return nil
  25759. case token.FieldCustomAgentBase:
  25760. m.ResetCustomAgentBase()
  25761. return nil
  25762. case token.FieldCustomAgentKey:
  25763. m.ResetCustomAgentKey()
  25764. return nil
  25765. case token.FieldOpenaiBase:
  25766. m.ResetOpenaiBase()
  25767. return nil
  25768. case token.FieldOpenaiKey:
  25769. m.ResetOpenaiKey()
  25770. return nil
  25771. }
  25772. return fmt.Errorf("unknown Token field %s", name)
  25773. }
  25774. // AddedEdges returns all edge names that were set/added in this mutation.
  25775. func (m *TokenMutation) AddedEdges() []string {
  25776. edges := make([]string, 0, 1)
  25777. if m.agent != nil {
  25778. edges = append(edges, token.EdgeAgent)
  25779. }
  25780. return edges
  25781. }
  25782. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25783. // name in this mutation.
  25784. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25785. switch name {
  25786. case token.EdgeAgent:
  25787. if id := m.agent; id != nil {
  25788. return []ent.Value{*id}
  25789. }
  25790. }
  25791. return nil
  25792. }
  25793. // RemovedEdges returns all edge names that were removed in this mutation.
  25794. func (m *TokenMutation) RemovedEdges() []string {
  25795. edges := make([]string, 0, 1)
  25796. return edges
  25797. }
  25798. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25799. // the given name in this mutation.
  25800. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25801. return nil
  25802. }
  25803. // ClearedEdges returns all edge names that were cleared in this mutation.
  25804. func (m *TokenMutation) ClearedEdges() []string {
  25805. edges := make([]string, 0, 1)
  25806. if m.clearedagent {
  25807. edges = append(edges, token.EdgeAgent)
  25808. }
  25809. return edges
  25810. }
  25811. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25812. // was cleared in this mutation.
  25813. func (m *TokenMutation) EdgeCleared(name string) bool {
  25814. switch name {
  25815. case token.EdgeAgent:
  25816. return m.clearedagent
  25817. }
  25818. return false
  25819. }
  25820. // ClearEdge clears the value of the edge with the given name. It returns an error
  25821. // if that edge is not defined in the schema.
  25822. func (m *TokenMutation) ClearEdge(name string) error {
  25823. switch name {
  25824. case token.EdgeAgent:
  25825. m.ClearAgent()
  25826. return nil
  25827. }
  25828. return fmt.Errorf("unknown Token unique edge %s", name)
  25829. }
  25830. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25831. // It returns an error if the edge is not defined in the schema.
  25832. func (m *TokenMutation) ResetEdge(name string) error {
  25833. switch name {
  25834. case token.EdgeAgent:
  25835. m.ResetAgent()
  25836. return nil
  25837. }
  25838. return fmt.Errorf("unknown Token edge %s", name)
  25839. }
  25840. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25841. type TutorialMutation struct {
  25842. config
  25843. op Op
  25844. typ string
  25845. id *uint64
  25846. created_at *time.Time
  25847. updated_at *time.Time
  25848. deleted_at *time.Time
  25849. index *int
  25850. addindex *int
  25851. title *string
  25852. content *string
  25853. organization_id *uint64
  25854. addorganization_id *int64
  25855. clearedFields map[string]struct{}
  25856. employee *uint64
  25857. clearedemployee bool
  25858. done bool
  25859. oldValue func(context.Context) (*Tutorial, error)
  25860. predicates []predicate.Tutorial
  25861. }
  25862. var _ ent.Mutation = (*TutorialMutation)(nil)
  25863. // tutorialOption allows management of the mutation configuration using functional options.
  25864. type tutorialOption func(*TutorialMutation)
  25865. // newTutorialMutation creates new mutation for the Tutorial entity.
  25866. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25867. m := &TutorialMutation{
  25868. config: c,
  25869. op: op,
  25870. typ: TypeTutorial,
  25871. clearedFields: make(map[string]struct{}),
  25872. }
  25873. for _, opt := range opts {
  25874. opt(m)
  25875. }
  25876. return m
  25877. }
  25878. // withTutorialID sets the ID field of the mutation.
  25879. func withTutorialID(id uint64) tutorialOption {
  25880. return func(m *TutorialMutation) {
  25881. var (
  25882. err error
  25883. once sync.Once
  25884. value *Tutorial
  25885. )
  25886. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25887. once.Do(func() {
  25888. if m.done {
  25889. err = errors.New("querying old values post mutation is not allowed")
  25890. } else {
  25891. value, err = m.Client().Tutorial.Get(ctx, id)
  25892. }
  25893. })
  25894. return value, err
  25895. }
  25896. m.id = &id
  25897. }
  25898. }
  25899. // withTutorial sets the old Tutorial of the mutation.
  25900. func withTutorial(node *Tutorial) tutorialOption {
  25901. return func(m *TutorialMutation) {
  25902. m.oldValue = func(context.Context) (*Tutorial, error) {
  25903. return node, nil
  25904. }
  25905. m.id = &node.ID
  25906. }
  25907. }
  25908. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25909. // executed in a transaction (ent.Tx), a transactional client is returned.
  25910. func (m TutorialMutation) Client() *Client {
  25911. client := &Client{config: m.config}
  25912. client.init()
  25913. return client
  25914. }
  25915. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25916. // it returns an error otherwise.
  25917. func (m TutorialMutation) Tx() (*Tx, error) {
  25918. if _, ok := m.driver.(*txDriver); !ok {
  25919. return nil, errors.New("ent: mutation is not running in a transaction")
  25920. }
  25921. tx := &Tx{config: m.config}
  25922. tx.init()
  25923. return tx, nil
  25924. }
  25925. // SetID sets the value of the id field. Note that this
  25926. // operation is only accepted on creation of Tutorial entities.
  25927. func (m *TutorialMutation) SetID(id uint64) {
  25928. m.id = &id
  25929. }
  25930. // ID returns the ID value in the mutation. Note that the ID is only available
  25931. // if it was provided to the builder or after it was returned from the database.
  25932. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25933. if m.id == nil {
  25934. return
  25935. }
  25936. return *m.id, true
  25937. }
  25938. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25939. // That means, if the mutation is applied within a transaction with an isolation level such
  25940. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25941. // or updated by the mutation.
  25942. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  25943. switch {
  25944. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25945. id, exists := m.ID()
  25946. if exists {
  25947. return []uint64{id}, nil
  25948. }
  25949. fallthrough
  25950. case m.op.Is(OpUpdate | OpDelete):
  25951. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  25952. default:
  25953. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25954. }
  25955. }
  25956. // SetCreatedAt sets the "created_at" field.
  25957. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  25958. m.created_at = &t
  25959. }
  25960. // CreatedAt returns the value of the "created_at" field in the mutation.
  25961. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  25962. v := m.created_at
  25963. if v == nil {
  25964. return
  25965. }
  25966. return *v, true
  25967. }
  25968. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  25969. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25971. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25972. if !m.op.Is(OpUpdateOne) {
  25973. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25974. }
  25975. if m.id == nil || m.oldValue == nil {
  25976. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25977. }
  25978. oldValue, err := m.oldValue(ctx)
  25979. if err != nil {
  25980. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25981. }
  25982. return oldValue.CreatedAt, nil
  25983. }
  25984. // ResetCreatedAt resets all changes to the "created_at" field.
  25985. func (m *TutorialMutation) ResetCreatedAt() {
  25986. m.created_at = nil
  25987. }
  25988. // SetUpdatedAt sets the "updated_at" field.
  25989. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  25990. m.updated_at = &t
  25991. }
  25992. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25993. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  25994. v := m.updated_at
  25995. if v == nil {
  25996. return
  25997. }
  25998. return *v, true
  25999. }
  26000. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26001. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26003. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26004. if !m.op.Is(OpUpdateOne) {
  26005. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26006. }
  26007. if m.id == nil || m.oldValue == nil {
  26008. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26009. }
  26010. oldValue, err := m.oldValue(ctx)
  26011. if err != nil {
  26012. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26013. }
  26014. return oldValue.UpdatedAt, nil
  26015. }
  26016. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26017. func (m *TutorialMutation) ResetUpdatedAt() {
  26018. m.updated_at = nil
  26019. }
  26020. // SetDeletedAt sets the "deleted_at" field.
  26021. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26022. m.deleted_at = &t
  26023. }
  26024. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26025. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26026. v := m.deleted_at
  26027. if v == nil {
  26028. return
  26029. }
  26030. return *v, true
  26031. }
  26032. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26033. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26035. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26036. if !m.op.Is(OpUpdateOne) {
  26037. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26038. }
  26039. if m.id == nil || m.oldValue == nil {
  26040. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26041. }
  26042. oldValue, err := m.oldValue(ctx)
  26043. if err != nil {
  26044. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26045. }
  26046. return oldValue.DeletedAt, nil
  26047. }
  26048. // ClearDeletedAt clears the value of the "deleted_at" field.
  26049. func (m *TutorialMutation) ClearDeletedAt() {
  26050. m.deleted_at = nil
  26051. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26052. }
  26053. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26054. func (m *TutorialMutation) DeletedAtCleared() bool {
  26055. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26056. return ok
  26057. }
  26058. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26059. func (m *TutorialMutation) ResetDeletedAt() {
  26060. m.deleted_at = nil
  26061. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26062. }
  26063. // SetEmployeeID sets the "employee_id" field.
  26064. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26065. m.employee = &u
  26066. }
  26067. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26068. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26069. v := m.employee
  26070. if v == nil {
  26071. return
  26072. }
  26073. return *v, true
  26074. }
  26075. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26076. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26078. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26079. if !m.op.Is(OpUpdateOne) {
  26080. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26081. }
  26082. if m.id == nil || m.oldValue == nil {
  26083. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26084. }
  26085. oldValue, err := m.oldValue(ctx)
  26086. if err != nil {
  26087. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26088. }
  26089. return oldValue.EmployeeID, nil
  26090. }
  26091. // ResetEmployeeID resets all changes to the "employee_id" field.
  26092. func (m *TutorialMutation) ResetEmployeeID() {
  26093. m.employee = nil
  26094. }
  26095. // SetIndex sets the "index" field.
  26096. func (m *TutorialMutation) SetIndex(i int) {
  26097. m.index = &i
  26098. m.addindex = nil
  26099. }
  26100. // Index returns the value of the "index" field in the mutation.
  26101. func (m *TutorialMutation) Index() (r int, exists bool) {
  26102. v := m.index
  26103. if v == nil {
  26104. return
  26105. }
  26106. return *v, true
  26107. }
  26108. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26109. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26111. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26112. if !m.op.Is(OpUpdateOne) {
  26113. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26114. }
  26115. if m.id == nil || m.oldValue == nil {
  26116. return v, errors.New("OldIndex requires an ID field in the mutation")
  26117. }
  26118. oldValue, err := m.oldValue(ctx)
  26119. if err != nil {
  26120. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26121. }
  26122. return oldValue.Index, nil
  26123. }
  26124. // AddIndex adds i to the "index" field.
  26125. func (m *TutorialMutation) AddIndex(i int) {
  26126. if m.addindex != nil {
  26127. *m.addindex += i
  26128. } else {
  26129. m.addindex = &i
  26130. }
  26131. }
  26132. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26133. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26134. v := m.addindex
  26135. if v == nil {
  26136. return
  26137. }
  26138. return *v, true
  26139. }
  26140. // ResetIndex resets all changes to the "index" field.
  26141. func (m *TutorialMutation) ResetIndex() {
  26142. m.index = nil
  26143. m.addindex = nil
  26144. }
  26145. // SetTitle sets the "title" field.
  26146. func (m *TutorialMutation) SetTitle(s string) {
  26147. m.title = &s
  26148. }
  26149. // Title returns the value of the "title" field in the mutation.
  26150. func (m *TutorialMutation) Title() (r string, exists bool) {
  26151. v := m.title
  26152. if v == nil {
  26153. return
  26154. }
  26155. return *v, true
  26156. }
  26157. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26158. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26160. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26161. if !m.op.Is(OpUpdateOne) {
  26162. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26163. }
  26164. if m.id == nil || m.oldValue == nil {
  26165. return v, errors.New("OldTitle requires an ID field in the mutation")
  26166. }
  26167. oldValue, err := m.oldValue(ctx)
  26168. if err != nil {
  26169. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26170. }
  26171. return oldValue.Title, nil
  26172. }
  26173. // ResetTitle resets all changes to the "title" field.
  26174. func (m *TutorialMutation) ResetTitle() {
  26175. m.title = nil
  26176. }
  26177. // SetContent sets the "content" field.
  26178. func (m *TutorialMutation) SetContent(s string) {
  26179. m.content = &s
  26180. }
  26181. // Content returns the value of the "content" field in the mutation.
  26182. func (m *TutorialMutation) Content() (r string, exists bool) {
  26183. v := m.content
  26184. if v == nil {
  26185. return
  26186. }
  26187. return *v, true
  26188. }
  26189. // OldContent returns the old "content" field's value of the Tutorial entity.
  26190. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26192. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26193. if !m.op.Is(OpUpdateOne) {
  26194. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26195. }
  26196. if m.id == nil || m.oldValue == nil {
  26197. return v, errors.New("OldContent requires an ID field in the mutation")
  26198. }
  26199. oldValue, err := m.oldValue(ctx)
  26200. if err != nil {
  26201. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26202. }
  26203. return oldValue.Content, nil
  26204. }
  26205. // ResetContent resets all changes to the "content" field.
  26206. func (m *TutorialMutation) ResetContent() {
  26207. m.content = nil
  26208. }
  26209. // SetOrganizationID sets the "organization_id" field.
  26210. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26211. m.organization_id = &u
  26212. m.addorganization_id = nil
  26213. }
  26214. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26215. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26216. v := m.organization_id
  26217. if v == nil {
  26218. return
  26219. }
  26220. return *v, true
  26221. }
  26222. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26223. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26225. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26226. if !m.op.Is(OpUpdateOne) {
  26227. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26228. }
  26229. if m.id == nil || m.oldValue == nil {
  26230. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26231. }
  26232. oldValue, err := m.oldValue(ctx)
  26233. if err != nil {
  26234. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26235. }
  26236. return oldValue.OrganizationID, nil
  26237. }
  26238. // AddOrganizationID adds u to the "organization_id" field.
  26239. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26240. if m.addorganization_id != nil {
  26241. *m.addorganization_id += u
  26242. } else {
  26243. m.addorganization_id = &u
  26244. }
  26245. }
  26246. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26247. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26248. v := m.addorganization_id
  26249. if v == nil {
  26250. return
  26251. }
  26252. return *v, true
  26253. }
  26254. // ResetOrganizationID resets all changes to the "organization_id" field.
  26255. func (m *TutorialMutation) ResetOrganizationID() {
  26256. m.organization_id = nil
  26257. m.addorganization_id = nil
  26258. }
  26259. // ClearEmployee clears the "employee" edge to the Employee entity.
  26260. func (m *TutorialMutation) ClearEmployee() {
  26261. m.clearedemployee = true
  26262. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26263. }
  26264. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26265. func (m *TutorialMutation) EmployeeCleared() bool {
  26266. return m.clearedemployee
  26267. }
  26268. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26269. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26270. // EmployeeID instead. It exists only for internal usage by the builders.
  26271. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26272. if id := m.employee; id != nil {
  26273. ids = append(ids, *id)
  26274. }
  26275. return
  26276. }
  26277. // ResetEmployee resets all changes to the "employee" edge.
  26278. func (m *TutorialMutation) ResetEmployee() {
  26279. m.employee = nil
  26280. m.clearedemployee = false
  26281. }
  26282. // Where appends a list predicates to the TutorialMutation builder.
  26283. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26284. m.predicates = append(m.predicates, ps...)
  26285. }
  26286. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26287. // users can use type-assertion to append predicates that do not depend on any generated package.
  26288. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26289. p := make([]predicate.Tutorial, len(ps))
  26290. for i := range ps {
  26291. p[i] = ps[i]
  26292. }
  26293. m.Where(p...)
  26294. }
  26295. // Op returns the operation name.
  26296. func (m *TutorialMutation) Op() Op {
  26297. return m.op
  26298. }
  26299. // SetOp allows setting the mutation operation.
  26300. func (m *TutorialMutation) SetOp(op Op) {
  26301. m.op = op
  26302. }
  26303. // Type returns the node type of this mutation (Tutorial).
  26304. func (m *TutorialMutation) Type() string {
  26305. return m.typ
  26306. }
  26307. // Fields returns all fields that were changed during this mutation. Note that in
  26308. // order to get all numeric fields that were incremented/decremented, call
  26309. // AddedFields().
  26310. func (m *TutorialMutation) Fields() []string {
  26311. fields := make([]string, 0, 8)
  26312. if m.created_at != nil {
  26313. fields = append(fields, tutorial.FieldCreatedAt)
  26314. }
  26315. if m.updated_at != nil {
  26316. fields = append(fields, tutorial.FieldUpdatedAt)
  26317. }
  26318. if m.deleted_at != nil {
  26319. fields = append(fields, tutorial.FieldDeletedAt)
  26320. }
  26321. if m.employee != nil {
  26322. fields = append(fields, tutorial.FieldEmployeeID)
  26323. }
  26324. if m.index != nil {
  26325. fields = append(fields, tutorial.FieldIndex)
  26326. }
  26327. if m.title != nil {
  26328. fields = append(fields, tutorial.FieldTitle)
  26329. }
  26330. if m.content != nil {
  26331. fields = append(fields, tutorial.FieldContent)
  26332. }
  26333. if m.organization_id != nil {
  26334. fields = append(fields, tutorial.FieldOrganizationID)
  26335. }
  26336. return fields
  26337. }
  26338. // Field returns the value of a field with the given name. The second boolean
  26339. // return value indicates that this field was not set, or was not defined in the
  26340. // schema.
  26341. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26342. switch name {
  26343. case tutorial.FieldCreatedAt:
  26344. return m.CreatedAt()
  26345. case tutorial.FieldUpdatedAt:
  26346. return m.UpdatedAt()
  26347. case tutorial.FieldDeletedAt:
  26348. return m.DeletedAt()
  26349. case tutorial.FieldEmployeeID:
  26350. return m.EmployeeID()
  26351. case tutorial.FieldIndex:
  26352. return m.Index()
  26353. case tutorial.FieldTitle:
  26354. return m.Title()
  26355. case tutorial.FieldContent:
  26356. return m.Content()
  26357. case tutorial.FieldOrganizationID:
  26358. return m.OrganizationID()
  26359. }
  26360. return nil, false
  26361. }
  26362. // OldField returns the old value of the field from the database. An error is
  26363. // returned if the mutation operation is not UpdateOne, or the query to the
  26364. // database failed.
  26365. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26366. switch name {
  26367. case tutorial.FieldCreatedAt:
  26368. return m.OldCreatedAt(ctx)
  26369. case tutorial.FieldUpdatedAt:
  26370. return m.OldUpdatedAt(ctx)
  26371. case tutorial.FieldDeletedAt:
  26372. return m.OldDeletedAt(ctx)
  26373. case tutorial.FieldEmployeeID:
  26374. return m.OldEmployeeID(ctx)
  26375. case tutorial.FieldIndex:
  26376. return m.OldIndex(ctx)
  26377. case tutorial.FieldTitle:
  26378. return m.OldTitle(ctx)
  26379. case tutorial.FieldContent:
  26380. return m.OldContent(ctx)
  26381. case tutorial.FieldOrganizationID:
  26382. return m.OldOrganizationID(ctx)
  26383. }
  26384. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26385. }
  26386. // SetField sets the value of a field with the given name. It returns an error if
  26387. // the field is not defined in the schema, or if the type mismatched the field
  26388. // type.
  26389. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26390. switch name {
  26391. case tutorial.FieldCreatedAt:
  26392. v, ok := value.(time.Time)
  26393. if !ok {
  26394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26395. }
  26396. m.SetCreatedAt(v)
  26397. return nil
  26398. case tutorial.FieldUpdatedAt:
  26399. v, ok := value.(time.Time)
  26400. if !ok {
  26401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26402. }
  26403. m.SetUpdatedAt(v)
  26404. return nil
  26405. case tutorial.FieldDeletedAt:
  26406. v, ok := value.(time.Time)
  26407. if !ok {
  26408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26409. }
  26410. m.SetDeletedAt(v)
  26411. return nil
  26412. case tutorial.FieldEmployeeID:
  26413. v, ok := value.(uint64)
  26414. if !ok {
  26415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26416. }
  26417. m.SetEmployeeID(v)
  26418. return nil
  26419. case tutorial.FieldIndex:
  26420. v, ok := value.(int)
  26421. if !ok {
  26422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26423. }
  26424. m.SetIndex(v)
  26425. return nil
  26426. case tutorial.FieldTitle:
  26427. v, ok := value.(string)
  26428. if !ok {
  26429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26430. }
  26431. m.SetTitle(v)
  26432. return nil
  26433. case tutorial.FieldContent:
  26434. v, ok := value.(string)
  26435. if !ok {
  26436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26437. }
  26438. m.SetContent(v)
  26439. return nil
  26440. case tutorial.FieldOrganizationID:
  26441. v, ok := value.(uint64)
  26442. if !ok {
  26443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26444. }
  26445. m.SetOrganizationID(v)
  26446. return nil
  26447. }
  26448. return fmt.Errorf("unknown Tutorial field %s", name)
  26449. }
  26450. // AddedFields returns all numeric fields that were incremented/decremented during
  26451. // this mutation.
  26452. func (m *TutorialMutation) AddedFields() []string {
  26453. var fields []string
  26454. if m.addindex != nil {
  26455. fields = append(fields, tutorial.FieldIndex)
  26456. }
  26457. if m.addorganization_id != nil {
  26458. fields = append(fields, tutorial.FieldOrganizationID)
  26459. }
  26460. return fields
  26461. }
  26462. // AddedField returns the numeric value that was incremented/decremented on a field
  26463. // with the given name. The second boolean return value indicates that this field
  26464. // was not set, or was not defined in the schema.
  26465. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26466. switch name {
  26467. case tutorial.FieldIndex:
  26468. return m.AddedIndex()
  26469. case tutorial.FieldOrganizationID:
  26470. return m.AddedOrganizationID()
  26471. }
  26472. return nil, false
  26473. }
  26474. // AddField adds the value to the field with the given name. It returns an error if
  26475. // the field is not defined in the schema, or if the type mismatched the field
  26476. // type.
  26477. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26478. switch name {
  26479. case tutorial.FieldIndex:
  26480. v, ok := value.(int)
  26481. if !ok {
  26482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26483. }
  26484. m.AddIndex(v)
  26485. return nil
  26486. case tutorial.FieldOrganizationID:
  26487. v, ok := value.(int64)
  26488. if !ok {
  26489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26490. }
  26491. m.AddOrganizationID(v)
  26492. return nil
  26493. }
  26494. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26495. }
  26496. // ClearedFields returns all nullable fields that were cleared during this
  26497. // mutation.
  26498. func (m *TutorialMutation) ClearedFields() []string {
  26499. var fields []string
  26500. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26501. fields = append(fields, tutorial.FieldDeletedAt)
  26502. }
  26503. return fields
  26504. }
  26505. // FieldCleared returns a boolean indicating if a field with the given name was
  26506. // cleared in this mutation.
  26507. func (m *TutorialMutation) FieldCleared(name string) bool {
  26508. _, ok := m.clearedFields[name]
  26509. return ok
  26510. }
  26511. // ClearField clears the value of the field with the given name. It returns an
  26512. // error if the field is not defined in the schema.
  26513. func (m *TutorialMutation) ClearField(name string) error {
  26514. switch name {
  26515. case tutorial.FieldDeletedAt:
  26516. m.ClearDeletedAt()
  26517. return nil
  26518. }
  26519. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26520. }
  26521. // ResetField resets all changes in the mutation for the field with the given name.
  26522. // It returns an error if the field is not defined in the schema.
  26523. func (m *TutorialMutation) ResetField(name string) error {
  26524. switch name {
  26525. case tutorial.FieldCreatedAt:
  26526. m.ResetCreatedAt()
  26527. return nil
  26528. case tutorial.FieldUpdatedAt:
  26529. m.ResetUpdatedAt()
  26530. return nil
  26531. case tutorial.FieldDeletedAt:
  26532. m.ResetDeletedAt()
  26533. return nil
  26534. case tutorial.FieldEmployeeID:
  26535. m.ResetEmployeeID()
  26536. return nil
  26537. case tutorial.FieldIndex:
  26538. m.ResetIndex()
  26539. return nil
  26540. case tutorial.FieldTitle:
  26541. m.ResetTitle()
  26542. return nil
  26543. case tutorial.FieldContent:
  26544. m.ResetContent()
  26545. return nil
  26546. case tutorial.FieldOrganizationID:
  26547. m.ResetOrganizationID()
  26548. return nil
  26549. }
  26550. return fmt.Errorf("unknown Tutorial field %s", name)
  26551. }
  26552. // AddedEdges returns all edge names that were set/added in this mutation.
  26553. func (m *TutorialMutation) AddedEdges() []string {
  26554. edges := make([]string, 0, 1)
  26555. if m.employee != nil {
  26556. edges = append(edges, tutorial.EdgeEmployee)
  26557. }
  26558. return edges
  26559. }
  26560. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26561. // name in this mutation.
  26562. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26563. switch name {
  26564. case tutorial.EdgeEmployee:
  26565. if id := m.employee; id != nil {
  26566. return []ent.Value{*id}
  26567. }
  26568. }
  26569. return nil
  26570. }
  26571. // RemovedEdges returns all edge names that were removed in this mutation.
  26572. func (m *TutorialMutation) RemovedEdges() []string {
  26573. edges := make([]string, 0, 1)
  26574. return edges
  26575. }
  26576. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26577. // the given name in this mutation.
  26578. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26579. return nil
  26580. }
  26581. // ClearedEdges returns all edge names that were cleared in this mutation.
  26582. func (m *TutorialMutation) ClearedEdges() []string {
  26583. edges := make([]string, 0, 1)
  26584. if m.clearedemployee {
  26585. edges = append(edges, tutorial.EdgeEmployee)
  26586. }
  26587. return edges
  26588. }
  26589. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26590. // was cleared in this mutation.
  26591. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26592. switch name {
  26593. case tutorial.EdgeEmployee:
  26594. return m.clearedemployee
  26595. }
  26596. return false
  26597. }
  26598. // ClearEdge clears the value of the edge with the given name. It returns an error
  26599. // if that edge is not defined in the schema.
  26600. func (m *TutorialMutation) ClearEdge(name string) error {
  26601. switch name {
  26602. case tutorial.EdgeEmployee:
  26603. m.ClearEmployee()
  26604. return nil
  26605. }
  26606. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26607. }
  26608. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26609. // It returns an error if the edge is not defined in the schema.
  26610. func (m *TutorialMutation) ResetEdge(name string) error {
  26611. switch name {
  26612. case tutorial.EdgeEmployee:
  26613. m.ResetEmployee()
  26614. return nil
  26615. }
  26616. return fmt.Errorf("unknown Tutorial edge %s", name)
  26617. }
  26618. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26619. type UsageDetailMutation struct {
  26620. config
  26621. op Op
  26622. typ string
  26623. id *uint64
  26624. created_at *time.Time
  26625. updated_at *time.Time
  26626. status *uint8
  26627. addstatus *int8
  26628. _type *int
  26629. add_type *int
  26630. bot_id *string
  26631. receiver_id *string
  26632. app *int
  26633. addapp *int
  26634. session_id *uint64
  26635. addsession_id *int64
  26636. request *string
  26637. response *string
  26638. original_data *custom_types.OriginalData
  26639. total_tokens *uint64
  26640. addtotal_tokens *int64
  26641. prompt_tokens *uint64
  26642. addprompt_tokens *int64
  26643. completion_tokens *uint64
  26644. addcompletion_tokens *int64
  26645. organization_id *uint64
  26646. addorganization_id *int64
  26647. clearedFields map[string]struct{}
  26648. done bool
  26649. oldValue func(context.Context) (*UsageDetail, error)
  26650. predicates []predicate.UsageDetail
  26651. }
  26652. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26653. // usagedetailOption allows management of the mutation configuration using functional options.
  26654. type usagedetailOption func(*UsageDetailMutation)
  26655. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26656. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26657. m := &UsageDetailMutation{
  26658. config: c,
  26659. op: op,
  26660. typ: TypeUsageDetail,
  26661. clearedFields: make(map[string]struct{}),
  26662. }
  26663. for _, opt := range opts {
  26664. opt(m)
  26665. }
  26666. return m
  26667. }
  26668. // withUsageDetailID sets the ID field of the mutation.
  26669. func withUsageDetailID(id uint64) usagedetailOption {
  26670. return func(m *UsageDetailMutation) {
  26671. var (
  26672. err error
  26673. once sync.Once
  26674. value *UsageDetail
  26675. )
  26676. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26677. once.Do(func() {
  26678. if m.done {
  26679. err = errors.New("querying old values post mutation is not allowed")
  26680. } else {
  26681. value, err = m.Client().UsageDetail.Get(ctx, id)
  26682. }
  26683. })
  26684. return value, err
  26685. }
  26686. m.id = &id
  26687. }
  26688. }
  26689. // withUsageDetail sets the old UsageDetail of the mutation.
  26690. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26691. return func(m *UsageDetailMutation) {
  26692. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26693. return node, nil
  26694. }
  26695. m.id = &node.ID
  26696. }
  26697. }
  26698. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26699. // executed in a transaction (ent.Tx), a transactional client is returned.
  26700. func (m UsageDetailMutation) Client() *Client {
  26701. client := &Client{config: m.config}
  26702. client.init()
  26703. return client
  26704. }
  26705. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26706. // it returns an error otherwise.
  26707. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26708. if _, ok := m.driver.(*txDriver); !ok {
  26709. return nil, errors.New("ent: mutation is not running in a transaction")
  26710. }
  26711. tx := &Tx{config: m.config}
  26712. tx.init()
  26713. return tx, nil
  26714. }
  26715. // SetID sets the value of the id field. Note that this
  26716. // operation is only accepted on creation of UsageDetail entities.
  26717. func (m *UsageDetailMutation) SetID(id uint64) {
  26718. m.id = &id
  26719. }
  26720. // ID returns the ID value in the mutation. Note that the ID is only available
  26721. // if it was provided to the builder or after it was returned from the database.
  26722. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26723. if m.id == nil {
  26724. return
  26725. }
  26726. return *m.id, true
  26727. }
  26728. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26729. // That means, if the mutation is applied within a transaction with an isolation level such
  26730. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26731. // or updated by the mutation.
  26732. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26733. switch {
  26734. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26735. id, exists := m.ID()
  26736. if exists {
  26737. return []uint64{id}, nil
  26738. }
  26739. fallthrough
  26740. case m.op.Is(OpUpdate | OpDelete):
  26741. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26742. default:
  26743. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26744. }
  26745. }
  26746. // SetCreatedAt sets the "created_at" field.
  26747. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26748. m.created_at = &t
  26749. }
  26750. // CreatedAt returns the value of the "created_at" field in the mutation.
  26751. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26752. v := m.created_at
  26753. if v == nil {
  26754. return
  26755. }
  26756. return *v, true
  26757. }
  26758. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26759. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26761. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26762. if !m.op.Is(OpUpdateOne) {
  26763. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26764. }
  26765. if m.id == nil || m.oldValue == nil {
  26766. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26767. }
  26768. oldValue, err := m.oldValue(ctx)
  26769. if err != nil {
  26770. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26771. }
  26772. return oldValue.CreatedAt, nil
  26773. }
  26774. // ResetCreatedAt resets all changes to the "created_at" field.
  26775. func (m *UsageDetailMutation) ResetCreatedAt() {
  26776. m.created_at = nil
  26777. }
  26778. // SetUpdatedAt sets the "updated_at" field.
  26779. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26780. m.updated_at = &t
  26781. }
  26782. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26783. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26784. v := m.updated_at
  26785. if v == nil {
  26786. return
  26787. }
  26788. return *v, true
  26789. }
  26790. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26791. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26793. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26794. if !m.op.Is(OpUpdateOne) {
  26795. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26796. }
  26797. if m.id == nil || m.oldValue == nil {
  26798. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26799. }
  26800. oldValue, err := m.oldValue(ctx)
  26801. if err != nil {
  26802. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26803. }
  26804. return oldValue.UpdatedAt, nil
  26805. }
  26806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26807. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26808. m.updated_at = nil
  26809. }
  26810. // SetStatus sets the "status" field.
  26811. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26812. m.status = &u
  26813. m.addstatus = nil
  26814. }
  26815. // Status returns the value of the "status" field in the mutation.
  26816. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26817. v := m.status
  26818. if v == nil {
  26819. return
  26820. }
  26821. return *v, true
  26822. }
  26823. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26824. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26826. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26827. if !m.op.Is(OpUpdateOne) {
  26828. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26829. }
  26830. if m.id == nil || m.oldValue == nil {
  26831. return v, errors.New("OldStatus requires an ID field in the mutation")
  26832. }
  26833. oldValue, err := m.oldValue(ctx)
  26834. if err != nil {
  26835. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26836. }
  26837. return oldValue.Status, nil
  26838. }
  26839. // AddStatus adds u to the "status" field.
  26840. func (m *UsageDetailMutation) AddStatus(u int8) {
  26841. if m.addstatus != nil {
  26842. *m.addstatus += u
  26843. } else {
  26844. m.addstatus = &u
  26845. }
  26846. }
  26847. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26848. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26849. v := m.addstatus
  26850. if v == nil {
  26851. return
  26852. }
  26853. return *v, true
  26854. }
  26855. // ClearStatus clears the value of the "status" field.
  26856. func (m *UsageDetailMutation) ClearStatus() {
  26857. m.status = nil
  26858. m.addstatus = nil
  26859. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26860. }
  26861. // StatusCleared returns if the "status" field was cleared in this mutation.
  26862. func (m *UsageDetailMutation) StatusCleared() bool {
  26863. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26864. return ok
  26865. }
  26866. // ResetStatus resets all changes to the "status" field.
  26867. func (m *UsageDetailMutation) ResetStatus() {
  26868. m.status = nil
  26869. m.addstatus = nil
  26870. delete(m.clearedFields, usagedetail.FieldStatus)
  26871. }
  26872. // SetType sets the "type" field.
  26873. func (m *UsageDetailMutation) SetType(i int) {
  26874. m._type = &i
  26875. m.add_type = nil
  26876. }
  26877. // GetType returns the value of the "type" field in the mutation.
  26878. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26879. v := m._type
  26880. if v == nil {
  26881. return
  26882. }
  26883. return *v, true
  26884. }
  26885. // OldType returns the old "type" field's value of the UsageDetail entity.
  26886. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26888. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26889. if !m.op.Is(OpUpdateOne) {
  26890. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26891. }
  26892. if m.id == nil || m.oldValue == nil {
  26893. return v, errors.New("OldType requires an ID field in the mutation")
  26894. }
  26895. oldValue, err := m.oldValue(ctx)
  26896. if err != nil {
  26897. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26898. }
  26899. return oldValue.Type, nil
  26900. }
  26901. // AddType adds i to the "type" field.
  26902. func (m *UsageDetailMutation) AddType(i int) {
  26903. if m.add_type != nil {
  26904. *m.add_type += i
  26905. } else {
  26906. m.add_type = &i
  26907. }
  26908. }
  26909. // AddedType returns the value that was added to the "type" field in this mutation.
  26910. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26911. v := m.add_type
  26912. if v == nil {
  26913. return
  26914. }
  26915. return *v, true
  26916. }
  26917. // ClearType clears the value of the "type" field.
  26918. func (m *UsageDetailMutation) ClearType() {
  26919. m._type = nil
  26920. m.add_type = nil
  26921. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26922. }
  26923. // TypeCleared returns if the "type" field was cleared in this mutation.
  26924. func (m *UsageDetailMutation) TypeCleared() bool {
  26925. _, ok := m.clearedFields[usagedetail.FieldType]
  26926. return ok
  26927. }
  26928. // ResetType resets all changes to the "type" field.
  26929. func (m *UsageDetailMutation) ResetType() {
  26930. m._type = nil
  26931. m.add_type = nil
  26932. delete(m.clearedFields, usagedetail.FieldType)
  26933. }
  26934. // SetBotID sets the "bot_id" field.
  26935. func (m *UsageDetailMutation) SetBotID(s string) {
  26936. m.bot_id = &s
  26937. }
  26938. // BotID returns the value of the "bot_id" field in the mutation.
  26939. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  26940. v := m.bot_id
  26941. if v == nil {
  26942. return
  26943. }
  26944. return *v, true
  26945. }
  26946. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  26947. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26949. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  26950. if !m.op.Is(OpUpdateOne) {
  26951. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26952. }
  26953. if m.id == nil || m.oldValue == nil {
  26954. return v, errors.New("OldBotID requires an ID field in the mutation")
  26955. }
  26956. oldValue, err := m.oldValue(ctx)
  26957. if err != nil {
  26958. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26959. }
  26960. return oldValue.BotID, nil
  26961. }
  26962. // ResetBotID resets all changes to the "bot_id" field.
  26963. func (m *UsageDetailMutation) ResetBotID() {
  26964. m.bot_id = nil
  26965. }
  26966. // SetReceiverID sets the "receiver_id" field.
  26967. func (m *UsageDetailMutation) SetReceiverID(s string) {
  26968. m.receiver_id = &s
  26969. }
  26970. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  26971. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  26972. v := m.receiver_id
  26973. if v == nil {
  26974. return
  26975. }
  26976. return *v, true
  26977. }
  26978. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  26979. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26981. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  26982. if !m.op.Is(OpUpdateOne) {
  26983. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  26984. }
  26985. if m.id == nil || m.oldValue == nil {
  26986. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  26987. }
  26988. oldValue, err := m.oldValue(ctx)
  26989. if err != nil {
  26990. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  26991. }
  26992. return oldValue.ReceiverID, nil
  26993. }
  26994. // ResetReceiverID resets all changes to the "receiver_id" field.
  26995. func (m *UsageDetailMutation) ResetReceiverID() {
  26996. m.receiver_id = nil
  26997. }
  26998. // SetApp sets the "app" field.
  26999. func (m *UsageDetailMutation) SetApp(i int) {
  27000. m.app = &i
  27001. m.addapp = nil
  27002. }
  27003. // App returns the value of the "app" field in the mutation.
  27004. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27005. v := m.app
  27006. if v == nil {
  27007. return
  27008. }
  27009. return *v, true
  27010. }
  27011. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27012. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27014. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27015. if !m.op.Is(OpUpdateOne) {
  27016. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27017. }
  27018. if m.id == nil || m.oldValue == nil {
  27019. return v, errors.New("OldApp requires an ID field in the mutation")
  27020. }
  27021. oldValue, err := m.oldValue(ctx)
  27022. if err != nil {
  27023. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27024. }
  27025. return oldValue.App, nil
  27026. }
  27027. // AddApp adds i to the "app" field.
  27028. func (m *UsageDetailMutation) AddApp(i int) {
  27029. if m.addapp != nil {
  27030. *m.addapp += i
  27031. } else {
  27032. m.addapp = &i
  27033. }
  27034. }
  27035. // AddedApp returns the value that was added to the "app" field in this mutation.
  27036. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27037. v := m.addapp
  27038. if v == nil {
  27039. return
  27040. }
  27041. return *v, true
  27042. }
  27043. // ClearApp clears the value of the "app" field.
  27044. func (m *UsageDetailMutation) ClearApp() {
  27045. m.app = nil
  27046. m.addapp = nil
  27047. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27048. }
  27049. // AppCleared returns if the "app" field was cleared in this mutation.
  27050. func (m *UsageDetailMutation) AppCleared() bool {
  27051. _, ok := m.clearedFields[usagedetail.FieldApp]
  27052. return ok
  27053. }
  27054. // ResetApp resets all changes to the "app" field.
  27055. func (m *UsageDetailMutation) ResetApp() {
  27056. m.app = nil
  27057. m.addapp = nil
  27058. delete(m.clearedFields, usagedetail.FieldApp)
  27059. }
  27060. // SetSessionID sets the "session_id" field.
  27061. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27062. m.session_id = &u
  27063. m.addsession_id = nil
  27064. }
  27065. // SessionID returns the value of the "session_id" field in the mutation.
  27066. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27067. v := m.session_id
  27068. if v == nil {
  27069. return
  27070. }
  27071. return *v, true
  27072. }
  27073. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27074. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27076. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27077. if !m.op.Is(OpUpdateOne) {
  27078. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27079. }
  27080. if m.id == nil || m.oldValue == nil {
  27081. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27082. }
  27083. oldValue, err := m.oldValue(ctx)
  27084. if err != nil {
  27085. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27086. }
  27087. return oldValue.SessionID, nil
  27088. }
  27089. // AddSessionID adds u to the "session_id" field.
  27090. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27091. if m.addsession_id != nil {
  27092. *m.addsession_id += u
  27093. } else {
  27094. m.addsession_id = &u
  27095. }
  27096. }
  27097. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27098. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27099. v := m.addsession_id
  27100. if v == nil {
  27101. return
  27102. }
  27103. return *v, true
  27104. }
  27105. // ClearSessionID clears the value of the "session_id" field.
  27106. func (m *UsageDetailMutation) ClearSessionID() {
  27107. m.session_id = nil
  27108. m.addsession_id = nil
  27109. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27110. }
  27111. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27112. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27113. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27114. return ok
  27115. }
  27116. // ResetSessionID resets all changes to the "session_id" field.
  27117. func (m *UsageDetailMutation) ResetSessionID() {
  27118. m.session_id = nil
  27119. m.addsession_id = nil
  27120. delete(m.clearedFields, usagedetail.FieldSessionID)
  27121. }
  27122. // SetRequest sets the "request" field.
  27123. func (m *UsageDetailMutation) SetRequest(s string) {
  27124. m.request = &s
  27125. }
  27126. // Request returns the value of the "request" field in the mutation.
  27127. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27128. v := m.request
  27129. if v == nil {
  27130. return
  27131. }
  27132. return *v, true
  27133. }
  27134. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27135. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27137. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27138. if !m.op.Is(OpUpdateOne) {
  27139. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27140. }
  27141. if m.id == nil || m.oldValue == nil {
  27142. return v, errors.New("OldRequest requires an ID field in the mutation")
  27143. }
  27144. oldValue, err := m.oldValue(ctx)
  27145. if err != nil {
  27146. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27147. }
  27148. return oldValue.Request, nil
  27149. }
  27150. // ResetRequest resets all changes to the "request" field.
  27151. func (m *UsageDetailMutation) ResetRequest() {
  27152. m.request = nil
  27153. }
  27154. // SetResponse sets the "response" field.
  27155. func (m *UsageDetailMutation) SetResponse(s string) {
  27156. m.response = &s
  27157. }
  27158. // Response returns the value of the "response" field in the mutation.
  27159. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27160. v := m.response
  27161. if v == nil {
  27162. return
  27163. }
  27164. return *v, true
  27165. }
  27166. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27167. // If the UsageDetail 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 *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27170. if !m.op.Is(OpUpdateOne) {
  27171. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27172. }
  27173. if m.id == nil || m.oldValue == nil {
  27174. return v, errors.New("OldResponse 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 OldResponse: %w", err)
  27179. }
  27180. return oldValue.Response, nil
  27181. }
  27182. // ResetResponse resets all changes to the "response" field.
  27183. func (m *UsageDetailMutation) ResetResponse() {
  27184. m.response = nil
  27185. }
  27186. // SetOriginalData sets the "original_data" field.
  27187. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27188. m.original_data = &ctd
  27189. }
  27190. // OriginalData returns the value of the "original_data" field in the mutation.
  27191. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27192. v := m.original_data
  27193. if v == nil {
  27194. return
  27195. }
  27196. return *v, true
  27197. }
  27198. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27199. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27201. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27202. if !m.op.Is(OpUpdateOne) {
  27203. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27204. }
  27205. if m.id == nil || m.oldValue == nil {
  27206. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27207. }
  27208. oldValue, err := m.oldValue(ctx)
  27209. if err != nil {
  27210. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27211. }
  27212. return oldValue.OriginalData, nil
  27213. }
  27214. // ResetOriginalData resets all changes to the "original_data" field.
  27215. func (m *UsageDetailMutation) ResetOriginalData() {
  27216. m.original_data = nil
  27217. }
  27218. // SetTotalTokens sets the "total_tokens" field.
  27219. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27220. m.total_tokens = &u
  27221. m.addtotal_tokens = nil
  27222. }
  27223. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27224. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27225. v := m.total_tokens
  27226. if v == nil {
  27227. return
  27228. }
  27229. return *v, true
  27230. }
  27231. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27232. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27234. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27235. if !m.op.Is(OpUpdateOne) {
  27236. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27237. }
  27238. if m.id == nil || m.oldValue == nil {
  27239. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27240. }
  27241. oldValue, err := m.oldValue(ctx)
  27242. if err != nil {
  27243. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27244. }
  27245. return oldValue.TotalTokens, nil
  27246. }
  27247. // AddTotalTokens adds u to the "total_tokens" field.
  27248. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27249. if m.addtotal_tokens != nil {
  27250. *m.addtotal_tokens += u
  27251. } else {
  27252. m.addtotal_tokens = &u
  27253. }
  27254. }
  27255. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27256. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27257. v := m.addtotal_tokens
  27258. if v == nil {
  27259. return
  27260. }
  27261. return *v, true
  27262. }
  27263. // ClearTotalTokens clears the value of the "total_tokens" field.
  27264. func (m *UsageDetailMutation) ClearTotalTokens() {
  27265. m.total_tokens = nil
  27266. m.addtotal_tokens = nil
  27267. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27268. }
  27269. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27270. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27271. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27272. return ok
  27273. }
  27274. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27275. func (m *UsageDetailMutation) ResetTotalTokens() {
  27276. m.total_tokens = nil
  27277. m.addtotal_tokens = nil
  27278. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27279. }
  27280. // SetPromptTokens sets the "prompt_tokens" field.
  27281. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27282. m.prompt_tokens = &u
  27283. m.addprompt_tokens = nil
  27284. }
  27285. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27286. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27287. v := m.prompt_tokens
  27288. if v == nil {
  27289. return
  27290. }
  27291. return *v, true
  27292. }
  27293. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27294. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27296. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27297. if !m.op.Is(OpUpdateOne) {
  27298. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27299. }
  27300. if m.id == nil || m.oldValue == nil {
  27301. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27302. }
  27303. oldValue, err := m.oldValue(ctx)
  27304. if err != nil {
  27305. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27306. }
  27307. return oldValue.PromptTokens, nil
  27308. }
  27309. // AddPromptTokens adds u to the "prompt_tokens" field.
  27310. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27311. if m.addprompt_tokens != nil {
  27312. *m.addprompt_tokens += u
  27313. } else {
  27314. m.addprompt_tokens = &u
  27315. }
  27316. }
  27317. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27318. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27319. v := m.addprompt_tokens
  27320. if v == nil {
  27321. return
  27322. }
  27323. return *v, true
  27324. }
  27325. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27326. func (m *UsageDetailMutation) ClearPromptTokens() {
  27327. m.prompt_tokens = nil
  27328. m.addprompt_tokens = nil
  27329. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27330. }
  27331. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27332. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27333. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27334. return ok
  27335. }
  27336. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27337. func (m *UsageDetailMutation) ResetPromptTokens() {
  27338. m.prompt_tokens = nil
  27339. m.addprompt_tokens = nil
  27340. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27341. }
  27342. // SetCompletionTokens sets the "completion_tokens" field.
  27343. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27344. m.completion_tokens = &u
  27345. m.addcompletion_tokens = nil
  27346. }
  27347. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27348. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27349. v := m.completion_tokens
  27350. if v == nil {
  27351. return
  27352. }
  27353. return *v, true
  27354. }
  27355. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27356. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27358. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27359. if !m.op.Is(OpUpdateOne) {
  27360. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27361. }
  27362. if m.id == nil || m.oldValue == nil {
  27363. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27364. }
  27365. oldValue, err := m.oldValue(ctx)
  27366. if err != nil {
  27367. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27368. }
  27369. return oldValue.CompletionTokens, nil
  27370. }
  27371. // AddCompletionTokens adds u to the "completion_tokens" field.
  27372. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27373. if m.addcompletion_tokens != nil {
  27374. *m.addcompletion_tokens += u
  27375. } else {
  27376. m.addcompletion_tokens = &u
  27377. }
  27378. }
  27379. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27380. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27381. v := m.addcompletion_tokens
  27382. if v == nil {
  27383. return
  27384. }
  27385. return *v, true
  27386. }
  27387. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27388. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27389. m.completion_tokens = nil
  27390. m.addcompletion_tokens = nil
  27391. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27392. }
  27393. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27394. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27395. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27396. return ok
  27397. }
  27398. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27399. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27400. m.completion_tokens = nil
  27401. m.addcompletion_tokens = nil
  27402. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27403. }
  27404. // SetOrganizationID sets the "organization_id" field.
  27405. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27406. m.organization_id = &u
  27407. m.addorganization_id = nil
  27408. }
  27409. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27410. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27411. v := m.organization_id
  27412. if v == nil {
  27413. return
  27414. }
  27415. return *v, true
  27416. }
  27417. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27418. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27420. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27421. if !m.op.Is(OpUpdateOne) {
  27422. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27423. }
  27424. if m.id == nil || m.oldValue == nil {
  27425. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27426. }
  27427. oldValue, err := m.oldValue(ctx)
  27428. if err != nil {
  27429. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27430. }
  27431. return oldValue.OrganizationID, nil
  27432. }
  27433. // AddOrganizationID adds u to the "organization_id" field.
  27434. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27435. if m.addorganization_id != nil {
  27436. *m.addorganization_id += u
  27437. } else {
  27438. m.addorganization_id = &u
  27439. }
  27440. }
  27441. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27442. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27443. v := m.addorganization_id
  27444. if v == nil {
  27445. return
  27446. }
  27447. return *v, true
  27448. }
  27449. // ClearOrganizationID clears the value of the "organization_id" field.
  27450. func (m *UsageDetailMutation) ClearOrganizationID() {
  27451. m.organization_id = nil
  27452. m.addorganization_id = nil
  27453. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27454. }
  27455. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27456. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27457. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27458. return ok
  27459. }
  27460. // ResetOrganizationID resets all changes to the "organization_id" field.
  27461. func (m *UsageDetailMutation) ResetOrganizationID() {
  27462. m.organization_id = nil
  27463. m.addorganization_id = nil
  27464. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27465. }
  27466. // Where appends a list predicates to the UsageDetailMutation builder.
  27467. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27468. m.predicates = append(m.predicates, ps...)
  27469. }
  27470. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27471. // users can use type-assertion to append predicates that do not depend on any generated package.
  27472. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27473. p := make([]predicate.UsageDetail, len(ps))
  27474. for i := range ps {
  27475. p[i] = ps[i]
  27476. }
  27477. m.Where(p...)
  27478. }
  27479. // Op returns the operation name.
  27480. func (m *UsageDetailMutation) Op() Op {
  27481. return m.op
  27482. }
  27483. // SetOp allows setting the mutation operation.
  27484. func (m *UsageDetailMutation) SetOp(op Op) {
  27485. m.op = op
  27486. }
  27487. // Type returns the node type of this mutation (UsageDetail).
  27488. func (m *UsageDetailMutation) Type() string {
  27489. return m.typ
  27490. }
  27491. // Fields returns all fields that were changed during this mutation. Note that in
  27492. // order to get all numeric fields that were incremented/decremented, call
  27493. // AddedFields().
  27494. func (m *UsageDetailMutation) Fields() []string {
  27495. fields := make([]string, 0, 15)
  27496. if m.created_at != nil {
  27497. fields = append(fields, usagedetail.FieldCreatedAt)
  27498. }
  27499. if m.updated_at != nil {
  27500. fields = append(fields, usagedetail.FieldUpdatedAt)
  27501. }
  27502. if m.status != nil {
  27503. fields = append(fields, usagedetail.FieldStatus)
  27504. }
  27505. if m._type != nil {
  27506. fields = append(fields, usagedetail.FieldType)
  27507. }
  27508. if m.bot_id != nil {
  27509. fields = append(fields, usagedetail.FieldBotID)
  27510. }
  27511. if m.receiver_id != nil {
  27512. fields = append(fields, usagedetail.FieldReceiverID)
  27513. }
  27514. if m.app != nil {
  27515. fields = append(fields, usagedetail.FieldApp)
  27516. }
  27517. if m.session_id != nil {
  27518. fields = append(fields, usagedetail.FieldSessionID)
  27519. }
  27520. if m.request != nil {
  27521. fields = append(fields, usagedetail.FieldRequest)
  27522. }
  27523. if m.response != nil {
  27524. fields = append(fields, usagedetail.FieldResponse)
  27525. }
  27526. if m.original_data != nil {
  27527. fields = append(fields, usagedetail.FieldOriginalData)
  27528. }
  27529. if m.total_tokens != nil {
  27530. fields = append(fields, usagedetail.FieldTotalTokens)
  27531. }
  27532. if m.prompt_tokens != nil {
  27533. fields = append(fields, usagedetail.FieldPromptTokens)
  27534. }
  27535. if m.completion_tokens != nil {
  27536. fields = append(fields, usagedetail.FieldCompletionTokens)
  27537. }
  27538. if m.organization_id != nil {
  27539. fields = append(fields, usagedetail.FieldOrganizationID)
  27540. }
  27541. return fields
  27542. }
  27543. // Field returns the value of a field with the given name. The second boolean
  27544. // return value indicates that this field was not set, or was not defined in the
  27545. // schema.
  27546. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27547. switch name {
  27548. case usagedetail.FieldCreatedAt:
  27549. return m.CreatedAt()
  27550. case usagedetail.FieldUpdatedAt:
  27551. return m.UpdatedAt()
  27552. case usagedetail.FieldStatus:
  27553. return m.Status()
  27554. case usagedetail.FieldType:
  27555. return m.GetType()
  27556. case usagedetail.FieldBotID:
  27557. return m.BotID()
  27558. case usagedetail.FieldReceiverID:
  27559. return m.ReceiverID()
  27560. case usagedetail.FieldApp:
  27561. return m.App()
  27562. case usagedetail.FieldSessionID:
  27563. return m.SessionID()
  27564. case usagedetail.FieldRequest:
  27565. return m.Request()
  27566. case usagedetail.FieldResponse:
  27567. return m.Response()
  27568. case usagedetail.FieldOriginalData:
  27569. return m.OriginalData()
  27570. case usagedetail.FieldTotalTokens:
  27571. return m.TotalTokens()
  27572. case usagedetail.FieldPromptTokens:
  27573. return m.PromptTokens()
  27574. case usagedetail.FieldCompletionTokens:
  27575. return m.CompletionTokens()
  27576. case usagedetail.FieldOrganizationID:
  27577. return m.OrganizationID()
  27578. }
  27579. return nil, false
  27580. }
  27581. // OldField returns the old value of the field from the database. An error is
  27582. // returned if the mutation operation is not UpdateOne, or the query to the
  27583. // database failed.
  27584. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27585. switch name {
  27586. case usagedetail.FieldCreatedAt:
  27587. return m.OldCreatedAt(ctx)
  27588. case usagedetail.FieldUpdatedAt:
  27589. return m.OldUpdatedAt(ctx)
  27590. case usagedetail.FieldStatus:
  27591. return m.OldStatus(ctx)
  27592. case usagedetail.FieldType:
  27593. return m.OldType(ctx)
  27594. case usagedetail.FieldBotID:
  27595. return m.OldBotID(ctx)
  27596. case usagedetail.FieldReceiverID:
  27597. return m.OldReceiverID(ctx)
  27598. case usagedetail.FieldApp:
  27599. return m.OldApp(ctx)
  27600. case usagedetail.FieldSessionID:
  27601. return m.OldSessionID(ctx)
  27602. case usagedetail.FieldRequest:
  27603. return m.OldRequest(ctx)
  27604. case usagedetail.FieldResponse:
  27605. return m.OldResponse(ctx)
  27606. case usagedetail.FieldOriginalData:
  27607. return m.OldOriginalData(ctx)
  27608. case usagedetail.FieldTotalTokens:
  27609. return m.OldTotalTokens(ctx)
  27610. case usagedetail.FieldPromptTokens:
  27611. return m.OldPromptTokens(ctx)
  27612. case usagedetail.FieldCompletionTokens:
  27613. return m.OldCompletionTokens(ctx)
  27614. case usagedetail.FieldOrganizationID:
  27615. return m.OldOrganizationID(ctx)
  27616. }
  27617. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27618. }
  27619. // SetField sets the value of a field with the given name. It returns an error if
  27620. // the field is not defined in the schema, or if the type mismatched the field
  27621. // type.
  27622. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27623. switch name {
  27624. case usagedetail.FieldCreatedAt:
  27625. v, ok := value.(time.Time)
  27626. if !ok {
  27627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27628. }
  27629. m.SetCreatedAt(v)
  27630. return nil
  27631. case usagedetail.FieldUpdatedAt:
  27632. v, ok := value.(time.Time)
  27633. if !ok {
  27634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27635. }
  27636. m.SetUpdatedAt(v)
  27637. return nil
  27638. case usagedetail.FieldStatus:
  27639. v, ok := value.(uint8)
  27640. if !ok {
  27641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27642. }
  27643. m.SetStatus(v)
  27644. return nil
  27645. case usagedetail.FieldType:
  27646. v, ok := value.(int)
  27647. if !ok {
  27648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27649. }
  27650. m.SetType(v)
  27651. return nil
  27652. case usagedetail.FieldBotID:
  27653. v, ok := value.(string)
  27654. if !ok {
  27655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27656. }
  27657. m.SetBotID(v)
  27658. return nil
  27659. case usagedetail.FieldReceiverID:
  27660. v, ok := value.(string)
  27661. if !ok {
  27662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27663. }
  27664. m.SetReceiverID(v)
  27665. return nil
  27666. case usagedetail.FieldApp:
  27667. v, ok := value.(int)
  27668. if !ok {
  27669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27670. }
  27671. m.SetApp(v)
  27672. return nil
  27673. case usagedetail.FieldSessionID:
  27674. v, ok := value.(uint64)
  27675. if !ok {
  27676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27677. }
  27678. m.SetSessionID(v)
  27679. return nil
  27680. case usagedetail.FieldRequest:
  27681. v, ok := value.(string)
  27682. if !ok {
  27683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27684. }
  27685. m.SetRequest(v)
  27686. return nil
  27687. case usagedetail.FieldResponse:
  27688. v, ok := value.(string)
  27689. if !ok {
  27690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27691. }
  27692. m.SetResponse(v)
  27693. return nil
  27694. case usagedetail.FieldOriginalData:
  27695. v, ok := value.(custom_types.OriginalData)
  27696. if !ok {
  27697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27698. }
  27699. m.SetOriginalData(v)
  27700. return nil
  27701. case usagedetail.FieldTotalTokens:
  27702. v, ok := value.(uint64)
  27703. if !ok {
  27704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27705. }
  27706. m.SetTotalTokens(v)
  27707. return nil
  27708. case usagedetail.FieldPromptTokens:
  27709. v, ok := value.(uint64)
  27710. if !ok {
  27711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27712. }
  27713. m.SetPromptTokens(v)
  27714. return nil
  27715. case usagedetail.FieldCompletionTokens:
  27716. v, ok := value.(uint64)
  27717. if !ok {
  27718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27719. }
  27720. m.SetCompletionTokens(v)
  27721. return nil
  27722. case usagedetail.FieldOrganizationID:
  27723. v, ok := value.(uint64)
  27724. if !ok {
  27725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27726. }
  27727. m.SetOrganizationID(v)
  27728. return nil
  27729. }
  27730. return fmt.Errorf("unknown UsageDetail field %s", name)
  27731. }
  27732. // AddedFields returns all numeric fields that were incremented/decremented during
  27733. // this mutation.
  27734. func (m *UsageDetailMutation) AddedFields() []string {
  27735. var fields []string
  27736. if m.addstatus != nil {
  27737. fields = append(fields, usagedetail.FieldStatus)
  27738. }
  27739. if m.add_type != nil {
  27740. fields = append(fields, usagedetail.FieldType)
  27741. }
  27742. if m.addapp != nil {
  27743. fields = append(fields, usagedetail.FieldApp)
  27744. }
  27745. if m.addsession_id != nil {
  27746. fields = append(fields, usagedetail.FieldSessionID)
  27747. }
  27748. if m.addtotal_tokens != nil {
  27749. fields = append(fields, usagedetail.FieldTotalTokens)
  27750. }
  27751. if m.addprompt_tokens != nil {
  27752. fields = append(fields, usagedetail.FieldPromptTokens)
  27753. }
  27754. if m.addcompletion_tokens != nil {
  27755. fields = append(fields, usagedetail.FieldCompletionTokens)
  27756. }
  27757. if m.addorganization_id != nil {
  27758. fields = append(fields, usagedetail.FieldOrganizationID)
  27759. }
  27760. return fields
  27761. }
  27762. // AddedField returns the numeric value that was incremented/decremented on a field
  27763. // with the given name. The second boolean return value indicates that this field
  27764. // was not set, or was not defined in the schema.
  27765. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27766. switch name {
  27767. case usagedetail.FieldStatus:
  27768. return m.AddedStatus()
  27769. case usagedetail.FieldType:
  27770. return m.AddedType()
  27771. case usagedetail.FieldApp:
  27772. return m.AddedApp()
  27773. case usagedetail.FieldSessionID:
  27774. return m.AddedSessionID()
  27775. case usagedetail.FieldTotalTokens:
  27776. return m.AddedTotalTokens()
  27777. case usagedetail.FieldPromptTokens:
  27778. return m.AddedPromptTokens()
  27779. case usagedetail.FieldCompletionTokens:
  27780. return m.AddedCompletionTokens()
  27781. case usagedetail.FieldOrganizationID:
  27782. return m.AddedOrganizationID()
  27783. }
  27784. return nil, false
  27785. }
  27786. // AddField adds the value to the field with the given name. It returns an error if
  27787. // the field is not defined in the schema, or if the type mismatched the field
  27788. // type.
  27789. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27790. switch name {
  27791. case usagedetail.FieldStatus:
  27792. v, ok := value.(int8)
  27793. if !ok {
  27794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27795. }
  27796. m.AddStatus(v)
  27797. return nil
  27798. case usagedetail.FieldType:
  27799. v, ok := value.(int)
  27800. if !ok {
  27801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27802. }
  27803. m.AddType(v)
  27804. return nil
  27805. case usagedetail.FieldApp:
  27806. v, ok := value.(int)
  27807. if !ok {
  27808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27809. }
  27810. m.AddApp(v)
  27811. return nil
  27812. case usagedetail.FieldSessionID:
  27813. v, ok := value.(int64)
  27814. if !ok {
  27815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27816. }
  27817. m.AddSessionID(v)
  27818. return nil
  27819. case usagedetail.FieldTotalTokens:
  27820. v, ok := value.(int64)
  27821. if !ok {
  27822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27823. }
  27824. m.AddTotalTokens(v)
  27825. return nil
  27826. case usagedetail.FieldPromptTokens:
  27827. v, ok := value.(int64)
  27828. if !ok {
  27829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27830. }
  27831. m.AddPromptTokens(v)
  27832. return nil
  27833. case usagedetail.FieldCompletionTokens:
  27834. v, ok := value.(int64)
  27835. if !ok {
  27836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27837. }
  27838. m.AddCompletionTokens(v)
  27839. return nil
  27840. case usagedetail.FieldOrganizationID:
  27841. v, ok := value.(int64)
  27842. if !ok {
  27843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27844. }
  27845. m.AddOrganizationID(v)
  27846. return nil
  27847. }
  27848. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27849. }
  27850. // ClearedFields returns all nullable fields that were cleared during this
  27851. // mutation.
  27852. func (m *UsageDetailMutation) ClearedFields() []string {
  27853. var fields []string
  27854. if m.FieldCleared(usagedetail.FieldStatus) {
  27855. fields = append(fields, usagedetail.FieldStatus)
  27856. }
  27857. if m.FieldCleared(usagedetail.FieldType) {
  27858. fields = append(fields, usagedetail.FieldType)
  27859. }
  27860. if m.FieldCleared(usagedetail.FieldApp) {
  27861. fields = append(fields, usagedetail.FieldApp)
  27862. }
  27863. if m.FieldCleared(usagedetail.FieldSessionID) {
  27864. fields = append(fields, usagedetail.FieldSessionID)
  27865. }
  27866. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27867. fields = append(fields, usagedetail.FieldTotalTokens)
  27868. }
  27869. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27870. fields = append(fields, usagedetail.FieldPromptTokens)
  27871. }
  27872. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27873. fields = append(fields, usagedetail.FieldCompletionTokens)
  27874. }
  27875. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27876. fields = append(fields, usagedetail.FieldOrganizationID)
  27877. }
  27878. return fields
  27879. }
  27880. // FieldCleared returns a boolean indicating if a field with the given name was
  27881. // cleared in this mutation.
  27882. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27883. _, ok := m.clearedFields[name]
  27884. return ok
  27885. }
  27886. // ClearField clears the value of the field with the given name. It returns an
  27887. // error if the field is not defined in the schema.
  27888. func (m *UsageDetailMutation) ClearField(name string) error {
  27889. switch name {
  27890. case usagedetail.FieldStatus:
  27891. m.ClearStatus()
  27892. return nil
  27893. case usagedetail.FieldType:
  27894. m.ClearType()
  27895. return nil
  27896. case usagedetail.FieldApp:
  27897. m.ClearApp()
  27898. return nil
  27899. case usagedetail.FieldSessionID:
  27900. m.ClearSessionID()
  27901. return nil
  27902. case usagedetail.FieldTotalTokens:
  27903. m.ClearTotalTokens()
  27904. return nil
  27905. case usagedetail.FieldPromptTokens:
  27906. m.ClearPromptTokens()
  27907. return nil
  27908. case usagedetail.FieldCompletionTokens:
  27909. m.ClearCompletionTokens()
  27910. return nil
  27911. case usagedetail.FieldOrganizationID:
  27912. m.ClearOrganizationID()
  27913. return nil
  27914. }
  27915. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27916. }
  27917. // ResetField resets all changes in the mutation for the field with the given name.
  27918. // It returns an error if the field is not defined in the schema.
  27919. func (m *UsageDetailMutation) ResetField(name string) error {
  27920. switch name {
  27921. case usagedetail.FieldCreatedAt:
  27922. m.ResetCreatedAt()
  27923. return nil
  27924. case usagedetail.FieldUpdatedAt:
  27925. m.ResetUpdatedAt()
  27926. return nil
  27927. case usagedetail.FieldStatus:
  27928. m.ResetStatus()
  27929. return nil
  27930. case usagedetail.FieldType:
  27931. m.ResetType()
  27932. return nil
  27933. case usagedetail.FieldBotID:
  27934. m.ResetBotID()
  27935. return nil
  27936. case usagedetail.FieldReceiverID:
  27937. m.ResetReceiverID()
  27938. return nil
  27939. case usagedetail.FieldApp:
  27940. m.ResetApp()
  27941. return nil
  27942. case usagedetail.FieldSessionID:
  27943. m.ResetSessionID()
  27944. return nil
  27945. case usagedetail.FieldRequest:
  27946. m.ResetRequest()
  27947. return nil
  27948. case usagedetail.FieldResponse:
  27949. m.ResetResponse()
  27950. return nil
  27951. case usagedetail.FieldOriginalData:
  27952. m.ResetOriginalData()
  27953. return nil
  27954. case usagedetail.FieldTotalTokens:
  27955. m.ResetTotalTokens()
  27956. return nil
  27957. case usagedetail.FieldPromptTokens:
  27958. m.ResetPromptTokens()
  27959. return nil
  27960. case usagedetail.FieldCompletionTokens:
  27961. m.ResetCompletionTokens()
  27962. return nil
  27963. case usagedetail.FieldOrganizationID:
  27964. m.ResetOrganizationID()
  27965. return nil
  27966. }
  27967. return fmt.Errorf("unknown UsageDetail field %s", name)
  27968. }
  27969. // AddedEdges returns all edge names that were set/added in this mutation.
  27970. func (m *UsageDetailMutation) AddedEdges() []string {
  27971. edges := make([]string, 0, 0)
  27972. return edges
  27973. }
  27974. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27975. // name in this mutation.
  27976. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  27977. return nil
  27978. }
  27979. // RemovedEdges returns all edge names that were removed in this mutation.
  27980. func (m *UsageDetailMutation) RemovedEdges() []string {
  27981. edges := make([]string, 0, 0)
  27982. return edges
  27983. }
  27984. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27985. // the given name in this mutation.
  27986. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  27987. return nil
  27988. }
  27989. // ClearedEdges returns all edge names that were cleared in this mutation.
  27990. func (m *UsageDetailMutation) ClearedEdges() []string {
  27991. edges := make([]string, 0, 0)
  27992. return edges
  27993. }
  27994. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27995. // was cleared in this mutation.
  27996. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  27997. return false
  27998. }
  27999. // ClearEdge clears the value of the edge with the given name. It returns an error
  28000. // if that edge is not defined in the schema.
  28001. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28002. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28003. }
  28004. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28005. // It returns an error if the edge is not defined in the schema.
  28006. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28007. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28008. }
  28009. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28010. type UsageStatisticDayMutation struct {
  28011. config
  28012. op Op
  28013. typ string
  28014. id *uint64
  28015. created_at *time.Time
  28016. updated_at *time.Time
  28017. status *uint8
  28018. addstatus *int8
  28019. deleted_at *time.Time
  28020. addtime *uint64
  28021. addaddtime *int64
  28022. _type *int
  28023. add_type *int
  28024. bot_id *string
  28025. organization_id *uint64
  28026. addorganization_id *int64
  28027. ai_response *uint64
  28028. addai_response *int64
  28029. sop_run *uint64
  28030. addsop_run *int64
  28031. total_friend *uint64
  28032. addtotal_friend *int64
  28033. total_group *uint64
  28034. addtotal_group *int64
  28035. account_balance *uint64
  28036. addaccount_balance *int64
  28037. consume_token *uint64
  28038. addconsume_token *int64
  28039. active_user *uint64
  28040. addactive_user *int64
  28041. new_user *int64
  28042. addnew_user *int64
  28043. label_dist *[]custom_types.LabelDist
  28044. appendlabel_dist []custom_types.LabelDist
  28045. clearedFields map[string]struct{}
  28046. done bool
  28047. oldValue func(context.Context) (*UsageStatisticDay, error)
  28048. predicates []predicate.UsageStatisticDay
  28049. }
  28050. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28051. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28052. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28053. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28054. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28055. m := &UsageStatisticDayMutation{
  28056. config: c,
  28057. op: op,
  28058. typ: TypeUsageStatisticDay,
  28059. clearedFields: make(map[string]struct{}),
  28060. }
  28061. for _, opt := range opts {
  28062. opt(m)
  28063. }
  28064. return m
  28065. }
  28066. // withUsageStatisticDayID sets the ID field of the mutation.
  28067. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28068. return func(m *UsageStatisticDayMutation) {
  28069. var (
  28070. err error
  28071. once sync.Once
  28072. value *UsageStatisticDay
  28073. )
  28074. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28075. once.Do(func() {
  28076. if m.done {
  28077. err = errors.New("querying old values post mutation is not allowed")
  28078. } else {
  28079. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28080. }
  28081. })
  28082. return value, err
  28083. }
  28084. m.id = &id
  28085. }
  28086. }
  28087. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28088. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28089. return func(m *UsageStatisticDayMutation) {
  28090. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28091. return node, nil
  28092. }
  28093. m.id = &node.ID
  28094. }
  28095. }
  28096. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28097. // executed in a transaction (ent.Tx), a transactional client is returned.
  28098. func (m UsageStatisticDayMutation) Client() *Client {
  28099. client := &Client{config: m.config}
  28100. client.init()
  28101. return client
  28102. }
  28103. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28104. // it returns an error otherwise.
  28105. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28106. if _, ok := m.driver.(*txDriver); !ok {
  28107. return nil, errors.New("ent: mutation is not running in a transaction")
  28108. }
  28109. tx := &Tx{config: m.config}
  28110. tx.init()
  28111. return tx, nil
  28112. }
  28113. // SetID sets the value of the id field. Note that this
  28114. // operation is only accepted on creation of UsageStatisticDay entities.
  28115. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28116. m.id = &id
  28117. }
  28118. // ID returns the ID value in the mutation. Note that the ID is only available
  28119. // if it was provided to the builder or after it was returned from the database.
  28120. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28121. if m.id == nil {
  28122. return
  28123. }
  28124. return *m.id, true
  28125. }
  28126. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28127. // That means, if the mutation is applied within a transaction with an isolation level such
  28128. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28129. // or updated by the mutation.
  28130. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28131. switch {
  28132. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28133. id, exists := m.ID()
  28134. if exists {
  28135. return []uint64{id}, nil
  28136. }
  28137. fallthrough
  28138. case m.op.Is(OpUpdate | OpDelete):
  28139. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28140. default:
  28141. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28142. }
  28143. }
  28144. // SetCreatedAt sets the "created_at" field.
  28145. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28146. m.created_at = &t
  28147. }
  28148. // CreatedAt returns the value of the "created_at" field in the mutation.
  28149. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28150. v := m.created_at
  28151. if v == nil {
  28152. return
  28153. }
  28154. return *v, true
  28155. }
  28156. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28157. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28159. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28160. if !m.op.Is(OpUpdateOne) {
  28161. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28162. }
  28163. if m.id == nil || m.oldValue == nil {
  28164. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28165. }
  28166. oldValue, err := m.oldValue(ctx)
  28167. if err != nil {
  28168. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28169. }
  28170. return oldValue.CreatedAt, nil
  28171. }
  28172. // ResetCreatedAt resets all changes to the "created_at" field.
  28173. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28174. m.created_at = nil
  28175. }
  28176. // SetUpdatedAt sets the "updated_at" field.
  28177. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28178. m.updated_at = &t
  28179. }
  28180. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28181. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28182. v := m.updated_at
  28183. if v == nil {
  28184. return
  28185. }
  28186. return *v, true
  28187. }
  28188. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28189. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28191. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28192. if !m.op.Is(OpUpdateOne) {
  28193. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28194. }
  28195. if m.id == nil || m.oldValue == nil {
  28196. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28197. }
  28198. oldValue, err := m.oldValue(ctx)
  28199. if err != nil {
  28200. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28201. }
  28202. return oldValue.UpdatedAt, nil
  28203. }
  28204. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28205. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28206. m.updated_at = nil
  28207. }
  28208. // SetStatus sets the "status" field.
  28209. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28210. m.status = &u
  28211. m.addstatus = nil
  28212. }
  28213. // Status returns the value of the "status" field in the mutation.
  28214. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28215. v := m.status
  28216. if v == nil {
  28217. return
  28218. }
  28219. return *v, true
  28220. }
  28221. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28222. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28224. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28225. if !m.op.Is(OpUpdateOne) {
  28226. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28227. }
  28228. if m.id == nil || m.oldValue == nil {
  28229. return v, errors.New("OldStatus requires an ID field in the mutation")
  28230. }
  28231. oldValue, err := m.oldValue(ctx)
  28232. if err != nil {
  28233. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28234. }
  28235. return oldValue.Status, nil
  28236. }
  28237. // AddStatus adds u to the "status" field.
  28238. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28239. if m.addstatus != nil {
  28240. *m.addstatus += u
  28241. } else {
  28242. m.addstatus = &u
  28243. }
  28244. }
  28245. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28246. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28247. v := m.addstatus
  28248. if v == nil {
  28249. return
  28250. }
  28251. return *v, true
  28252. }
  28253. // ClearStatus clears the value of the "status" field.
  28254. func (m *UsageStatisticDayMutation) ClearStatus() {
  28255. m.status = nil
  28256. m.addstatus = nil
  28257. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28258. }
  28259. // StatusCleared returns if the "status" field was cleared in this mutation.
  28260. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28261. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28262. return ok
  28263. }
  28264. // ResetStatus resets all changes to the "status" field.
  28265. func (m *UsageStatisticDayMutation) ResetStatus() {
  28266. m.status = nil
  28267. m.addstatus = nil
  28268. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28269. }
  28270. // SetDeletedAt sets the "deleted_at" field.
  28271. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28272. m.deleted_at = &t
  28273. }
  28274. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28275. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28276. v := m.deleted_at
  28277. if v == nil {
  28278. return
  28279. }
  28280. return *v, true
  28281. }
  28282. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28283. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28285. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28286. if !m.op.Is(OpUpdateOne) {
  28287. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28288. }
  28289. if m.id == nil || m.oldValue == nil {
  28290. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28291. }
  28292. oldValue, err := m.oldValue(ctx)
  28293. if err != nil {
  28294. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28295. }
  28296. return oldValue.DeletedAt, nil
  28297. }
  28298. // ClearDeletedAt clears the value of the "deleted_at" field.
  28299. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28300. m.deleted_at = nil
  28301. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28302. }
  28303. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28304. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28305. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28306. return ok
  28307. }
  28308. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28309. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28310. m.deleted_at = nil
  28311. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28312. }
  28313. // SetAddtime sets the "addtime" field.
  28314. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28315. m.addtime = &u
  28316. m.addaddtime = nil
  28317. }
  28318. // Addtime returns the value of the "addtime" field in the mutation.
  28319. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28320. v := m.addtime
  28321. if v == nil {
  28322. return
  28323. }
  28324. return *v, true
  28325. }
  28326. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28327. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28329. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28330. if !m.op.Is(OpUpdateOne) {
  28331. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28332. }
  28333. if m.id == nil || m.oldValue == nil {
  28334. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28335. }
  28336. oldValue, err := m.oldValue(ctx)
  28337. if err != nil {
  28338. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28339. }
  28340. return oldValue.Addtime, nil
  28341. }
  28342. // AddAddtime adds u to the "addtime" field.
  28343. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28344. if m.addaddtime != nil {
  28345. *m.addaddtime += u
  28346. } else {
  28347. m.addaddtime = &u
  28348. }
  28349. }
  28350. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28351. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28352. v := m.addaddtime
  28353. if v == nil {
  28354. return
  28355. }
  28356. return *v, true
  28357. }
  28358. // ResetAddtime resets all changes to the "addtime" field.
  28359. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28360. m.addtime = nil
  28361. m.addaddtime = nil
  28362. }
  28363. // SetType sets the "type" field.
  28364. func (m *UsageStatisticDayMutation) SetType(i int) {
  28365. m._type = &i
  28366. m.add_type = nil
  28367. }
  28368. // GetType returns the value of the "type" field in the mutation.
  28369. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28370. v := m._type
  28371. if v == nil {
  28372. return
  28373. }
  28374. return *v, true
  28375. }
  28376. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28377. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28379. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28380. if !m.op.Is(OpUpdateOne) {
  28381. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28382. }
  28383. if m.id == nil || m.oldValue == nil {
  28384. return v, errors.New("OldType requires an ID field in the mutation")
  28385. }
  28386. oldValue, err := m.oldValue(ctx)
  28387. if err != nil {
  28388. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28389. }
  28390. return oldValue.Type, nil
  28391. }
  28392. // AddType adds i to the "type" field.
  28393. func (m *UsageStatisticDayMutation) AddType(i int) {
  28394. if m.add_type != nil {
  28395. *m.add_type += i
  28396. } else {
  28397. m.add_type = &i
  28398. }
  28399. }
  28400. // AddedType returns the value that was added to the "type" field in this mutation.
  28401. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28402. v := m.add_type
  28403. if v == nil {
  28404. return
  28405. }
  28406. return *v, true
  28407. }
  28408. // ResetType resets all changes to the "type" field.
  28409. func (m *UsageStatisticDayMutation) ResetType() {
  28410. m._type = nil
  28411. m.add_type = nil
  28412. }
  28413. // SetBotID sets the "bot_id" field.
  28414. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28415. m.bot_id = &s
  28416. }
  28417. // BotID returns the value of the "bot_id" field in the mutation.
  28418. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28419. v := m.bot_id
  28420. if v == nil {
  28421. return
  28422. }
  28423. return *v, true
  28424. }
  28425. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28426. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28428. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28429. if !m.op.Is(OpUpdateOne) {
  28430. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28431. }
  28432. if m.id == nil || m.oldValue == nil {
  28433. return v, errors.New("OldBotID requires an ID field in the mutation")
  28434. }
  28435. oldValue, err := m.oldValue(ctx)
  28436. if err != nil {
  28437. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28438. }
  28439. return oldValue.BotID, nil
  28440. }
  28441. // ClearBotID clears the value of the "bot_id" field.
  28442. func (m *UsageStatisticDayMutation) ClearBotID() {
  28443. m.bot_id = nil
  28444. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28445. }
  28446. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28447. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28448. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28449. return ok
  28450. }
  28451. // ResetBotID resets all changes to the "bot_id" field.
  28452. func (m *UsageStatisticDayMutation) ResetBotID() {
  28453. m.bot_id = nil
  28454. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28455. }
  28456. // SetOrganizationID sets the "organization_id" field.
  28457. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28458. m.organization_id = &u
  28459. m.addorganization_id = nil
  28460. }
  28461. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28462. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28463. v := m.organization_id
  28464. if v == nil {
  28465. return
  28466. }
  28467. return *v, true
  28468. }
  28469. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28470. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28472. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28473. if !m.op.Is(OpUpdateOne) {
  28474. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28475. }
  28476. if m.id == nil || m.oldValue == nil {
  28477. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28478. }
  28479. oldValue, err := m.oldValue(ctx)
  28480. if err != nil {
  28481. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28482. }
  28483. return oldValue.OrganizationID, nil
  28484. }
  28485. // AddOrganizationID adds u to the "organization_id" field.
  28486. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28487. if m.addorganization_id != nil {
  28488. *m.addorganization_id += u
  28489. } else {
  28490. m.addorganization_id = &u
  28491. }
  28492. }
  28493. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28494. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28495. v := m.addorganization_id
  28496. if v == nil {
  28497. return
  28498. }
  28499. return *v, true
  28500. }
  28501. // ClearOrganizationID clears the value of the "organization_id" field.
  28502. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28503. m.organization_id = nil
  28504. m.addorganization_id = nil
  28505. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28506. }
  28507. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28508. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28509. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28510. return ok
  28511. }
  28512. // ResetOrganizationID resets all changes to the "organization_id" field.
  28513. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28514. m.organization_id = nil
  28515. m.addorganization_id = nil
  28516. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28517. }
  28518. // SetAiResponse sets the "ai_response" field.
  28519. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28520. m.ai_response = &u
  28521. m.addai_response = nil
  28522. }
  28523. // AiResponse returns the value of the "ai_response" field in the mutation.
  28524. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28525. v := m.ai_response
  28526. if v == nil {
  28527. return
  28528. }
  28529. return *v, true
  28530. }
  28531. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28532. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28534. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28535. if !m.op.Is(OpUpdateOne) {
  28536. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28537. }
  28538. if m.id == nil || m.oldValue == nil {
  28539. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28540. }
  28541. oldValue, err := m.oldValue(ctx)
  28542. if err != nil {
  28543. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28544. }
  28545. return oldValue.AiResponse, nil
  28546. }
  28547. // AddAiResponse adds u to the "ai_response" field.
  28548. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28549. if m.addai_response != nil {
  28550. *m.addai_response += u
  28551. } else {
  28552. m.addai_response = &u
  28553. }
  28554. }
  28555. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28556. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28557. v := m.addai_response
  28558. if v == nil {
  28559. return
  28560. }
  28561. return *v, true
  28562. }
  28563. // ResetAiResponse resets all changes to the "ai_response" field.
  28564. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28565. m.ai_response = nil
  28566. m.addai_response = nil
  28567. }
  28568. // SetSopRun sets the "sop_run" field.
  28569. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28570. m.sop_run = &u
  28571. m.addsop_run = nil
  28572. }
  28573. // SopRun returns the value of the "sop_run" field in the mutation.
  28574. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28575. v := m.sop_run
  28576. if v == nil {
  28577. return
  28578. }
  28579. return *v, true
  28580. }
  28581. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28582. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28584. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28585. if !m.op.Is(OpUpdateOne) {
  28586. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28587. }
  28588. if m.id == nil || m.oldValue == nil {
  28589. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28590. }
  28591. oldValue, err := m.oldValue(ctx)
  28592. if err != nil {
  28593. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28594. }
  28595. return oldValue.SopRun, nil
  28596. }
  28597. // AddSopRun adds u to the "sop_run" field.
  28598. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28599. if m.addsop_run != nil {
  28600. *m.addsop_run += u
  28601. } else {
  28602. m.addsop_run = &u
  28603. }
  28604. }
  28605. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28606. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28607. v := m.addsop_run
  28608. if v == nil {
  28609. return
  28610. }
  28611. return *v, true
  28612. }
  28613. // ResetSopRun resets all changes to the "sop_run" field.
  28614. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28615. m.sop_run = nil
  28616. m.addsop_run = nil
  28617. }
  28618. // SetTotalFriend sets the "total_friend" field.
  28619. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28620. m.total_friend = &u
  28621. m.addtotal_friend = nil
  28622. }
  28623. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28624. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28625. v := m.total_friend
  28626. if v == nil {
  28627. return
  28628. }
  28629. return *v, true
  28630. }
  28631. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28632. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28634. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28635. if !m.op.Is(OpUpdateOne) {
  28636. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28637. }
  28638. if m.id == nil || m.oldValue == nil {
  28639. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28640. }
  28641. oldValue, err := m.oldValue(ctx)
  28642. if err != nil {
  28643. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28644. }
  28645. return oldValue.TotalFriend, nil
  28646. }
  28647. // AddTotalFriend adds u to the "total_friend" field.
  28648. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28649. if m.addtotal_friend != nil {
  28650. *m.addtotal_friend += u
  28651. } else {
  28652. m.addtotal_friend = &u
  28653. }
  28654. }
  28655. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28656. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28657. v := m.addtotal_friend
  28658. if v == nil {
  28659. return
  28660. }
  28661. return *v, true
  28662. }
  28663. // ResetTotalFriend resets all changes to the "total_friend" field.
  28664. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28665. m.total_friend = nil
  28666. m.addtotal_friend = nil
  28667. }
  28668. // SetTotalGroup sets the "total_group" field.
  28669. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28670. m.total_group = &u
  28671. m.addtotal_group = nil
  28672. }
  28673. // TotalGroup returns the value of the "total_group" field in the mutation.
  28674. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28675. v := m.total_group
  28676. if v == nil {
  28677. return
  28678. }
  28679. return *v, true
  28680. }
  28681. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28682. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28684. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28685. if !m.op.Is(OpUpdateOne) {
  28686. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28687. }
  28688. if m.id == nil || m.oldValue == nil {
  28689. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28690. }
  28691. oldValue, err := m.oldValue(ctx)
  28692. if err != nil {
  28693. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28694. }
  28695. return oldValue.TotalGroup, nil
  28696. }
  28697. // AddTotalGroup adds u to the "total_group" field.
  28698. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28699. if m.addtotal_group != nil {
  28700. *m.addtotal_group += u
  28701. } else {
  28702. m.addtotal_group = &u
  28703. }
  28704. }
  28705. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28706. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28707. v := m.addtotal_group
  28708. if v == nil {
  28709. return
  28710. }
  28711. return *v, true
  28712. }
  28713. // ResetTotalGroup resets all changes to the "total_group" field.
  28714. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28715. m.total_group = nil
  28716. m.addtotal_group = nil
  28717. }
  28718. // SetAccountBalance sets the "account_balance" field.
  28719. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28720. m.account_balance = &u
  28721. m.addaccount_balance = nil
  28722. }
  28723. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28724. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28725. v := m.account_balance
  28726. if v == nil {
  28727. return
  28728. }
  28729. return *v, true
  28730. }
  28731. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28732. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28734. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28735. if !m.op.Is(OpUpdateOne) {
  28736. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28737. }
  28738. if m.id == nil || m.oldValue == nil {
  28739. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28740. }
  28741. oldValue, err := m.oldValue(ctx)
  28742. if err != nil {
  28743. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28744. }
  28745. return oldValue.AccountBalance, nil
  28746. }
  28747. // AddAccountBalance adds u to the "account_balance" field.
  28748. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28749. if m.addaccount_balance != nil {
  28750. *m.addaccount_balance += u
  28751. } else {
  28752. m.addaccount_balance = &u
  28753. }
  28754. }
  28755. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28756. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28757. v := m.addaccount_balance
  28758. if v == nil {
  28759. return
  28760. }
  28761. return *v, true
  28762. }
  28763. // ResetAccountBalance resets all changes to the "account_balance" field.
  28764. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28765. m.account_balance = nil
  28766. m.addaccount_balance = nil
  28767. }
  28768. // SetConsumeToken sets the "consume_token" field.
  28769. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28770. m.consume_token = &u
  28771. m.addconsume_token = nil
  28772. }
  28773. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28774. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28775. v := m.consume_token
  28776. if v == nil {
  28777. return
  28778. }
  28779. return *v, true
  28780. }
  28781. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28782. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28784. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28785. if !m.op.Is(OpUpdateOne) {
  28786. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28787. }
  28788. if m.id == nil || m.oldValue == nil {
  28789. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28790. }
  28791. oldValue, err := m.oldValue(ctx)
  28792. if err != nil {
  28793. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28794. }
  28795. return oldValue.ConsumeToken, nil
  28796. }
  28797. // AddConsumeToken adds u to the "consume_token" field.
  28798. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28799. if m.addconsume_token != nil {
  28800. *m.addconsume_token += u
  28801. } else {
  28802. m.addconsume_token = &u
  28803. }
  28804. }
  28805. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28806. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28807. v := m.addconsume_token
  28808. if v == nil {
  28809. return
  28810. }
  28811. return *v, true
  28812. }
  28813. // ResetConsumeToken resets all changes to the "consume_token" field.
  28814. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28815. m.consume_token = nil
  28816. m.addconsume_token = nil
  28817. }
  28818. // SetActiveUser sets the "active_user" field.
  28819. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28820. m.active_user = &u
  28821. m.addactive_user = nil
  28822. }
  28823. // ActiveUser returns the value of the "active_user" field in the mutation.
  28824. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28825. v := m.active_user
  28826. if v == nil {
  28827. return
  28828. }
  28829. return *v, true
  28830. }
  28831. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28832. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28834. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28835. if !m.op.Is(OpUpdateOne) {
  28836. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28837. }
  28838. if m.id == nil || m.oldValue == nil {
  28839. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28840. }
  28841. oldValue, err := m.oldValue(ctx)
  28842. if err != nil {
  28843. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28844. }
  28845. return oldValue.ActiveUser, nil
  28846. }
  28847. // AddActiveUser adds u to the "active_user" field.
  28848. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28849. if m.addactive_user != nil {
  28850. *m.addactive_user += u
  28851. } else {
  28852. m.addactive_user = &u
  28853. }
  28854. }
  28855. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28856. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28857. v := m.addactive_user
  28858. if v == nil {
  28859. return
  28860. }
  28861. return *v, true
  28862. }
  28863. // ResetActiveUser resets all changes to the "active_user" field.
  28864. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28865. m.active_user = nil
  28866. m.addactive_user = nil
  28867. }
  28868. // SetNewUser sets the "new_user" field.
  28869. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28870. m.new_user = &i
  28871. m.addnew_user = nil
  28872. }
  28873. // NewUser returns the value of the "new_user" field in the mutation.
  28874. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28875. v := m.new_user
  28876. if v == nil {
  28877. return
  28878. }
  28879. return *v, true
  28880. }
  28881. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28882. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28884. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28885. if !m.op.Is(OpUpdateOne) {
  28886. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28887. }
  28888. if m.id == nil || m.oldValue == nil {
  28889. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28890. }
  28891. oldValue, err := m.oldValue(ctx)
  28892. if err != nil {
  28893. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28894. }
  28895. return oldValue.NewUser, nil
  28896. }
  28897. // AddNewUser adds i to the "new_user" field.
  28898. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28899. if m.addnew_user != nil {
  28900. *m.addnew_user += i
  28901. } else {
  28902. m.addnew_user = &i
  28903. }
  28904. }
  28905. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28906. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28907. v := m.addnew_user
  28908. if v == nil {
  28909. return
  28910. }
  28911. return *v, true
  28912. }
  28913. // ResetNewUser resets all changes to the "new_user" field.
  28914. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28915. m.new_user = nil
  28916. m.addnew_user = nil
  28917. }
  28918. // SetLabelDist sets the "label_dist" field.
  28919. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28920. m.label_dist = &ctd
  28921. m.appendlabel_dist = nil
  28922. }
  28923. // LabelDist returns the value of the "label_dist" field in the mutation.
  28924. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28925. v := m.label_dist
  28926. if v == nil {
  28927. return
  28928. }
  28929. return *v, true
  28930. }
  28931. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28932. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28934. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28935. if !m.op.Is(OpUpdateOne) {
  28936. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28937. }
  28938. if m.id == nil || m.oldValue == nil {
  28939. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28940. }
  28941. oldValue, err := m.oldValue(ctx)
  28942. if err != nil {
  28943. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28944. }
  28945. return oldValue.LabelDist, nil
  28946. }
  28947. // AppendLabelDist adds ctd to the "label_dist" field.
  28948. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28949. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28950. }
  28951. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28952. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28953. if len(m.appendlabel_dist) == 0 {
  28954. return nil, false
  28955. }
  28956. return m.appendlabel_dist, true
  28957. }
  28958. // ResetLabelDist resets all changes to the "label_dist" field.
  28959. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  28960. m.label_dist = nil
  28961. m.appendlabel_dist = nil
  28962. }
  28963. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  28964. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  28965. m.predicates = append(m.predicates, ps...)
  28966. }
  28967. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  28968. // users can use type-assertion to append predicates that do not depend on any generated package.
  28969. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  28970. p := make([]predicate.UsageStatisticDay, len(ps))
  28971. for i := range ps {
  28972. p[i] = ps[i]
  28973. }
  28974. m.Where(p...)
  28975. }
  28976. // Op returns the operation name.
  28977. func (m *UsageStatisticDayMutation) Op() Op {
  28978. return m.op
  28979. }
  28980. // SetOp allows setting the mutation operation.
  28981. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  28982. m.op = op
  28983. }
  28984. // Type returns the node type of this mutation (UsageStatisticDay).
  28985. func (m *UsageStatisticDayMutation) Type() string {
  28986. return m.typ
  28987. }
  28988. // Fields returns all fields that were changed during this mutation. Note that in
  28989. // order to get all numeric fields that were incremented/decremented, call
  28990. // AddedFields().
  28991. func (m *UsageStatisticDayMutation) Fields() []string {
  28992. fields := make([]string, 0, 17)
  28993. if m.created_at != nil {
  28994. fields = append(fields, usagestatisticday.FieldCreatedAt)
  28995. }
  28996. if m.updated_at != nil {
  28997. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  28998. }
  28999. if m.status != nil {
  29000. fields = append(fields, usagestatisticday.FieldStatus)
  29001. }
  29002. if m.deleted_at != nil {
  29003. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29004. }
  29005. if m.addtime != nil {
  29006. fields = append(fields, usagestatisticday.FieldAddtime)
  29007. }
  29008. if m._type != nil {
  29009. fields = append(fields, usagestatisticday.FieldType)
  29010. }
  29011. if m.bot_id != nil {
  29012. fields = append(fields, usagestatisticday.FieldBotID)
  29013. }
  29014. if m.organization_id != nil {
  29015. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29016. }
  29017. if m.ai_response != nil {
  29018. fields = append(fields, usagestatisticday.FieldAiResponse)
  29019. }
  29020. if m.sop_run != nil {
  29021. fields = append(fields, usagestatisticday.FieldSopRun)
  29022. }
  29023. if m.total_friend != nil {
  29024. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29025. }
  29026. if m.total_group != nil {
  29027. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29028. }
  29029. if m.account_balance != nil {
  29030. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29031. }
  29032. if m.consume_token != nil {
  29033. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29034. }
  29035. if m.active_user != nil {
  29036. fields = append(fields, usagestatisticday.FieldActiveUser)
  29037. }
  29038. if m.new_user != nil {
  29039. fields = append(fields, usagestatisticday.FieldNewUser)
  29040. }
  29041. if m.label_dist != nil {
  29042. fields = append(fields, usagestatisticday.FieldLabelDist)
  29043. }
  29044. return fields
  29045. }
  29046. // Field returns the value of a field with the given name. The second boolean
  29047. // return value indicates that this field was not set, or was not defined in the
  29048. // schema.
  29049. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29050. switch name {
  29051. case usagestatisticday.FieldCreatedAt:
  29052. return m.CreatedAt()
  29053. case usagestatisticday.FieldUpdatedAt:
  29054. return m.UpdatedAt()
  29055. case usagestatisticday.FieldStatus:
  29056. return m.Status()
  29057. case usagestatisticday.FieldDeletedAt:
  29058. return m.DeletedAt()
  29059. case usagestatisticday.FieldAddtime:
  29060. return m.Addtime()
  29061. case usagestatisticday.FieldType:
  29062. return m.GetType()
  29063. case usagestatisticday.FieldBotID:
  29064. return m.BotID()
  29065. case usagestatisticday.FieldOrganizationID:
  29066. return m.OrganizationID()
  29067. case usagestatisticday.FieldAiResponse:
  29068. return m.AiResponse()
  29069. case usagestatisticday.FieldSopRun:
  29070. return m.SopRun()
  29071. case usagestatisticday.FieldTotalFriend:
  29072. return m.TotalFriend()
  29073. case usagestatisticday.FieldTotalGroup:
  29074. return m.TotalGroup()
  29075. case usagestatisticday.FieldAccountBalance:
  29076. return m.AccountBalance()
  29077. case usagestatisticday.FieldConsumeToken:
  29078. return m.ConsumeToken()
  29079. case usagestatisticday.FieldActiveUser:
  29080. return m.ActiveUser()
  29081. case usagestatisticday.FieldNewUser:
  29082. return m.NewUser()
  29083. case usagestatisticday.FieldLabelDist:
  29084. return m.LabelDist()
  29085. }
  29086. return nil, false
  29087. }
  29088. // OldField returns the old value of the field from the database. An error is
  29089. // returned if the mutation operation is not UpdateOne, or the query to the
  29090. // database failed.
  29091. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29092. switch name {
  29093. case usagestatisticday.FieldCreatedAt:
  29094. return m.OldCreatedAt(ctx)
  29095. case usagestatisticday.FieldUpdatedAt:
  29096. return m.OldUpdatedAt(ctx)
  29097. case usagestatisticday.FieldStatus:
  29098. return m.OldStatus(ctx)
  29099. case usagestatisticday.FieldDeletedAt:
  29100. return m.OldDeletedAt(ctx)
  29101. case usagestatisticday.FieldAddtime:
  29102. return m.OldAddtime(ctx)
  29103. case usagestatisticday.FieldType:
  29104. return m.OldType(ctx)
  29105. case usagestatisticday.FieldBotID:
  29106. return m.OldBotID(ctx)
  29107. case usagestatisticday.FieldOrganizationID:
  29108. return m.OldOrganizationID(ctx)
  29109. case usagestatisticday.FieldAiResponse:
  29110. return m.OldAiResponse(ctx)
  29111. case usagestatisticday.FieldSopRun:
  29112. return m.OldSopRun(ctx)
  29113. case usagestatisticday.FieldTotalFriend:
  29114. return m.OldTotalFriend(ctx)
  29115. case usagestatisticday.FieldTotalGroup:
  29116. return m.OldTotalGroup(ctx)
  29117. case usagestatisticday.FieldAccountBalance:
  29118. return m.OldAccountBalance(ctx)
  29119. case usagestatisticday.FieldConsumeToken:
  29120. return m.OldConsumeToken(ctx)
  29121. case usagestatisticday.FieldActiveUser:
  29122. return m.OldActiveUser(ctx)
  29123. case usagestatisticday.FieldNewUser:
  29124. return m.OldNewUser(ctx)
  29125. case usagestatisticday.FieldLabelDist:
  29126. return m.OldLabelDist(ctx)
  29127. }
  29128. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29129. }
  29130. // SetField sets the value of a field with the given name. It returns an error if
  29131. // the field is not defined in the schema, or if the type mismatched the field
  29132. // type.
  29133. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29134. switch name {
  29135. case usagestatisticday.FieldCreatedAt:
  29136. v, ok := value.(time.Time)
  29137. if !ok {
  29138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29139. }
  29140. m.SetCreatedAt(v)
  29141. return nil
  29142. case usagestatisticday.FieldUpdatedAt:
  29143. v, ok := value.(time.Time)
  29144. if !ok {
  29145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29146. }
  29147. m.SetUpdatedAt(v)
  29148. return nil
  29149. case usagestatisticday.FieldStatus:
  29150. v, ok := value.(uint8)
  29151. if !ok {
  29152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29153. }
  29154. m.SetStatus(v)
  29155. return nil
  29156. case usagestatisticday.FieldDeletedAt:
  29157. v, ok := value.(time.Time)
  29158. if !ok {
  29159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29160. }
  29161. m.SetDeletedAt(v)
  29162. return nil
  29163. case usagestatisticday.FieldAddtime:
  29164. v, ok := value.(uint64)
  29165. if !ok {
  29166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29167. }
  29168. m.SetAddtime(v)
  29169. return nil
  29170. case usagestatisticday.FieldType:
  29171. v, ok := value.(int)
  29172. if !ok {
  29173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29174. }
  29175. m.SetType(v)
  29176. return nil
  29177. case usagestatisticday.FieldBotID:
  29178. v, ok := value.(string)
  29179. if !ok {
  29180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29181. }
  29182. m.SetBotID(v)
  29183. return nil
  29184. case usagestatisticday.FieldOrganizationID:
  29185. v, ok := value.(uint64)
  29186. if !ok {
  29187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29188. }
  29189. m.SetOrganizationID(v)
  29190. return nil
  29191. case usagestatisticday.FieldAiResponse:
  29192. v, ok := value.(uint64)
  29193. if !ok {
  29194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29195. }
  29196. m.SetAiResponse(v)
  29197. return nil
  29198. case usagestatisticday.FieldSopRun:
  29199. v, ok := value.(uint64)
  29200. if !ok {
  29201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29202. }
  29203. m.SetSopRun(v)
  29204. return nil
  29205. case usagestatisticday.FieldTotalFriend:
  29206. v, ok := value.(uint64)
  29207. if !ok {
  29208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29209. }
  29210. m.SetTotalFriend(v)
  29211. return nil
  29212. case usagestatisticday.FieldTotalGroup:
  29213. v, ok := value.(uint64)
  29214. if !ok {
  29215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29216. }
  29217. m.SetTotalGroup(v)
  29218. return nil
  29219. case usagestatisticday.FieldAccountBalance:
  29220. v, ok := value.(uint64)
  29221. if !ok {
  29222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29223. }
  29224. m.SetAccountBalance(v)
  29225. return nil
  29226. case usagestatisticday.FieldConsumeToken:
  29227. v, ok := value.(uint64)
  29228. if !ok {
  29229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29230. }
  29231. m.SetConsumeToken(v)
  29232. return nil
  29233. case usagestatisticday.FieldActiveUser:
  29234. v, ok := value.(uint64)
  29235. if !ok {
  29236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29237. }
  29238. m.SetActiveUser(v)
  29239. return nil
  29240. case usagestatisticday.FieldNewUser:
  29241. v, ok := value.(int64)
  29242. if !ok {
  29243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29244. }
  29245. m.SetNewUser(v)
  29246. return nil
  29247. case usagestatisticday.FieldLabelDist:
  29248. v, ok := value.([]custom_types.LabelDist)
  29249. if !ok {
  29250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29251. }
  29252. m.SetLabelDist(v)
  29253. return nil
  29254. }
  29255. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29256. }
  29257. // AddedFields returns all numeric fields that were incremented/decremented during
  29258. // this mutation.
  29259. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29260. var fields []string
  29261. if m.addstatus != nil {
  29262. fields = append(fields, usagestatisticday.FieldStatus)
  29263. }
  29264. if m.addaddtime != nil {
  29265. fields = append(fields, usagestatisticday.FieldAddtime)
  29266. }
  29267. if m.add_type != nil {
  29268. fields = append(fields, usagestatisticday.FieldType)
  29269. }
  29270. if m.addorganization_id != nil {
  29271. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29272. }
  29273. if m.addai_response != nil {
  29274. fields = append(fields, usagestatisticday.FieldAiResponse)
  29275. }
  29276. if m.addsop_run != nil {
  29277. fields = append(fields, usagestatisticday.FieldSopRun)
  29278. }
  29279. if m.addtotal_friend != nil {
  29280. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29281. }
  29282. if m.addtotal_group != nil {
  29283. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29284. }
  29285. if m.addaccount_balance != nil {
  29286. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29287. }
  29288. if m.addconsume_token != nil {
  29289. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29290. }
  29291. if m.addactive_user != nil {
  29292. fields = append(fields, usagestatisticday.FieldActiveUser)
  29293. }
  29294. if m.addnew_user != nil {
  29295. fields = append(fields, usagestatisticday.FieldNewUser)
  29296. }
  29297. return fields
  29298. }
  29299. // AddedField returns the numeric value that was incremented/decremented on a field
  29300. // with the given name. The second boolean return value indicates that this field
  29301. // was not set, or was not defined in the schema.
  29302. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29303. switch name {
  29304. case usagestatisticday.FieldStatus:
  29305. return m.AddedStatus()
  29306. case usagestatisticday.FieldAddtime:
  29307. return m.AddedAddtime()
  29308. case usagestatisticday.FieldType:
  29309. return m.AddedType()
  29310. case usagestatisticday.FieldOrganizationID:
  29311. return m.AddedOrganizationID()
  29312. case usagestatisticday.FieldAiResponse:
  29313. return m.AddedAiResponse()
  29314. case usagestatisticday.FieldSopRun:
  29315. return m.AddedSopRun()
  29316. case usagestatisticday.FieldTotalFriend:
  29317. return m.AddedTotalFriend()
  29318. case usagestatisticday.FieldTotalGroup:
  29319. return m.AddedTotalGroup()
  29320. case usagestatisticday.FieldAccountBalance:
  29321. return m.AddedAccountBalance()
  29322. case usagestatisticday.FieldConsumeToken:
  29323. return m.AddedConsumeToken()
  29324. case usagestatisticday.FieldActiveUser:
  29325. return m.AddedActiveUser()
  29326. case usagestatisticday.FieldNewUser:
  29327. return m.AddedNewUser()
  29328. }
  29329. return nil, false
  29330. }
  29331. // AddField adds the value to the field with the given name. It returns an error if
  29332. // the field is not defined in the schema, or if the type mismatched the field
  29333. // type.
  29334. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29335. switch name {
  29336. case usagestatisticday.FieldStatus:
  29337. v, ok := value.(int8)
  29338. if !ok {
  29339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29340. }
  29341. m.AddStatus(v)
  29342. return nil
  29343. case usagestatisticday.FieldAddtime:
  29344. v, ok := value.(int64)
  29345. if !ok {
  29346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29347. }
  29348. m.AddAddtime(v)
  29349. return nil
  29350. case usagestatisticday.FieldType:
  29351. v, ok := value.(int)
  29352. if !ok {
  29353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29354. }
  29355. m.AddType(v)
  29356. return nil
  29357. case usagestatisticday.FieldOrganizationID:
  29358. v, ok := value.(int64)
  29359. if !ok {
  29360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29361. }
  29362. m.AddOrganizationID(v)
  29363. return nil
  29364. case usagestatisticday.FieldAiResponse:
  29365. v, ok := value.(int64)
  29366. if !ok {
  29367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29368. }
  29369. m.AddAiResponse(v)
  29370. return nil
  29371. case usagestatisticday.FieldSopRun:
  29372. v, ok := value.(int64)
  29373. if !ok {
  29374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29375. }
  29376. m.AddSopRun(v)
  29377. return nil
  29378. case usagestatisticday.FieldTotalFriend:
  29379. v, ok := value.(int64)
  29380. if !ok {
  29381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29382. }
  29383. m.AddTotalFriend(v)
  29384. return nil
  29385. case usagestatisticday.FieldTotalGroup:
  29386. v, ok := value.(int64)
  29387. if !ok {
  29388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29389. }
  29390. m.AddTotalGroup(v)
  29391. return nil
  29392. case usagestatisticday.FieldAccountBalance:
  29393. v, ok := value.(int64)
  29394. if !ok {
  29395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29396. }
  29397. m.AddAccountBalance(v)
  29398. return nil
  29399. case usagestatisticday.FieldConsumeToken:
  29400. v, ok := value.(int64)
  29401. if !ok {
  29402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29403. }
  29404. m.AddConsumeToken(v)
  29405. return nil
  29406. case usagestatisticday.FieldActiveUser:
  29407. v, ok := value.(int64)
  29408. if !ok {
  29409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29410. }
  29411. m.AddActiveUser(v)
  29412. return nil
  29413. case usagestatisticday.FieldNewUser:
  29414. v, ok := value.(int64)
  29415. if !ok {
  29416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29417. }
  29418. m.AddNewUser(v)
  29419. return nil
  29420. }
  29421. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29422. }
  29423. // ClearedFields returns all nullable fields that were cleared during this
  29424. // mutation.
  29425. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29426. var fields []string
  29427. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29428. fields = append(fields, usagestatisticday.FieldStatus)
  29429. }
  29430. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29431. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29432. }
  29433. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29434. fields = append(fields, usagestatisticday.FieldBotID)
  29435. }
  29436. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29437. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29438. }
  29439. return fields
  29440. }
  29441. // FieldCleared returns a boolean indicating if a field with the given name was
  29442. // cleared in this mutation.
  29443. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29444. _, ok := m.clearedFields[name]
  29445. return ok
  29446. }
  29447. // ClearField clears the value of the field with the given name. It returns an
  29448. // error if the field is not defined in the schema.
  29449. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29450. switch name {
  29451. case usagestatisticday.FieldStatus:
  29452. m.ClearStatus()
  29453. return nil
  29454. case usagestatisticday.FieldDeletedAt:
  29455. m.ClearDeletedAt()
  29456. return nil
  29457. case usagestatisticday.FieldBotID:
  29458. m.ClearBotID()
  29459. return nil
  29460. case usagestatisticday.FieldOrganizationID:
  29461. m.ClearOrganizationID()
  29462. return nil
  29463. }
  29464. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29465. }
  29466. // ResetField resets all changes in the mutation for the field with the given name.
  29467. // It returns an error if the field is not defined in the schema.
  29468. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29469. switch name {
  29470. case usagestatisticday.FieldCreatedAt:
  29471. m.ResetCreatedAt()
  29472. return nil
  29473. case usagestatisticday.FieldUpdatedAt:
  29474. m.ResetUpdatedAt()
  29475. return nil
  29476. case usagestatisticday.FieldStatus:
  29477. m.ResetStatus()
  29478. return nil
  29479. case usagestatisticday.FieldDeletedAt:
  29480. m.ResetDeletedAt()
  29481. return nil
  29482. case usagestatisticday.FieldAddtime:
  29483. m.ResetAddtime()
  29484. return nil
  29485. case usagestatisticday.FieldType:
  29486. m.ResetType()
  29487. return nil
  29488. case usagestatisticday.FieldBotID:
  29489. m.ResetBotID()
  29490. return nil
  29491. case usagestatisticday.FieldOrganizationID:
  29492. m.ResetOrganizationID()
  29493. return nil
  29494. case usagestatisticday.FieldAiResponse:
  29495. m.ResetAiResponse()
  29496. return nil
  29497. case usagestatisticday.FieldSopRun:
  29498. m.ResetSopRun()
  29499. return nil
  29500. case usagestatisticday.FieldTotalFriend:
  29501. m.ResetTotalFriend()
  29502. return nil
  29503. case usagestatisticday.FieldTotalGroup:
  29504. m.ResetTotalGroup()
  29505. return nil
  29506. case usagestatisticday.FieldAccountBalance:
  29507. m.ResetAccountBalance()
  29508. return nil
  29509. case usagestatisticday.FieldConsumeToken:
  29510. m.ResetConsumeToken()
  29511. return nil
  29512. case usagestatisticday.FieldActiveUser:
  29513. m.ResetActiveUser()
  29514. return nil
  29515. case usagestatisticday.FieldNewUser:
  29516. m.ResetNewUser()
  29517. return nil
  29518. case usagestatisticday.FieldLabelDist:
  29519. m.ResetLabelDist()
  29520. return nil
  29521. }
  29522. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29523. }
  29524. // AddedEdges returns all edge names that were set/added in this mutation.
  29525. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29526. edges := make([]string, 0, 0)
  29527. return edges
  29528. }
  29529. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29530. // name in this mutation.
  29531. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29532. return nil
  29533. }
  29534. // RemovedEdges returns all edge names that were removed in this mutation.
  29535. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29536. edges := make([]string, 0, 0)
  29537. return edges
  29538. }
  29539. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29540. // the given name in this mutation.
  29541. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29542. return nil
  29543. }
  29544. // ClearedEdges returns all edge names that were cleared in this mutation.
  29545. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29546. edges := make([]string, 0, 0)
  29547. return edges
  29548. }
  29549. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29550. // was cleared in this mutation.
  29551. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29552. return false
  29553. }
  29554. // ClearEdge clears the value of the edge with the given name. It returns an error
  29555. // if that edge is not defined in the schema.
  29556. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29557. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29558. }
  29559. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29560. // It returns an error if the edge is not defined in the schema.
  29561. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29562. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29563. }
  29564. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29565. type UsageStatisticHourMutation struct {
  29566. config
  29567. op Op
  29568. typ string
  29569. id *uint64
  29570. created_at *time.Time
  29571. updated_at *time.Time
  29572. status *uint8
  29573. addstatus *int8
  29574. deleted_at *time.Time
  29575. addtime *uint64
  29576. addaddtime *int64
  29577. _type *int
  29578. add_type *int
  29579. bot_id *string
  29580. organization_id *uint64
  29581. addorganization_id *int64
  29582. ai_response *uint64
  29583. addai_response *int64
  29584. sop_run *uint64
  29585. addsop_run *int64
  29586. total_friend *uint64
  29587. addtotal_friend *int64
  29588. total_group *uint64
  29589. addtotal_group *int64
  29590. account_balance *uint64
  29591. addaccount_balance *int64
  29592. consume_token *uint64
  29593. addconsume_token *int64
  29594. active_user *uint64
  29595. addactive_user *int64
  29596. new_user *int64
  29597. addnew_user *int64
  29598. label_dist *[]custom_types.LabelDist
  29599. appendlabel_dist []custom_types.LabelDist
  29600. clearedFields map[string]struct{}
  29601. done bool
  29602. oldValue func(context.Context) (*UsageStatisticHour, error)
  29603. predicates []predicate.UsageStatisticHour
  29604. }
  29605. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29606. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29607. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29608. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29609. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29610. m := &UsageStatisticHourMutation{
  29611. config: c,
  29612. op: op,
  29613. typ: TypeUsageStatisticHour,
  29614. clearedFields: make(map[string]struct{}),
  29615. }
  29616. for _, opt := range opts {
  29617. opt(m)
  29618. }
  29619. return m
  29620. }
  29621. // withUsageStatisticHourID sets the ID field of the mutation.
  29622. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29623. return func(m *UsageStatisticHourMutation) {
  29624. var (
  29625. err error
  29626. once sync.Once
  29627. value *UsageStatisticHour
  29628. )
  29629. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29630. once.Do(func() {
  29631. if m.done {
  29632. err = errors.New("querying old values post mutation is not allowed")
  29633. } else {
  29634. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29635. }
  29636. })
  29637. return value, err
  29638. }
  29639. m.id = &id
  29640. }
  29641. }
  29642. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29643. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29644. return func(m *UsageStatisticHourMutation) {
  29645. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29646. return node, nil
  29647. }
  29648. m.id = &node.ID
  29649. }
  29650. }
  29651. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29652. // executed in a transaction (ent.Tx), a transactional client is returned.
  29653. func (m UsageStatisticHourMutation) Client() *Client {
  29654. client := &Client{config: m.config}
  29655. client.init()
  29656. return client
  29657. }
  29658. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29659. // it returns an error otherwise.
  29660. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29661. if _, ok := m.driver.(*txDriver); !ok {
  29662. return nil, errors.New("ent: mutation is not running in a transaction")
  29663. }
  29664. tx := &Tx{config: m.config}
  29665. tx.init()
  29666. return tx, nil
  29667. }
  29668. // SetID sets the value of the id field. Note that this
  29669. // operation is only accepted on creation of UsageStatisticHour entities.
  29670. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29671. m.id = &id
  29672. }
  29673. // ID returns the ID value in the mutation. Note that the ID is only available
  29674. // if it was provided to the builder or after it was returned from the database.
  29675. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29676. if m.id == nil {
  29677. return
  29678. }
  29679. return *m.id, true
  29680. }
  29681. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29682. // That means, if the mutation is applied within a transaction with an isolation level such
  29683. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29684. // or updated by the mutation.
  29685. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29686. switch {
  29687. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29688. id, exists := m.ID()
  29689. if exists {
  29690. return []uint64{id}, nil
  29691. }
  29692. fallthrough
  29693. case m.op.Is(OpUpdate | OpDelete):
  29694. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29695. default:
  29696. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29697. }
  29698. }
  29699. // SetCreatedAt sets the "created_at" field.
  29700. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29701. m.created_at = &t
  29702. }
  29703. // CreatedAt returns the value of the "created_at" field in the mutation.
  29704. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29705. v := m.created_at
  29706. if v == nil {
  29707. return
  29708. }
  29709. return *v, true
  29710. }
  29711. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29712. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29714. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29715. if !m.op.Is(OpUpdateOne) {
  29716. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29717. }
  29718. if m.id == nil || m.oldValue == nil {
  29719. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29720. }
  29721. oldValue, err := m.oldValue(ctx)
  29722. if err != nil {
  29723. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29724. }
  29725. return oldValue.CreatedAt, nil
  29726. }
  29727. // ResetCreatedAt resets all changes to the "created_at" field.
  29728. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29729. m.created_at = nil
  29730. }
  29731. // SetUpdatedAt sets the "updated_at" field.
  29732. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29733. m.updated_at = &t
  29734. }
  29735. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29736. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29737. v := m.updated_at
  29738. if v == nil {
  29739. return
  29740. }
  29741. return *v, true
  29742. }
  29743. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29744. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29746. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29747. if !m.op.Is(OpUpdateOne) {
  29748. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29749. }
  29750. if m.id == nil || m.oldValue == nil {
  29751. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29752. }
  29753. oldValue, err := m.oldValue(ctx)
  29754. if err != nil {
  29755. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29756. }
  29757. return oldValue.UpdatedAt, nil
  29758. }
  29759. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29760. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29761. m.updated_at = nil
  29762. }
  29763. // SetStatus sets the "status" field.
  29764. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29765. m.status = &u
  29766. m.addstatus = nil
  29767. }
  29768. // Status returns the value of the "status" field in the mutation.
  29769. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29770. v := m.status
  29771. if v == nil {
  29772. return
  29773. }
  29774. return *v, true
  29775. }
  29776. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29777. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29779. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29780. if !m.op.Is(OpUpdateOne) {
  29781. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29782. }
  29783. if m.id == nil || m.oldValue == nil {
  29784. return v, errors.New("OldStatus requires an ID field in the mutation")
  29785. }
  29786. oldValue, err := m.oldValue(ctx)
  29787. if err != nil {
  29788. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29789. }
  29790. return oldValue.Status, nil
  29791. }
  29792. // AddStatus adds u to the "status" field.
  29793. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29794. if m.addstatus != nil {
  29795. *m.addstatus += u
  29796. } else {
  29797. m.addstatus = &u
  29798. }
  29799. }
  29800. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29801. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29802. v := m.addstatus
  29803. if v == nil {
  29804. return
  29805. }
  29806. return *v, true
  29807. }
  29808. // ClearStatus clears the value of the "status" field.
  29809. func (m *UsageStatisticHourMutation) ClearStatus() {
  29810. m.status = nil
  29811. m.addstatus = nil
  29812. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29813. }
  29814. // StatusCleared returns if the "status" field was cleared in this mutation.
  29815. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29816. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29817. return ok
  29818. }
  29819. // ResetStatus resets all changes to the "status" field.
  29820. func (m *UsageStatisticHourMutation) ResetStatus() {
  29821. m.status = nil
  29822. m.addstatus = nil
  29823. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29824. }
  29825. // SetDeletedAt sets the "deleted_at" field.
  29826. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29827. m.deleted_at = &t
  29828. }
  29829. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29830. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29831. v := m.deleted_at
  29832. if v == nil {
  29833. return
  29834. }
  29835. return *v, true
  29836. }
  29837. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29838. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29840. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29841. if !m.op.Is(OpUpdateOne) {
  29842. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29843. }
  29844. if m.id == nil || m.oldValue == nil {
  29845. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29846. }
  29847. oldValue, err := m.oldValue(ctx)
  29848. if err != nil {
  29849. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29850. }
  29851. return oldValue.DeletedAt, nil
  29852. }
  29853. // ClearDeletedAt clears the value of the "deleted_at" field.
  29854. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29855. m.deleted_at = nil
  29856. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29857. }
  29858. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29859. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29860. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29861. return ok
  29862. }
  29863. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29864. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29865. m.deleted_at = nil
  29866. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29867. }
  29868. // SetAddtime sets the "addtime" field.
  29869. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29870. m.addtime = &u
  29871. m.addaddtime = nil
  29872. }
  29873. // Addtime returns the value of the "addtime" field in the mutation.
  29874. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29875. v := m.addtime
  29876. if v == nil {
  29877. return
  29878. }
  29879. return *v, true
  29880. }
  29881. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29882. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29884. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29885. if !m.op.Is(OpUpdateOne) {
  29886. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29887. }
  29888. if m.id == nil || m.oldValue == nil {
  29889. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29890. }
  29891. oldValue, err := m.oldValue(ctx)
  29892. if err != nil {
  29893. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29894. }
  29895. return oldValue.Addtime, nil
  29896. }
  29897. // AddAddtime adds u to the "addtime" field.
  29898. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29899. if m.addaddtime != nil {
  29900. *m.addaddtime += u
  29901. } else {
  29902. m.addaddtime = &u
  29903. }
  29904. }
  29905. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29906. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29907. v := m.addaddtime
  29908. if v == nil {
  29909. return
  29910. }
  29911. return *v, true
  29912. }
  29913. // ResetAddtime resets all changes to the "addtime" field.
  29914. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29915. m.addtime = nil
  29916. m.addaddtime = nil
  29917. }
  29918. // SetType sets the "type" field.
  29919. func (m *UsageStatisticHourMutation) SetType(i int) {
  29920. m._type = &i
  29921. m.add_type = nil
  29922. }
  29923. // GetType returns the value of the "type" field in the mutation.
  29924. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29925. v := m._type
  29926. if v == nil {
  29927. return
  29928. }
  29929. return *v, true
  29930. }
  29931. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29932. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29934. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29935. if !m.op.Is(OpUpdateOne) {
  29936. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29937. }
  29938. if m.id == nil || m.oldValue == nil {
  29939. return v, errors.New("OldType requires an ID field in the mutation")
  29940. }
  29941. oldValue, err := m.oldValue(ctx)
  29942. if err != nil {
  29943. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29944. }
  29945. return oldValue.Type, nil
  29946. }
  29947. // AddType adds i to the "type" field.
  29948. func (m *UsageStatisticHourMutation) AddType(i int) {
  29949. if m.add_type != nil {
  29950. *m.add_type += i
  29951. } else {
  29952. m.add_type = &i
  29953. }
  29954. }
  29955. // AddedType returns the value that was added to the "type" field in this mutation.
  29956. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  29957. v := m.add_type
  29958. if v == nil {
  29959. return
  29960. }
  29961. return *v, true
  29962. }
  29963. // ResetType resets all changes to the "type" field.
  29964. func (m *UsageStatisticHourMutation) ResetType() {
  29965. m._type = nil
  29966. m.add_type = nil
  29967. }
  29968. // SetBotID sets the "bot_id" field.
  29969. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  29970. m.bot_id = &s
  29971. }
  29972. // BotID returns the value of the "bot_id" field in the mutation.
  29973. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  29974. v := m.bot_id
  29975. if v == nil {
  29976. return
  29977. }
  29978. return *v, true
  29979. }
  29980. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  29981. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29983. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  29984. if !m.op.Is(OpUpdateOne) {
  29985. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29986. }
  29987. if m.id == nil || m.oldValue == nil {
  29988. return v, errors.New("OldBotID requires an ID field in the mutation")
  29989. }
  29990. oldValue, err := m.oldValue(ctx)
  29991. if err != nil {
  29992. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29993. }
  29994. return oldValue.BotID, nil
  29995. }
  29996. // ClearBotID clears the value of the "bot_id" field.
  29997. func (m *UsageStatisticHourMutation) ClearBotID() {
  29998. m.bot_id = nil
  29999. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30000. }
  30001. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30002. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30003. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30004. return ok
  30005. }
  30006. // ResetBotID resets all changes to the "bot_id" field.
  30007. func (m *UsageStatisticHourMutation) ResetBotID() {
  30008. m.bot_id = nil
  30009. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30010. }
  30011. // SetOrganizationID sets the "organization_id" field.
  30012. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30013. m.organization_id = &u
  30014. m.addorganization_id = nil
  30015. }
  30016. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30017. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30018. v := m.organization_id
  30019. if v == nil {
  30020. return
  30021. }
  30022. return *v, true
  30023. }
  30024. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30025. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30027. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30028. if !m.op.Is(OpUpdateOne) {
  30029. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30030. }
  30031. if m.id == nil || m.oldValue == nil {
  30032. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30033. }
  30034. oldValue, err := m.oldValue(ctx)
  30035. if err != nil {
  30036. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30037. }
  30038. return oldValue.OrganizationID, nil
  30039. }
  30040. // AddOrganizationID adds u to the "organization_id" field.
  30041. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30042. if m.addorganization_id != nil {
  30043. *m.addorganization_id += u
  30044. } else {
  30045. m.addorganization_id = &u
  30046. }
  30047. }
  30048. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30049. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30050. v := m.addorganization_id
  30051. if v == nil {
  30052. return
  30053. }
  30054. return *v, true
  30055. }
  30056. // ClearOrganizationID clears the value of the "organization_id" field.
  30057. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30058. m.organization_id = nil
  30059. m.addorganization_id = nil
  30060. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30061. }
  30062. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30063. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30064. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30065. return ok
  30066. }
  30067. // ResetOrganizationID resets all changes to the "organization_id" field.
  30068. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30069. m.organization_id = nil
  30070. m.addorganization_id = nil
  30071. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30072. }
  30073. // SetAiResponse sets the "ai_response" field.
  30074. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30075. m.ai_response = &u
  30076. m.addai_response = nil
  30077. }
  30078. // AiResponse returns the value of the "ai_response" field in the mutation.
  30079. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30080. v := m.ai_response
  30081. if v == nil {
  30082. return
  30083. }
  30084. return *v, true
  30085. }
  30086. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30087. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30089. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30090. if !m.op.Is(OpUpdateOne) {
  30091. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30092. }
  30093. if m.id == nil || m.oldValue == nil {
  30094. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30095. }
  30096. oldValue, err := m.oldValue(ctx)
  30097. if err != nil {
  30098. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30099. }
  30100. return oldValue.AiResponse, nil
  30101. }
  30102. // AddAiResponse adds u to the "ai_response" field.
  30103. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30104. if m.addai_response != nil {
  30105. *m.addai_response += u
  30106. } else {
  30107. m.addai_response = &u
  30108. }
  30109. }
  30110. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30111. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30112. v := m.addai_response
  30113. if v == nil {
  30114. return
  30115. }
  30116. return *v, true
  30117. }
  30118. // ResetAiResponse resets all changes to the "ai_response" field.
  30119. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30120. m.ai_response = nil
  30121. m.addai_response = nil
  30122. }
  30123. // SetSopRun sets the "sop_run" field.
  30124. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30125. m.sop_run = &u
  30126. m.addsop_run = nil
  30127. }
  30128. // SopRun returns the value of the "sop_run" field in the mutation.
  30129. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30130. v := m.sop_run
  30131. if v == nil {
  30132. return
  30133. }
  30134. return *v, true
  30135. }
  30136. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30137. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30139. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30140. if !m.op.Is(OpUpdateOne) {
  30141. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30142. }
  30143. if m.id == nil || m.oldValue == nil {
  30144. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30145. }
  30146. oldValue, err := m.oldValue(ctx)
  30147. if err != nil {
  30148. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30149. }
  30150. return oldValue.SopRun, nil
  30151. }
  30152. // AddSopRun adds u to the "sop_run" field.
  30153. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30154. if m.addsop_run != nil {
  30155. *m.addsop_run += u
  30156. } else {
  30157. m.addsop_run = &u
  30158. }
  30159. }
  30160. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30161. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30162. v := m.addsop_run
  30163. if v == nil {
  30164. return
  30165. }
  30166. return *v, true
  30167. }
  30168. // ResetSopRun resets all changes to the "sop_run" field.
  30169. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30170. m.sop_run = nil
  30171. m.addsop_run = nil
  30172. }
  30173. // SetTotalFriend sets the "total_friend" field.
  30174. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30175. m.total_friend = &u
  30176. m.addtotal_friend = nil
  30177. }
  30178. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30179. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30180. v := m.total_friend
  30181. if v == nil {
  30182. return
  30183. }
  30184. return *v, true
  30185. }
  30186. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30187. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30189. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30190. if !m.op.Is(OpUpdateOne) {
  30191. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30192. }
  30193. if m.id == nil || m.oldValue == nil {
  30194. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30195. }
  30196. oldValue, err := m.oldValue(ctx)
  30197. if err != nil {
  30198. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30199. }
  30200. return oldValue.TotalFriend, nil
  30201. }
  30202. // AddTotalFriend adds u to the "total_friend" field.
  30203. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30204. if m.addtotal_friend != nil {
  30205. *m.addtotal_friend += u
  30206. } else {
  30207. m.addtotal_friend = &u
  30208. }
  30209. }
  30210. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30211. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30212. v := m.addtotal_friend
  30213. if v == nil {
  30214. return
  30215. }
  30216. return *v, true
  30217. }
  30218. // ResetTotalFriend resets all changes to the "total_friend" field.
  30219. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30220. m.total_friend = nil
  30221. m.addtotal_friend = nil
  30222. }
  30223. // SetTotalGroup sets the "total_group" field.
  30224. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30225. m.total_group = &u
  30226. m.addtotal_group = nil
  30227. }
  30228. // TotalGroup returns the value of the "total_group" field in the mutation.
  30229. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30230. v := m.total_group
  30231. if v == nil {
  30232. return
  30233. }
  30234. return *v, true
  30235. }
  30236. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30237. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30239. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30240. if !m.op.Is(OpUpdateOne) {
  30241. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30242. }
  30243. if m.id == nil || m.oldValue == nil {
  30244. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30245. }
  30246. oldValue, err := m.oldValue(ctx)
  30247. if err != nil {
  30248. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30249. }
  30250. return oldValue.TotalGroup, nil
  30251. }
  30252. // AddTotalGroup adds u to the "total_group" field.
  30253. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30254. if m.addtotal_group != nil {
  30255. *m.addtotal_group += u
  30256. } else {
  30257. m.addtotal_group = &u
  30258. }
  30259. }
  30260. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30261. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30262. v := m.addtotal_group
  30263. if v == nil {
  30264. return
  30265. }
  30266. return *v, true
  30267. }
  30268. // ResetTotalGroup resets all changes to the "total_group" field.
  30269. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30270. m.total_group = nil
  30271. m.addtotal_group = nil
  30272. }
  30273. // SetAccountBalance sets the "account_balance" field.
  30274. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30275. m.account_balance = &u
  30276. m.addaccount_balance = nil
  30277. }
  30278. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30279. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30280. v := m.account_balance
  30281. if v == nil {
  30282. return
  30283. }
  30284. return *v, true
  30285. }
  30286. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30287. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30289. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30290. if !m.op.Is(OpUpdateOne) {
  30291. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30292. }
  30293. if m.id == nil || m.oldValue == nil {
  30294. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30295. }
  30296. oldValue, err := m.oldValue(ctx)
  30297. if err != nil {
  30298. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30299. }
  30300. return oldValue.AccountBalance, nil
  30301. }
  30302. // AddAccountBalance adds u to the "account_balance" field.
  30303. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30304. if m.addaccount_balance != nil {
  30305. *m.addaccount_balance += u
  30306. } else {
  30307. m.addaccount_balance = &u
  30308. }
  30309. }
  30310. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30311. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30312. v := m.addaccount_balance
  30313. if v == nil {
  30314. return
  30315. }
  30316. return *v, true
  30317. }
  30318. // ResetAccountBalance resets all changes to the "account_balance" field.
  30319. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30320. m.account_balance = nil
  30321. m.addaccount_balance = nil
  30322. }
  30323. // SetConsumeToken sets the "consume_token" field.
  30324. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30325. m.consume_token = &u
  30326. m.addconsume_token = nil
  30327. }
  30328. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30329. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30330. v := m.consume_token
  30331. if v == nil {
  30332. return
  30333. }
  30334. return *v, true
  30335. }
  30336. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30337. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30339. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30340. if !m.op.Is(OpUpdateOne) {
  30341. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30342. }
  30343. if m.id == nil || m.oldValue == nil {
  30344. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30345. }
  30346. oldValue, err := m.oldValue(ctx)
  30347. if err != nil {
  30348. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30349. }
  30350. return oldValue.ConsumeToken, nil
  30351. }
  30352. // AddConsumeToken adds u to the "consume_token" field.
  30353. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30354. if m.addconsume_token != nil {
  30355. *m.addconsume_token += u
  30356. } else {
  30357. m.addconsume_token = &u
  30358. }
  30359. }
  30360. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30361. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30362. v := m.addconsume_token
  30363. if v == nil {
  30364. return
  30365. }
  30366. return *v, true
  30367. }
  30368. // ResetConsumeToken resets all changes to the "consume_token" field.
  30369. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30370. m.consume_token = nil
  30371. m.addconsume_token = nil
  30372. }
  30373. // SetActiveUser sets the "active_user" field.
  30374. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30375. m.active_user = &u
  30376. m.addactive_user = nil
  30377. }
  30378. // ActiveUser returns the value of the "active_user" field in the mutation.
  30379. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30380. v := m.active_user
  30381. if v == nil {
  30382. return
  30383. }
  30384. return *v, true
  30385. }
  30386. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30387. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30389. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30390. if !m.op.Is(OpUpdateOne) {
  30391. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30392. }
  30393. if m.id == nil || m.oldValue == nil {
  30394. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30395. }
  30396. oldValue, err := m.oldValue(ctx)
  30397. if err != nil {
  30398. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30399. }
  30400. return oldValue.ActiveUser, nil
  30401. }
  30402. // AddActiveUser adds u to the "active_user" field.
  30403. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30404. if m.addactive_user != nil {
  30405. *m.addactive_user += u
  30406. } else {
  30407. m.addactive_user = &u
  30408. }
  30409. }
  30410. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30411. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30412. v := m.addactive_user
  30413. if v == nil {
  30414. return
  30415. }
  30416. return *v, true
  30417. }
  30418. // ResetActiveUser resets all changes to the "active_user" field.
  30419. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30420. m.active_user = nil
  30421. m.addactive_user = nil
  30422. }
  30423. // SetNewUser sets the "new_user" field.
  30424. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30425. m.new_user = &i
  30426. m.addnew_user = nil
  30427. }
  30428. // NewUser returns the value of the "new_user" field in the mutation.
  30429. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30430. v := m.new_user
  30431. if v == nil {
  30432. return
  30433. }
  30434. return *v, true
  30435. }
  30436. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30437. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30440. if !m.op.Is(OpUpdateOne) {
  30441. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30442. }
  30443. if m.id == nil || m.oldValue == nil {
  30444. return v, errors.New("OldNewUser 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 OldNewUser: %w", err)
  30449. }
  30450. return oldValue.NewUser, nil
  30451. }
  30452. // AddNewUser adds i to the "new_user" field.
  30453. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30454. if m.addnew_user != nil {
  30455. *m.addnew_user += i
  30456. } else {
  30457. m.addnew_user = &i
  30458. }
  30459. }
  30460. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30461. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30462. v := m.addnew_user
  30463. if v == nil {
  30464. return
  30465. }
  30466. return *v, true
  30467. }
  30468. // ResetNewUser resets all changes to the "new_user" field.
  30469. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30470. m.new_user = nil
  30471. m.addnew_user = nil
  30472. }
  30473. // SetLabelDist sets the "label_dist" field.
  30474. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30475. m.label_dist = &ctd
  30476. m.appendlabel_dist = nil
  30477. }
  30478. // LabelDist returns the value of the "label_dist" field in the mutation.
  30479. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30480. v := m.label_dist
  30481. if v == nil {
  30482. return
  30483. }
  30484. return *v, true
  30485. }
  30486. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30487. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30489. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30490. if !m.op.Is(OpUpdateOne) {
  30491. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30492. }
  30493. if m.id == nil || m.oldValue == nil {
  30494. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30495. }
  30496. oldValue, err := m.oldValue(ctx)
  30497. if err != nil {
  30498. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30499. }
  30500. return oldValue.LabelDist, nil
  30501. }
  30502. // AppendLabelDist adds ctd to the "label_dist" field.
  30503. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30504. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30505. }
  30506. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30507. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30508. if len(m.appendlabel_dist) == 0 {
  30509. return nil, false
  30510. }
  30511. return m.appendlabel_dist, true
  30512. }
  30513. // ResetLabelDist resets all changes to the "label_dist" field.
  30514. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30515. m.label_dist = nil
  30516. m.appendlabel_dist = nil
  30517. }
  30518. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30519. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30520. m.predicates = append(m.predicates, ps...)
  30521. }
  30522. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30523. // users can use type-assertion to append predicates that do not depend on any generated package.
  30524. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30525. p := make([]predicate.UsageStatisticHour, len(ps))
  30526. for i := range ps {
  30527. p[i] = ps[i]
  30528. }
  30529. m.Where(p...)
  30530. }
  30531. // Op returns the operation name.
  30532. func (m *UsageStatisticHourMutation) Op() Op {
  30533. return m.op
  30534. }
  30535. // SetOp allows setting the mutation operation.
  30536. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30537. m.op = op
  30538. }
  30539. // Type returns the node type of this mutation (UsageStatisticHour).
  30540. func (m *UsageStatisticHourMutation) Type() string {
  30541. return m.typ
  30542. }
  30543. // Fields returns all fields that were changed during this mutation. Note that in
  30544. // order to get all numeric fields that were incremented/decremented, call
  30545. // AddedFields().
  30546. func (m *UsageStatisticHourMutation) Fields() []string {
  30547. fields := make([]string, 0, 17)
  30548. if m.created_at != nil {
  30549. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30550. }
  30551. if m.updated_at != nil {
  30552. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30553. }
  30554. if m.status != nil {
  30555. fields = append(fields, usagestatistichour.FieldStatus)
  30556. }
  30557. if m.deleted_at != nil {
  30558. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30559. }
  30560. if m.addtime != nil {
  30561. fields = append(fields, usagestatistichour.FieldAddtime)
  30562. }
  30563. if m._type != nil {
  30564. fields = append(fields, usagestatistichour.FieldType)
  30565. }
  30566. if m.bot_id != nil {
  30567. fields = append(fields, usagestatistichour.FieldBotID)
  30568. }
  30569. if m.organization_id != nil {
  30570. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30571. }
  30572. if m.ai_response != nil {
  30573. fields = append(fields, usagestatistichour.FieldAiResponse)
  30574. }
  30575. if m.sop_run != nil {
  30576. fields = append(fields, usagestatistichour.FieldSopRun)
  30577. }
  30578. if m.total_friend != nil {
  30579. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30580. }
  30581. if m.total_group != nil {
  30582. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30583. }
  30584. if m.account_balance != nil {
  30585. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30586. }
  30587. if m.consume_token != nil {
  30588. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30589. }
  30590. if m.active_user != nil {
  30591. fields = append(fields, usagestatistichour.FieldActiveUser)
  30592. }
  30593. if m.new_user != nil {
  30594. fields = append(fields, usagestatistichour.FieldNewUser)
  30595. }
  30596. if m.label_dist != nil {
  30597. fields = append(fields, usagestatistichour.FieldLabelDist)
  30598. }
  30599. return fields
  30600. }
  30601. // Field returns the value of a field with the given name. The second boolean
  30602. // return value indicates that this field was not set, or was not defined in the
  30603. // schema.
  30604. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30605. switch name {
  30606. case usagestatistichour.FieldCreatedAt:
  30607. return m.CreatedAt()
  30608. case usagestatistichour.FieldUpdatedAt:
  30609. return m.UpdatedAt()
  30610. case usagestatistichour.FieldStatus:
  30611. return m.Status()
  30612. case usagestatistichour.FieldDeletedAt:
  30613. return m.DeletedAt()
  30614. case usagestatistichour.FieldAddtime:
  30615. return m.Addtime()
  30616. case usagestatistichour.FieldType:
  30617. return m.GetType()
  30618. case usagestatistichour.FieldBotID:
  30619. return m.BotID()
  30620. case usagestatistichour.FieldOrganizationID:
  30621. return m.OrganizationID()
  30622. case usagestatistichour.FieldAiResponse:
  30623. return m.AiResponse()
  30624. case usagestatistichour.FieldSopRun:
  30625. return m.SopRun()
  30626. case usagestatistichour.FieldTotalFriend:
  30627. return m.TotalFriend()
  30628. case usagestatistichour.FieldTotalGroup:
  30629. return m.TotalGroup()
  30630. case usagestatistichour.FieldAccountBalance:
  30631. return m.AccountBalance()
  30632. case usagestatistichour.FieldConsumeToken:
  30633. return m.ConsumeToken()
  30634. case usagestatistichour.FieldActiveUser:
  30635. return m.ActiveUser()
  30636. case usagestatistichour.FieldNewUser:
  30637. return m.NewUser()
  30638. case usagestatistichour.FieldLabelDist:
  30639. return m.LabelDist()
  30640. }
  30641. return nil, false
  30642. }
  30643. // OldField returns the old value of the field from the database. An error is
  30644. // returned if the mutation operation is not UpdateOne, or the query to the
  30645. // database failed.
  30646. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30647. switch name {
  30648. case usagestatistichour.FieldCreatedAt:
  30649. return m.OldCreatedAt(ctx)
  30650. case usagestatistichour.FieldUpdatedAt:
  30651. return m.OldUpdatedAt(ctx)
  30652. case usagestatistichour.FieldStatus:
  30653. return m.OldStatus(ctx)
  30654. case usagestatistichour.FieldDeletedAt:
  30655. return m.OldDeletedAt(ctx)
  30656. case usagestatistichour.FieldAddtime:
  30657. return m.OldAddtime(ctx)
  30658. case usagestatistichour.FieldType:
  30659. return m.OldType(ctx)
  30660. case usagestatistichour.FieldBotID:
  30661. return m.OldBotID(ctx)
  30662. case usagestatistichour.FieldOrganizationID:
  30663. return m.OldOrganizationID(ctx)
  30664. case usagestatistichour.FieldAiResponse:
  30665. return m.OldAiResponse(ctx)
  30666. case usagestatistichour.FieldSopRun:
  30667. return m.OldSopRun(ctx)
  30668. case usagestatistichour.FieldTotalFriend:
  30669. return m.OldTotalFriend(ctx)
  30670. case usagestatistichour.FieldTotalGroup:
  30671. return m.OldTotalGroup(ctx)
  30672. case usagestatistichour.FieldAccountBalance:
  30673. return m.OldAccountBalance(ctx)
  30674. case usagestatistichour.FieldConsumeToken:
  30675. return m.OldConsumeToken(ctx)
  30676. case usagestatistichour.FieldActiveUser:
  30677. return m.OldActiveUser(ctx)
  30678. case usagestatistichour.FieldNewUser:
  30679. return m.OldNewUser(ctx)
  30680. case usagestatistichour.FieldLabelDist:
  30681. return m.OldLabelDist(ctx)
  30682. }
  30683. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30684. }
  30685. // SetField sets the value of a field with the given name. It returns an error if
  30686. // the field is not defined in the schema, or if the type mismatched the field
  30687. // type.
  30688. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30689. switch name {
  30690. case usagestatistichour.FieldCreatedAt:
  30691. v, ok := value.(time.Time)
  30692. if !ok {
  30693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30694. }
  30695. m.SetCreatedAt(v)
  30696. return nil
  30697. case usagestatistichour.FieldUpdatedAt:
  30698. v, ok := value.(time.Time)
  30699. if !ok {
  30700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30701. }
  30702. m.SetUpdatedAt(v)
  30703. return nil
  30704. case usagestatistichour.FieldStatus:
  30705. v, ok := value.(uint8)
  30706. if !ok {
  30707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30708. }
  30709. m.SetStatus(v)
  30710. return nil
  30711. case usagestatistichour.FieldDeletedAt:
  30712. v, ok := value.(time.Time)
  30713. if !ok {
  30714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30715. }
  30716. m.SetDeletedAt(v)
  30717. return nil
  30718. case usagestatistichour.FieldAddtime:
  30719. v, ok := value.(uint64)
  30720. if !ok {
  30721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30722. }
  30723. m.SetAddtime(v)
  30724. return nil
  30725. case usagestatistichour.FieldType:
  30726. v, ok := value.(int)
  30727. if !ok {
  30728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30729. }
  30730. m.SetType(v)
  30731. return nil
  30732. case usagestatistichour.FieldBotID:
  30733. v, ok := value.(string)
  30734. if !ok {
  30735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30736. }
  30737. m.SetBotID(v)
  30738. return nil
  30739. case usagestatistichour.FieldOrganizationID:
  30740. v, ok := value.(uint64)
  30741. if !ok {
  30742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30743. }
  30744. m.SetOrganizationID(v)
  30745. return nil
  30746. case usagestatistichour.FieldAiResponse:
  30747. v, ok := value.(uint64)
  30748. if !ok {
  30749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30750. }
  30751. m.SetAiResponse(v)
  30752. return nil
  30753. case usagestatistichour.FieldSopRun:
  30754. v, ok := value.(uint64)
  30755. if !ok {
  30756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30757. }
  30758. m.SetSopRun(v)
  30759. return nil
  30760. case usagestatistichour.FieldTotalFriend:
  30761. v, ok := value.(uint64)
  30762. if !ok {
  30763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30764. }
  30765. m.SetTotalFriend(v)
  30766. return nil
  30767. case usagestatistichour.FieldTotalGroup:
  30768. v, ok := value.(uint64)
  30769. if !ok {
  30770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30771. }
  30772. m.SetTotalGroup(v)
  30773. return nil
  30774. case usagestatistichour.FieldAccountBalance:
  30775. v, ok := value.(uint64)
  30776. if !ok {
  30777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30778. }
  30779. m.SetAccountBalance(v)
  30780. return nil
  30781. case usagestatistichour.FieldConsumeToken:
  30782. v, ok := value.(uint64)
  30783. if !ok {
  30784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30785. }
  30786. m.SetConsumeToken(v)
  30787. return nil
  30788. case usagestatistichour.FieldActiveUser:
  30789. v, ok := value.(uint64)
  30790. if !ok {
  30791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30792. }
  30793. m.SetActiveUser(v)
  30794. return nil
  30795. case usagestatistichour.FieldNewUser:
  30796. v, ok := value.(int64)
  30797. if !ok {
  30798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30799. }
  30800. m.SetNewUser(v)
  30801. return nil
  30802. case usagestatistichour.FieldLabelDist:
  30803. v, ok := value.([]custom_types.LabelDist)
  30804. if !ok {
  30805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30806. }
  30807. m.SetLabelDist(v)
  30808. return nil
  30809. }
  30810. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30811. }
  30812. // AddedFields returns all numeric fields that were incremented/decremented during
  30813. // this mutation.
  30814. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30815. var fields []string
  30816. if m.addstatus != nil {
  30817. fields = append(fields, usagestatistichour.FieldStatus)
  30818. }
  30819. if m.addaddtime != nil {
  30820. fields = append(fields, usagestatistichour.FieldAddtime)
  30821. }
  30822. if m.add_type != nil {
  30823. fields = append(fields, usagestatistichour.FieldType)
  30824. }
  30825. if m.addorganization_id != nil {
  30826. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30827. }
  30828. if m.addai_response != nil {
  30829. fields = append(fields, usagestatistichour.FieldAiResponse)
  30830. }
  30831. if m.addsop_run != nil {
  30832. fields = append(fields, usagestatistichour.FieldSopRun)
  30833. }
  30834. if m.addtotal_friend != nil {
  30835. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30836. }
  30837. if m.addtotal_group != nil {
  30838. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30839. }
  30840. if m.addaccount_balance != nil {
  30841. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30842. }
  30843. if m.addconsume_token != nil {
  30844. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30845. }
  30846. if m.addactive_user != nil {
  30847. fields = append(fields, usagestatistichour.FieldActiveUser)
  30848. }
  30849. if m.addnew_user != nil {
  30850. fields = append(fields, usagestatistichour.FieldNewUser)
  30851. }
  30852. return fields
  30853. }
  30854. // AddedField returns the numeric value that was incremented/decremented on a field
  30855. // with the given name. The second boolean return value indicates that this field
  30856. // was not set, or was not defined in the schema.
  30857. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30858. switch name {
  30859. case usagestatistichour.FieldStatus:
  30860. return m.AddedStatus()
  30861. case usagestatistichour.FieldAddtime:
  30862. return m.AddedAddtime()
  30863. case usagestatistichour.FieldType:
  30864. return m.AddedType()
  30865. case usagestatistichour.FieldOrganizationID:
  30866. return m.AddedOrganizationID()
  30867. case usagestatistichour.FieldAiResponse:
  30868. return m.AddedAiResponse()
  30869. case usagestatistichour.FieldSopRun:
  30870. return m.AddedSopRun()
  30871. case usagestatistichour.FieldTotalFriend:
  30872. return m.AddedTotalFriend()
  30873. case usagestatistichour.FieldTotalGroup:
  30874. return m.AddedTotalGroup()
  30875. case usagestatistichour.FieldAccountBalance:
  30876. return m.AddedAccountBalance()
  30877. case usagestatistichour.FieldConsumeToken:
  30878. return m.AddedConsumeToken()
  30879. case usagestatistichour.FieldActiveUser:
  30880. return m.AddedActiveUser()
  30881. case usagestatistichour.FieldNewUser:
  30882. return m.AddedNewUser()
  30883. }
  30884. return nil, false
  30885. }
  30886. // AddField adds the value to the field with the given name. It returns an error if
  30887. // the field is not defined in the schema, or if the type mismatched the field
  30888. // type.
  30889. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30890. switch name {
  30891. case usagestatistichour.FieldStatus:
  30892. v, ok := value.(int8)
  30893. if !ok {
  30894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30895. }
  30896. m.AddStatus(v)
  30897. return nil
  30898. case usagestatistichour.FieldAddtime:
  30899. v, ok := value.(int64)
  30900. if !ok {
  30901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30902. }
  30903. m.AddAddtime(v)
  30904. return nil
  30905. case usagestatistichour.FieldType:
  30906. v, ok := value.(int)
  30907. if !ok {
  30908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30909. }
  30910. m.AddType(v)
  30911. return nil
  30912. case usagestatistichour.FieldOrganizationID:
  30913. v, ok := value.(int64)
  30914. if !ok {
  30915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30916. }
  30917. m.AddOrganizationID(v)
  30918. return nil
  30919. case usagestatistichour.FieldAiResponse:
  30920. v, ok := value.(int64)
  30921. if !ok {
  30922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30923. }
  30924. m.AddAiResponse(v)
  30925. return nil
  30926. case usagestatistichour.FieldSopRun:
  30927. v, ok := value.(int64)
  30928. if !ok {
  30929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30930. }
  30931. m.AddSopRun(v)
  30932. return nil
  30933. case usagestatistichour.FieldTotalFriend:
  30934. v, ok := value.(int64)
  30935. if !ok {
  30936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30937. }
  30938. m.AddTotalFriend(v)
  30939. return nil
  30940. case usagestatistichour.FieldTotalGroup:
  30941. v, ok := value.(int64)
  30942. if !ok {
  30943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30944. }
  30945. m.AddTotalGroup(v)
  30946. return nil
  30947. case usagestatistichour.FieldAccountBalance:
  30948. v, ok := value.(int64)
  30949. if !ok {
  30950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30951. }
  30952. m.AddAccountBalance(v)
  30953. return nil
  30954. case usagestatistichour.FieldConsumeToken:
  30955. v, ok := value.(int64)
  30956. if !ok {
  30957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30958. }
  30959. m.AddConsumeToken(v)
  30960. return nil
  30961. case usagestatistichour.FieldActiveUser:
  30962. v, ok := value.(int64)
  30963. if !ok {
  30964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30965. }
  30966. m.AddActiveUser(v)
  30967. return nil
  30968. case usagestatistichour.FieldNewUser:
  30969. v, ok := value.(int64)
  30970. if !ok {
  30971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30972. }
  30973. m.AddNewUser(v)
  30974. return nil
  30975. }
  30976. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  30977. }
  30978. // ClearedFields returns all nullable fields that were cleared during this
  30979. // mutation.
  30980. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  30981. var fields []string
  30982. if m.FieldCleared(usagestatistichour.FieldStatus) {
  30983. fields = append(fields, usagestatistichour.FieldStatus)
  30984. }
  30985. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  30986. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30987. }
  30988. if m.FieldCleared(usagestatistichour.FieldBotID) {
  30989. fields = append(fields, usagestatistichour.FieldBotID)
  30990. }
  30991. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  30992. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30993. }
  30994. return fields
  30995. }
  30996. // FieldCleared returns a boolean indicating if a field with the given name was
  30997. // cleared in this mutation.
  30998. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  30999. _, ok := m.clearedFields[name]
  31000. return ok
  31001. }
  31002. // ClearField clears the value of the field with the given name. It returns an
  31003. // error if the field is not defined in the schema.
  31004. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31005. switch name {
  31006. case usagestatistichour.FieldStatus:
  31007. m.ClearStatus()
  31008. return nil
  31009. case usagestatistichour.FieldDeletedAt:
  31010. m.ClearDeletedAt()
  31011. return nil
  31012. case usagestatistichour.FieldBotID:
  31013. m.ClearBotID()
  31014. return nil
  31015. case usagestatistichour.FieldOrganizationID:
  31016. m.ClearOrganizationID()
  31017. return nil
  31018. }
  31019. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31020. }
  31021. // ResetField resets all changes in the mutation for the field with the given name.
  31022. // It returns an error if the field is not defined in the schema.
  31023. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31024. switch name {
  31025. case usagestatistichour.FieldCreatedAt:
  31026. m.ResetCreatedAt()
  31027. return nil
  31028. case usagestatistichour.FieldUpdatedAt:
  31029. m.ResetUpdatedAt()
  31030. return nil
  31031. case usagestatistichour.FieldStatus:
  31032. m.ResetStatus()
  31033. return nil
  31034. case usagestatistichour.FieldDeletedAt:
  31035. m.ResetDeletedAt()
  31036. return nil
  31037. case usagestatistichour.FieldAddtime:
  31038. m.ResetAddtime()
  31039. return nil
  31040. case usagestatistichour.FieldType:
  31041. m.ResetType()
  31042. return nil
  31043. case usagestatistichour.FieldBotID:
  31044. m.ResetBotID()
  31045. return nil
  31046. case usagestatistichour.FieldOrganizationID:
  31047. m.ResetOrganizationID()
  31048. return nil
  31049. case usagestatistichour.FieldAiResponse:
  31050. m.ResetAiResponse()
  31051. return nil
  31052. case usagestatistichour.FieldSopRun:
  31053. m.ResetSopRun()
  31054. return nil
  31055. case usagestatistichour.FieldTotalFriend:
  31056. m.ResetTotalFriend()
  31057. return nil
  31058. case usagestatistichour.FieldTotalGroup:
  31059. m.ResetTotalGroup()
  31060. return nil
  31061. case usagestatistichour.FieldAccountBalance:
  31062. m.ResetAccountBalance()
  31063. return nil
  31064. case usagestatistichour.FieldConsumeToken:
  31065. m.ResetConsumeToken()
  31066. return nil
  31067. case usagestatistichour.FieldActiveUser:
  31068. m.ResetActiveUser()
  31069. return nil
  31070. case usagestatistichour.FieldNewUser:
  31071. m.ResetNewUser()
  31072. return nil
  31073. case usagestatistichour.FieldLabelDist:
  31074. m.ResetLabelDist()
  31075. return nil
  31076. }
  31077. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31078. }
  31079. // AddedEdges returns all edge names that were set/added in this mutation.
  31080. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31081. edges := make([]string, 0, 0)
  31082. return edges
  31083. }
  31084. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31085. // name in this mutation.
  31086. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31087. return nil
  31088. }
  31089. // RemovedEdges returns all edge names that were removed in this mutation.
  31090. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31091. edges := make([]string, 0, 0)
  31092. return edges
  31093. }
  31094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31095. // the given name in this mutation.
  31096. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31097. return nil
  31098. }
  31099. // ClearedEdges returns all edge names that were cleared in this mutation.
  31100. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31101. edges := make([]string, 0, 0)
  31102. return edges
  31103. }
  31104. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31105. // was cleared in this mutation.
  31106. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31107. return false
  31108. }
  31109. // ClearEdge clears the value of the edge with the given name. It returns an error
  31110. // if that edge is not defined in the schema.
  31111. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31112. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31113. }
  31114. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31115. // It returns an error if the edge is not defined in the schema.
  31116. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31117. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31118. }
  31119. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31120. type UsageStatisticMonthMutation struct {
  31121. config
  31122. op Op
  31123. typ string
  31124. id *uint64
  31125. created_at *time.Time
  31126. updated_at *time.Time
  31127. status *uint8
  31128. addstatus *int8
  31129. deleted_at *time.Time
  31130. addtime *uint64
  31131. addaddtime *int64
  31132. _type *int
  31133. add_type *int
  31134. bot_id *string
  31135. organization_id *uint64
  31136. addorganization_id *int64
  31137. ai_response *uint64
  31138. addai_response *int64
  31139. sop_run *uint64
  31140. addsop_run *int64
  31141. total_friend *uint64
  31142. addtotal_friend *int64
  31143. total_group *uint64
  31144. addtotal_group *int64
  31145. account_balance *uint64
  31146. addaccount_balance *int64
  31147. consume_token *uint64
  31148. addconsume_token *int64
  31149. active_user *uint64
  31150. addactive_user *int64
  31151. new_user *int64
  31152. addnew_user *int64
  31153. label_dist *[]custom_types.LabelDist
  31154. appendlabel_dist []custom_types.LabelDist
  31155. clearedFields map[string]struct{}
  31156. done bool
  31157. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31158. predicates []predicate.UsageStatisticMonth
  31159. }
  31160. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31161. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31162. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31163. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31164. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31165. m := &UsageStatisticMonthMutation{
  31166. config: c,
  31167. op: op,
  31168. typ: TypeUsageStatisticMonth,
  31169. clearedFields: make(map[string]struct{}),
  31170. }
  31171. for _, opt := range opts {
  31172. opt(m)
  31173. }
  31174. return m
  31175. }
  31176. // withUsageStatisticMonthID sets the ID field of the mutation.
  31177. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31178. return func(m *UsageStatisticMonthMutation) {
  31179. var (
  31180. err error
  31181. once sync.Once
  31182. value *UsageStatisticMonth
  31183. )
  31184. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31185. once.Do(func() {
  31186. if m.done {
  31187. err = errors.New("querying old values post mutation is not allowed")
  31188. } else {
  31189. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31190. }
  31191. })
  31192. return value, err
  31193. }
  31194. m.id = &id
  31195. }
  31196. }
  31197. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31198. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31199. return func(m *UsageStatisticMonthMutation) {
  31200. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31201. return node, nil
  31202. }
  31203. m.id = &node.ID
  31204. }
  31205. }
  31206. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31207. // executed in a transaction (ent.Tx), a transactional client is returned.
  31208. func (m UsageStatisticMonthMutation) Client() *Client {
  31209. client := &Client{config: m.config}
  31210. client.init()
  31211. return client
  31212. }
  31213. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31214. // it returns an error otherwise.
  31215. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31216. if _, ok := m.driver.(*txDriver); !ok {
  31217. return nil, errors.New("ent: mutation is not running in a transaction")
  31218. }
  31219. tx := &Tx{config: m.config}
  31220. tx.init()
  31221. return tx, nil
  31222. }
  31223. // SetID sets the value of the id field. Note that this
  31224. // operation is only accepted on creation of UsageStatisticMonth entities.
  31225. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31226. m.id = &id
  31227. }
  31228. // ID returns the ID value in the mutation. Note that the ID is only available
  31229. // if it was provided to the builder or after it was returned from the database.
  31230. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31231. if m.id == nil {
  31232. return
  31233. }
  31234. return *m.id, true
  31235. }
  31236. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31237. // That means, if the mutation is applied within a transaction with an isolation level such
  31238. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31239. // or updated by the mutation.
  31240. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31241. switch {
  31242. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31243. id, exists := m.ID()
  31244. if exists {
  31245. return []uint64{id}, nil
  31246. }
  31247. fallthrough
  31248. case m.op.Is(OpUpdate | OpDelete):
  31249. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31250. default:
  31251. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31252. }
  31253. }
  31254. // SetCreatedAt sets the "created_at" field.
  31255. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31256. m.created_at = &t
  31257. }
  31258. // CreatedAt returns the value of the "created_at" field in the mutation.
  31259. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31260. v := m.created_at
  31261. if v == nil {
  31262. return
  31263. }
  31264. return *v, true
  31265. }
  31266. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31267. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31269. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31270. if !m.op.Is(OpUpdateOne) {
  31271. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31272. }
  31273. if m.id == nil || m.oldValue == nil {
  31274. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31275. }
  31276. oldValue, err := m.oldValue(ctx)
  31277. if err != nil {
  31278. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31279. }
  31280. return oldValue.CreatedAt, nil
  31281. }
  31282. // ResetCreatedAt resets all changes to the "created_at" field.
  31283. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31284. m.created_at = nil
  31285. }
  31286. // SetUpdatedAt sets the "updated_at" field.
  31287. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31288. m.updated_at = &t
  31289. }
  31290. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31291. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31292. v := m.updated_at
  31293. if v == nil {
  31294. return
  31295. }
  31296. return *v, true
  31297. }
  31298. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31299. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31301. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31302. if !m.op.Is(OpUpdateOne) {
  31303. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31304. }
  31305. if m.id == nil || m.oldValue == nil {
  31306. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31307. }
  31308. oldValue, err := m.oldValue(ctx)
  31309. if err != nil {
  31310. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31311. }
  31312. return oldValue.UpdatedAt, nil
  31313. }
  31314. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31315. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31316. m.updated_at = nil
  31317. }
  31318. // SetStatus sets the "status" field.
  31319. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31320. m.status = &u
  31321. m.addstatus = nil
  31322. }
  31323. // Status returns the value of the "status" field in the mutation.
  31324. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31325. v := m.status
  31326. if v == nil {
  31327. return
  31328. }
  31329. return *v, true
  31330. }
  31331. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31332. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31334. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31335. if !m.op.Is(OpUpdateOne) {
  31336. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31337. }
  31338. if m.id == nil || m.oldValue == nil {
  31339. return v, errors.New("OldStatus requires an ID field in the mutation")
  31340. }
  31341. oldValue, err := m.oldValue(ctx)
  31342. if err != nil {
  31343. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31344. }
  31345. return oldValue.Status, nil
  31346. }
  31347. // AddStatus adds u to the "status" field.
  31348. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31349. if m.addstatus != nil {
  31350. *m.addstatus += u
  31351. } else {
  31352. m.addstatus = &u
  31353. }
  31354. }
  31355. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31356. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31357. v := m.addstatus
  31358. if v == nil {
  31359. return
  31360. }
  31361. return *v, true
  31362. }
  31363. // ClearStatus clears the value of the "status" field.
  31364. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31365. m.status = nil
  31366. m.addstatus = nil
  31367. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31368. }
  31369. // StatusCleared returns if the "status" field was cleared in this mutation.
  31370. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31371. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31372. return ok
  31373. }
  31374. // ResetStatus resets all changes to the "status" field.
  31375. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31376. m.status = nil
  31377. m.addstatus = nil
  31378. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31379. }
  31380. // SetDeletedAt sets the "deleted_at" field.
  31381. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31382. m.deleted_at = &t
  31383. }
  31384. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31385. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31386. v := m.deleted_at
  31387. if v == nil {
  31388. return
  31389. }
  31390. return *v, true
  31391. }
  31392. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31393. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31395. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31396. if !m.op.Is(OpUpdateOne) {
  31397. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31398. }
  31399. if m.id == nil || m.oldValue == nil {
  31400. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31401. }
  31402. oldValue, err := m.oldValue(ctx)
  31403. if err != nil {
  31404. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31405. }
  31406. return oldValue.DeletedAt, nil
  31407. }
  31408. // ClearDeletedAt clears the value of the "deleted_at" field.
  31409. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31410. m.deleted_at = nil
  31411. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31412. }
  31413. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31414. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31415. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31416. return ok
  31417. }
  31418. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31419. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31420. m.deleted_at = nil
  31421. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31422. }
  31423. // SetAddtime sets the "addtime" field.
  31424. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31425. m.addtime = &u
  31426. m.addaddtime = nil
  31427. }
  31428. // Addtime returns the value of the "addtime" field in the mutation.
  31429. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31430. v := m.addtime
  31431. if v == nil {
  31432. return
  31433. }
  31434. return *v, true
  31435. }
  31436. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31437. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31439. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31440. if !m.op.Is(OpUpdateOne) {
  31441. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31442. }
  31443. if m.id == nil || m.oldValue == nil {
  31444. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31445. }
  31446. oldValue, err := m.oldValue(ctx)
  31447. if err != nil {
  31448. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31449. }
  31450. return oldValue.Addtime, nil
  31451. }
  31452. // AddAddtime adds u to the "addtime" field.
  31453. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31454. if m.addaddtime != nil {
  31455. *m.addaddtime += u
  31456. } else {
  31457. m.addaddtime = &u
  31458. }
  31459. }
  31460. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31461. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31462. v := m.addaddtime
  31463. if v == nil {
  31464. return
  31465. }
  31466. return *v, true
  31467. }
  31468. // ResetAddtime resets all changes to the "addtime" field.
  31469. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31470. m.addtime = nil
  31471. m.addaddtime = nil
  31472. }
  31473. // SetType sets the "type" field.
  31474. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31475. m._type = &i
  31476. m.add_type = nil
  31477. }
  31478. // GetType returns the value of the "type" field in the mutation.
  31479. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31480. v := m._type
  31481. if v == nil {
  31482. return
  31483. }
  31484. return *v, true
  31485. }
  31486. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31487. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31489. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31490. if !m.op.Is(OpUpdateOne) {
  31491. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31492. }
  31493. if m.id == nil || m.oldValue == nil {
  31494. return v, errors.New("OldType requires an ID field in the mutation")
  31495. }
  31496. oldValue, err := m.oldValue(ctx)
  31497. if err != nil {
  31498. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31499. }
  31500. return oldValue.Type, nil
  31501. }
  31502. // AddType adds i to the "type" field.
  31503. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31504. if m.add_type != nil {
  31505. *m.add_type += i
  31506. } else {
  31507. m.add_type = &i
  31508. }
  31509. }
  31510. // AddedType returns the value that was added to the "type" field in this mutation.
  31511. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31512. v := m.add_type
  31513. if v == nil {
  31514. return
  31515. }
  31516. return *v, true
  31517. }
  31518. // ResetType resets all changes to the "type" field.
  31519. func (m *UsageStatisticMonthMutation) ResetType() {
  31520. m._type = nil
  31521. m.add_type = nil
  31522. }
  31523. // SetBotID sets the "bot_id" field.
  31524. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31525. m.bot_id = &s
  31526. }
  31527. // BotID returns the value of the "bot_id" field in the mutation.
  31528. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31529. v := m.bot_id
  31530. if v == nil {
  31531. return
  31532. }
  31533. return *v, true
  31534. }
  31535. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31536. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31538. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31539. if !m.op.Is(OpUpdateOne) {
  31540. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31541. }
  31542. if m.id == nil || m.oldValue == nil {
  31543. return v, errors.New("OldBotID requires an ID field in the mutation")
  31544. }
  31545. oldValue, err := m.oldValue(ctx)
  31546. if err != nil {
  31547. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31548. }
  31549. return oldValue.BotID, nil
  31550. }
  31551. // ClearBotID clears the value of the "bot_id" field.
  31552. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31553. m.bot_id = nil
  31554. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31555. }
  31556. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31557. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31558. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31559. return ok
  31560. }
  31561. // ResetBotID resets all changes to the "bot_id" field.
  31562. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31563. m.bot_id = nil
  31564. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31565. }
  31566. // SetOrganizationID sets the "organization_id" field.
  31567. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31568. m.organization_id = &u
  31569. m.addorganization_id = nil
  31570. }
  31571. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31572. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31573. v := m.organization_id
  31574. if v == nil {
  31575. return
  31576. }
  31577. return *v, true
  31578. }
  31579. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31580. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31582. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31583. if !m.op.Is(OpUpdateOne) {
  31584. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31585. }
  31586. if m.id == nil || m.oldValue == nil {
  31587. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31588. }
  31589. oldValue, err := m.oldValue(ctx)
  31590. if err != nil {
  31591. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31592. }
  31593. return oldValue.OrganizationID, nil
  31594. }
  31595. // AddOrganizationID adds u to the "organization_id" field.
  31596. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31597. if m.addorganization_id != nil {
  31598. *m.addorganization_id += u
  31599. } else {
  31600. m.addorganization_id = &u
  31601. }
  31602. }
  31603. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31604. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31605. v := m.addorganization_id
  31606. if v == nil {
  31607. return
  31608. }
  31609. return *v, true
  31610. }
  31611. // ClearOrganizationID clears the value of the "organization_id" field.
  31612. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31613. m.organization_id = nil
  31614. m.addorganization_id = nil
  31615. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31616. }
  31617. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31618. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31619. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31620. return ok
  31621. }
  31622. // ResetOrganizationID resets all changes to the "organization_id" field.
  31623. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31624. m.organization_id = nil
  31625. m.addorganization_id = nil
  31626. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31627. }
  31628. // SetAiResponse sets the "ai_response" field.
  31629. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31630. m.ai_response = &u
  31631. m.addai_response = nil
  31632. }
  31633. // AiResponse returns the value of the "ai_response" field in the mutation.
  31634. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31635. v := m.ai_response
  31636. if v == nil {
  31637. return
  31638. }
  31639. return *v, true
  31640. }
  31641. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31642. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31644. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31645. if !m.op.Is(OpUpdateOne) {
  31646. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31647. }
  31648. if m.id == nil || m.oldValue == nil {
  31649. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31650. }
  31651. oldValue, err := m.oldValue(ctx)
  31652. if err != nil {
  31653. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31654. }
  31655. return oldValue.AiResponse, nil
  31656. }
  31657. // AddAiResponse adds u to the "ai_response" field.
  31658. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31659. if m.addai_response != nil {
  31660. *m.addai_response += u
  31661. } else {
  31662. m.addai_response = &u
  31663. }
  31664. }
  31665. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31666. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31667. v := m.addai_response
  31668. if v == nil {
  31669. return
  31670. }
  31671. return *v, true
  31672. }
  31673. // ResetAiResponse resets all changes to the "ai_response" field.
  31674. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31675. m.ai_response = nil
  31676. m.addai_response = nil
  31677. }
  31678. // SetSopRun sets the "sop_run" field.
  31679. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31680. m.sop_run = &u
  31681. m.addsop_run = nil
  31682. }
  31683. // SopRun returns the value of the "sop_run" field in the mutation.
  31684. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31685. v := m.sop_run
  31686. if v == nil {
  31687. return
  31688. }
  31689. return *v, true
  31690. }
  31691. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31692. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31694. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31695. if !m.op.Is(OpUpdateOne) {
  31696. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31697. }
  31698. if m.id == nil || m.oldValue == nil {
  31699. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31700. }
  31701. oldValue, err := m.oldValue(ctx)
  31702. if err != nil {
  31703. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31704. }
  31705. return oldValue.SopRun, nil
  31706. }
  31707. // AddSopRun adds u to the "sop_run" field.
  31708. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31709. if m.addsop_run != nil {
  31710. *m.addsop_run += u
  31711. } else {
  31712. m.addsop_run = &u
  31713. }
  31714. }
  31715. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31716. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31717. v := m.addsop_run
  31718. if v == nil {
  31719. return
  31720. }
  31721. return *v, true
  31722. }
  31723. // ResetSopRun resets all changes to the "sop_run" field.
  31724. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31725. m.sop_run = nil
  31726. m.addsop_run = nil
  31727. }
  31728. // SetTotalFriend sets the "total_friend" field.
  31729. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31730. m.total_friend = &u
  31731. m.addtotal_friend = nil
  31732. }
  31733. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31734. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31735. v := m.total_friend
  31736. if v == nil {
  31737. return
  31738. }
  31739. return *v, true
  31740. }
  31741. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31742. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31744. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31745. if !m.op.Is(OpUpdateOne) {
  31746. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31747. }
  31748. if m.id == nil || m.oldValue == nil {
  31749. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31750. }
  31751. oldValue, err := m.oldValue(ctx)
  31752. if err != nil {
  31753. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31754. }
  31755. return oldValue.TotalFriend, nil
  31756. }
  31757. // AddTotalFriend adds u to the "total_friend" field.
  31758. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31759. if m.addtotal_friend != nil {
  31760. *m.addtotal_friend += u
  31761. } else {
  31762. m.addtotal_friend = &u
  31763. }
  31764. }
  31765. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31766. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31767. v := m.addtotal_friend
  31768. if v == nil {
  31769. return
  31770. }
  31771. return *v, true
  31772. }
  31773. // ResetTotalFriend resets all changes to the "total_friend" field.
  31774. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31775. m.total_friend = nil
  31776. m.addtotal_friend = nil
  31777. }
  31778. // SetTotalGroup sets the "total_group" field.
  31779. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31780. m.total_group = &u
  31781. m.addtotal_group = nil
  31782. }
  31783. // TotalGroup returns the value of the "total_group" field in the mutation.
  31784. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31785. v := m.total_group
  31786. if v == nil {
  31787. return
  31788. }
  31789. return *v, true
  31790. }
  31791. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31792. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31794. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31795. if !m.op.Is(OpUpdateOne) {
  31796. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31797. }
  31798. if m.id == nil || m.oldValue == nil {
  31799. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31800. }
  31801. oldValue, err := m.oldValue(ctx)
  31802. if err != nil {
  31803. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31804. }
  31805. return oldValue.TotalGroup, nil
  31806. }
  31807. // AddTotalGroup adds u to the "total_group" field.
  31808. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31809. if m.addtotal_group != nil {
  31810. *m.addtotal_group += u
  31811. } else {
  31812. m.addtotal_group = &u
  31813. }
  31814. }
  31815. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31816. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31817. v := m.addtotal_group
  31818. if v == nil {
  31819. return
  31820. }
  31821. return *v, true
  31822. }
  31823. // ResetTotalGroup resets all changes to the "total_group" field.
  31824. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31825. m.total_group = nil
  31826. m.addtotal_group = nil
  31827. }
  31828. // SetAccountBalance sets the "account_balance" field.
  31829. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31830. m.account_balance = &u
  31831. m.addaccount_balance = nil
  31832. }
  31833. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31834. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31835. v := m.account_balance
  31836. if v == nil {
  31837. return
  31838. }
  31839. return *v, true
  31840. }
  31841. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31842. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31844. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31845. if !m.op.Is(OpUpdateOne) {
  31846. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31847. }
  31848. if m.id == nil || m.oldValue == nil {
  31849. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31850. }
  31851. oldValue, err := m.oldValue(ctx)
  31852. if err != nil {
  31853. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31854. }
  31855. return oldValue.AccountBalance, nil
  31856. }
  31857. // AddAccountBalance adds u to the "account_balance" field.
  31858. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31859. if m.addaccount_balance != nil {
  31860. *m.addaccount_balance += u
  31861. } else {
  31862. m.addaccount_balance = &u
  31863. }
  31864. }
  31865. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31866. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31867. v := m.addaccount_balance
  31868. if v == nil {
  31869. return
  31870. }
  31871. return *v, true
  31872. }
  31873. // ResetAccountBalance resets all changes to the "account_balance" field.
  31874. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31875. m.account_balance = nil
  31876. m.addaccount_balance = nil
  31877. }
  31878. // SetConsumeToken sets the "consume_token" field.
  31879. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31880. m.consume_token = &u
  31881. m.addconsume_token = nil
  31882. }
  31883. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31884. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31885. v := m.consume_token
  31886. if v == nil {
  31887. return
  31888. }
  31889. return *v, true
  31890. }
  31891. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31892. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31894. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31895. if !m.op.Is(OpUpdateOne) {
  31896. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31897. }
  31898. if m.id == nil || m.oldValue == nil {
  31899. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31900. }
  31901. oldValue, err := m.oldValue(ctx)
  31902. if err != nil {
  31903. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31904. }
  31905. return oldValue.ConsumeToken, nil
  31906. }
  31907. // AddConsumeToken adds u to the "consume_token" field.
  31908. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31909. if m.addconsume_token != nil {
  31910. *m.addconsume_token += u
  31911. } else {
  31912. m.addconsume_token = &u
  31913. }
  31914. }
  31915. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31916. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31917. v := m.addconsume_token
  31918. if v == nil {
  31919. return
  31920. }
  31921. return *v, true
  31922. }
  31923. // ResetConsumeToken resets all changes to the "consume_token" field.
  31924. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31925. m.consume_token = nil
  31926. m.addconsume_token = nil
  31927. }
  31928. // SetActiveUser sets the "active_user" field.
  31929. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31930. m.active_user = &u
  31931. m.addactive_user = nil
  31932. }
  31933. // ActiveUser returns the value of the "active_user" field in the mutation.
  31934. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31935. v := m.active_user
  31936. if v == nil {
  31937. return
  31938. }
  31939. return *v, true
  31940. }
  31941. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  31942. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31944. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31945. if !m.op.Is(OpUpdateOne) {
  31946. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31947. }
  31948. if m.id == nil || m.oldValue == nil {
  31949. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31950. }
  31951. oldValue, err := m.oldValue(ctx)
  31952. if err != nil {
  31953. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31954. }
  31955. return oldValue.ActiveUser, nil
  31956. }
  31957. // AddActiveUser adds u to the "active_user" field.
  31958. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  31959. if m.addactive_user != nil {
  31960. *m.addactive_user += u
  31961. } else {
  31962. m.addactive_user = &u
  31963. }
  31964. }
  31965. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31966. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  31967. v := m.addactive_user
  31968. if v == nil {
  31969. return
  31970. }
  31971. return *v, true
  31972. }
  31973. // ResetActiveUser resets all changes to the "active_user" field.
  31974. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  31975. m.active_user = nil
  31976. m.addactive_user = nil
  31977. }
  31978. // SetNewUser sets the "new_user" field.
  31979. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  31980. m.new_user = &i
  31981. m.addnew_user = nil
  31982. }
  31983. // NewUser returns the value of the "new_user" field in the mutation.
  31984. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  31985. v := m.new_user
  31986. if v == nil {
  31987. return
  31988. }
  31989. return *v, true
  31990. }
  31991. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  31992. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31994. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31995. if !m.op.Is(OpUpdateOne) {
  31996. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31997. }
  31998. if m.id == nil || m.oldValue == nil {
  31999. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32000. }
  32001. oldValue, err := m.oldValue(ctx)
  32002. if err != nil {
  32003. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32004. }
  32005. return oldValue.NewUser, nil
  32006. }
  32007. // AddNewUser adds i to the "new_user" field.
  32008. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32009. if m.addnew_user != nil {
  32010. *m.addnew_user += i
  32011. } else {
  32012. m.addnew_user = &i
  32013. }
  32014. }
  32015. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32016. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32017. v := m.addnew_user
  32018. if v == nil {
  32019. return
  32020. }
  32021. return *v, true
  32022. }
  32023. // ResetNewUser resets all changes to the "new_user" field.
  32024. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32025. m.new_user = nil
  32026. m.addnew_user = nil
  32027. }
  32028. // SetLabelDist sets the "label_dist" field.
  32029. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32030. m.label_dist = &ctd
  32031. m.appendlabel_dist = nil
  32032. }
  32033. // LabelDist returns the value of the "label_dist" field in the mutation.
  32034. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32035. v := m.label_dist
  32036. if v == nil {
  32037. return
  32038. }
  32039. return *v, true
  32040. }
  32041. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32042. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32044. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32045. if !m.op.Is(OpUpdateOne) {
  32046. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32047. }
  32048. if m.id == nil || m.oldValue == nil {
  32049. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32050. }
  32051. oldValue, err := m.oldValue(ctx)
  32052. if err != nil {
  32053. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32054. }
  32055. return oldValue.LabelDist, nil
  32056. }
  32057. // AppendLabelDist adds ctd to the "label_dist" field.
  32058. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32059. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32060. }
  32061. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32062. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32063. if len(m.appendlabel_dist) == 0 {
  32064. return nil, false
  32065. }
  32066. return m.appendlabel_dist, true
  32067. }
  32068. // ResetLabelDist resets all changes to the "label_dist" field.
  32069. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32070. m.label_dist = nil
  32071. m.appendlabel_dist = nil
  32072. }
  32073. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32074. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32075. m.predicates = append(m.predicates, ps...)
  32076. }
  32077. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32078. // users can use type-assertion to append predicates that do not depend on any generated package.
  32079. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32080. p := make([]predicate.UsageStatisticMonth, len(ps))
  32081. for i := range ps {
  32082. p[i] = ps[i]
  32083. }
  32084. m.Where(p...)
  32085. }
  32086. // Op returns the operation name.
  32087. func (m *UsageStatisticMonthMutation) Op() Op {
  32088. return m.op
  32089. }
  32090. // SetOp allows setting the mutation operation.
  32091. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32092. m.op = op
  32093. }
  32094. // Type returns the node type of this mutation (UsageStatisticMonth).
  32095. func (m *UsageStatisticMonthMutation) Type() string {
  32096. return m.typ
  32097. }
  32098. // Fields returns all fields that were changed during this mutation. Note that in
  32099. // order to get all numeric fields that were incremented/decremented, call
  32100. // AddedFields().
  32101. func (m *UsageStatisticMonthMutation) Fields() []string {
  32102. fields := make([]string, 0, 17)
  32103. if m.created_at != nil {
  32104. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32105. }
  32106. if m.updated_at != nil {
  32107. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32108. }
  32109. if m.status != nil {
  32110. fields = append(fields, usagestatisticmonth.FieldStatus)
  32111. }
  32112. if m.deleted_at != nil {
  32113. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32114. }
  32115. if m.addtime != nil {
  32116. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32117. }
  32118. if m._type != nil {
  32119. fields = append(fields, usagestatisticmonth.FieldType)
  32120. }
  32121. if m.bot_id != nil {
  32122. fields = append(fields, usagestatisticmonth.FieldBotID)
  32123. }
  32124. if m.organization_id != nil {
  32125. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32126. }
  32127. if m.ai_response != nil {
  32128. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32129. }
  32130. if m.sop_run != nil {
  32131. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32132. }
  32133. if m.total_friend != nil {
  32134. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32135. }
  32136. if m.total_group != nil {
  32137. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32138. }
  32139. if m.account_balance != nil {
  32140. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32141. }
  32142. if m.consume_token != nil {
  32143. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32144. }
  32145. if m.active_user != nil {
  32146. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32147. }
  32148. if m.new_user != nil {
  32149. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32150. }
  32151. if m.label_dist != nil {
  32152. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32153. }
  32154. return fields
  32155. }
  32156. // Field returns the value of a field with the given name. The second boolean
  32157. // return value indicates that this field was not set, or was not defined in the
  32158. // schema.
  32159. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32160. switch name {
  32161. case usagestatisticmonth.FieldCreatedAt:
  32162. return m.CreatedAt()
  32163. case usagestatisticmonth.FieldUpdatedAt:
  32164. return m.UpdatedAt()
  32165. case usagestatisticmonth.FieldStatus:
  32166. return m.Status()
  32167. case usagestatisticmonth.FieldDeletedAt:
  32168. return m.DeletedAt()
  32169. case usagestatisticmonth.FieldAddtime:
  32170. return m.Addtime()
  32171. case usagestatisticmonth.FieldType:
  32172. return m.GetType()
  32173. case usagestatisticmonth.FieldBotID:
  32174. return m.BotID()
  32175. case usagestatisticmonth.FieldOrganizationID:
  32176. return m.OrganizationID()
  32177. case usagestatisticmonth.FieldAiResponse:
  32178. return m.AiResponse()
  32179. case usagestatisticmonth.FieldSopRun:
  32180. return m.SopRun()
  32181. case usagestatisticmonth.FieldTotalFriend:
  32182. return m.TotalFriend()
  32183. case usagestatisticmonth.FieldTotalGroup:
  32184. return m.TotalGroup()
  32185. case usagestatisticmonth.FieldAccountBalance:
  32186. return m.AccountBalance()
  32187. case usagestatisticmonth.FieldConsumeToken:
  32188. return m.ConsumeToken()
  32189. case usagestatisticmonth.FieldActiveUser:
  32190. return m.ActiveUser()
  32191. case usagestatisticmonth.FieldNewUser:
  32192. return m.NewUser()
  32193. case usagestatisticmonth.FieldLabelDist:
  32194. return m.LabelDist()
  32195. }
  32196. return nil, false
  32197. }
  32198. // OldField returns the old value of the field from the database. An error is
  32199. // returned if the mutation operation is not UpdateOne, or the query to the
  32200. // database failed.
  32201. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32202. switch name {
  32203. case usagestatisticmonth.FieldCreatedAt:
  32204. return m.OldCreatedAt(ctx)
  32205. case usagestatisticmonth.FieldUpdatedAt:
  32206. return m.OldUpdatedAt(ctx)
  32207. case usagestatisticmonth.FieldStatus:
  32208. return m.OldStatus(ctx)
  32209. case usagestatisticmonth.FieldDeletedAt:
  32210. return m.OldDeletedAt(ctx)
  32211. case usagestatisticmonth.FieldAddtime:
  32212. return m.OldAddtime(ctx)
  32213. case usagestatisticmonth.FieldType:
  32214. return m.OldType(ctx)
  32215. case usagestatisticmonth.FieldBotID:
  32216. return m.OldBotID(ctx)
  32217. case usagestatisticmonth.FieldOrganizationID:
  32218. return m.OldOrganizationID(ctx)
  32219. case usagestatisticmonth.FieldAiResponse:
  32220. return m.OldAiResponse(ctx)
  32221. case usagestatisticmonth.FieldSopRun:
  32222. return m.OldSopRun(ctx)
  32223. case usagestatisticmonth.FieldTotalFriend:
  32224. return m.OldTotalFriend(ctx)
  32225. case usagestatisticmonth.FieldTotalGroup:
  32226. return m.OldTotalGroup(ctx)
  32227. case usagestatisticmonth.FieldAccountBalance:
  32228. return m.OldAccountBalance(ctx)
  32229. case usagestatisticmonth.FieldConsumeToken:
  32230. return m.OldConsumeToken(ctx)
  32231. case usagestatisticmonth.FieldActiveUser:
  32232. return m.OldActiveUser(ctx)
  32233. case usagestatisticmonth.FieldNewUser:
  32234. return m.OldNewUser(ctx)
  32235. case usagestatisticmonth.FieldLabelDist:
  32236. return m.OldLabelDist(ctx)
  32237. }
  32238. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32239. }
  32240. // SetField sets the value of a field with the given name. It returns an error if
  32241. // the field is not defined in the schema, or if the type mismatched the field
  32242. // type.
  32243. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32244. switch name {
  32245. case usagestatisticmonth.FieldCreatedAt:
  32246. v, ok := value.(time.Time)
  32247. if !ok {
  32248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32249. }
  32250. m.SetCreatedAt(v)
  32251. return nil
  32252. case usagestatisticmonth.FieldUpdatedAt:
  32253. v, ok := value.(time.Time)
  32254. if !ok {
  32255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32256. }
  32257. m.SetUpdatedAt(v)
  32258. return nil
  32259. case usagestatisticmonth.FieldStatus:
  32260. v, ok := value.(uint8)
  32261. if !ok {
  32262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32263. }
  32264. m.SetStatus(v)
  32265. return nil
  32266. case usagestatisticmonth.FieldDeletedAt:
  32267. v, ok := value.(time.Time)
  32268. if !ok {
  32269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32270. }
  32271. m.SetDeletedAt(v)
  32272. return nil
  32273. case usagestatisticmonth.FieldAddtime:
  32274. v, ok := value.(uint64)
  32275. if !ok {
  32276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32277. }
  32278. m.SetAddtime(v)
  32279. return nil
  32280. case usagestatisticmonth.FieldType:
  32281. v, ok := value.(int)
  32282. if !ok {
  32283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32284. }
  32285. m.SetType(v)
  32286. return nil
  32287. case usagestatisticmonth.FieldBotID:
  32288. v, ok := value.(string)
  32289. if !ok {
  32290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32291. }
  32292. m.SetBotID(v)
  32293. return nil
  32294. case usagestatisticmonth.FieldOrganizationID:
  32295. v, ok := value.(uint64)
  32296. if !ok {
  32297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32298. }
  32299. m.SetOrganizationID(v)
  32300. return nil
  32301. case usagestatisticmonth.FieldAiResponse:
  32302. v, ok := value.(uint64)
  32303. if !ok {
  32304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32305. }
  32306. m.SetAiResponse(v)
  32307. return nil
  32308. case usagestatisticmonth.FieldSopRun:
  32309. v, ok := value.(uint64)
  32310. if !ok {
  32311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32312. }
  32313. m.SetSopRun(v)
  32314. return nil
  32315. case usagestatisticmonth.FieldTotalFriend:
  32316. v, ok := value.(uint64)
  32317. if !ok {
  32318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32319. }
  32320. m.SetTotalFriend(v)
  32321. return nil
  32322. case usagestatisticmonth.FieldTotalGroup:
  32323. v, ok := value.(uint64)
  32324. if !ok {
  32325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32326. }
  32327. m.SetTotalGroup(v)
  32328. return nil
  32329. case usagestatisticmonth.FieldAccountBalance:
  32330. v, ok := value.(uint64)
  32331. if !ok {
  32332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32333. }
  32334. m.SetAccountBalance(v)
  32335. return nil
  32336. case usagestatisticmonth.FieldConsumeToken:
  32337. v, ok := value.(uint64)
  32338. if !ok {
  32339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32340. }
  32341. m.SetConsumeToken(v)
  32342. return nil
  32343. case usagestatisticmonth.FieldActiveUser:
  32344. v, ok := value.(uint64)
  32345. if !ok {
  32346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32347. }
  32348. m.SetActiveUser(v)
  32349. return nil
  32350. case usagestatisticmonth.FieldNewUser:
  32351. v, ok := value.(int64)
  32352. if !ok {
  32353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32354. }
  32355. m.SetNewUser(v)
  32356. return nil
  32357. case usagestatisticmonth.FieldLabelDist:
  32358. v, ok := value.([]custom_types.LabelDist)
  32359. if !ok {
  32360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32361. }
  32362. m.SetLabelDist(v)
  32363. return nil
  32364. }
  32365. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32366. }
  32367. // AddedFields returns all numeric fields that were incremented/decremented during
  32368. // this mutation.
  32369. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32370. var fields []string
  32371. if m.addstatus != nil {
  32372. fields = append(fields, usagestatisticmonth.FieldStatus)
  32373. }
  32374. if m.addaddtime != nil {
  32375. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32376. }
  32377. if m.add_type != nil {
  32378. fields = append(fields, usagestatisticmonth.FieldType)
  32379. }
  32380. if m.addorganization_id != nil {
  32381. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32382. }
  32383. if m.addai_response != nil {
  32384. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32385. }
  32386. if m.addsop_run != nil {
  32387. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32388. }
  32389. if m.addtotal_friend != nil {
  32390. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32391. }
  32392. if m.addtotal_group != nil {
  32393. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32394. }
  32395. if m.addaccount_balance != nil {
  32396. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32397. }
  32398. if m.addconsume_token != nil {
  32399. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32400. }
  32401. if m.addactive_user != nil {
  32402. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32403. }
  32404. if m.addnew_user != nil {
  32405. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32406. }
  32407. return fields
  32408. }
  32409. // AddedField returns the numeric value that was incremented/decremented on a field
  32410. // with the given name. The second boolean return value indicates that this field
  32411. // was not set, or was not defined in the schema.
  32412. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32413. switch name {
  32414. case usagestatisticmonth.FieldStatus:
  32415. return m.AddedStatus()
  32416. case usagestatisticmonth.FieldAddtime:
  32417. return m.AddedAddtime()
  32418. case usagestatisticmonth.FieldType:
  32419. return m.AddedType()
  32420. case usagestatisticmonth.FieldOrganizationID:
  32421. return m.AddedOrganizationID()
  32422. case usagestatisticmonth.FieldAiResponse:
  32423. return m.AddedAiResponse()
  32424. case usagestatisticmonth.FieldSopRun:
  32425. return m.AddedSopRun()
  32426. case usagestatisticmonth.FieldTotalFriend:
  32427. return m.AddedTotalFriend()
  32428. case usagestatisticmonth.FieldTotalGroup:
  32429. return m.AddedTotalGroup()
  32430. case usagestatisticmonth.FieldAccountBalance:
  32431. return m.AddedAccountBalance()
  32432. case usagestatisticmonth.FieldConsumeToken:
  32433. return m.AddedConsumeToken()
  32434. case usagestatisticmonth.FieldActiveUser:
  32435. return m.AddedActiveUser()
  32436. case usagestatisticmonth.FieldNewUser:
  32437. return m.AddedNewUser()
  32438. }
  32439. return nil, false
  32440. }
  32441. // AddField adds the value to the field with the given name. It returns an error if
  32442. // the field is not defined in the schema, or if the type mismatched the field
  32443. // type.
  32444. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32445. switch name {
  32446. case usagestatisticmonth.FieldStatus:
  32447. v, ok := value.(int8)
  32448. if !ok {
  32449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32450. }
  32451. m.AddStatus(v)
  32452. return nil
  32453. case usagestatisticmonth.FieldAddtime:
  32454. v, ok := value.(int64)
  32455. if !ok {
  32456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32457. }
  32458. m.AddAddtime(v)
  32459. return nil
  32460. case usagestatisticmonth.FieldType:
  32461. v, ok := value.(int)
  32462. if !ok {
  32463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32464. }
  32465. m.AddType(v)
  32466. return nil
  32467. case usagestatisticmonth.FieldOrganizationID:
  32468. v, ok := value.(int64)
  32469. if !ok {
  32470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32471. }
  32472. m.AddOrganizationID(v)
  32473. return nil
  32474. case usagestatisticmonth.FieldAiResponse:
  32475. v, ok := value.(int64)
  32476. if !ok {
  32477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32478. }
  32479. m.AddAiResponse(v)
  32480. return nil
  32481. case usagestatisticmonth.FieldSopRun:
  32482. v, ok := value.(int64)
  32483. if !ok {
  32484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32485. }
  32486. m.AddSopRun(v)
  32487. return nil
  32488. case usagestatisticmonth.FieldTotalFriend:
  32489. v, ok := value.(int64)
  32490. if !ok {
  32491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32492. }
  32493. m.AddTotalFriend(v)
  32494. return nil
  32495. case usagestatisticmonth.FieldTotalGroup:
  32496. v, ok := value.(int64)
  32497. if !ok {
  32498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32499. }
  32500. m.AddTotalGroup(v)
  32501. return nil
  32502. case usagestatisticmonth.FieldAccountBalance:
  32503. v, ok := value.(int64)
  32504. if !ok {
  32505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32506. }
  32507. m.AddAccountBalance(v)
  32508. return nil
  32509. case usagestatisticmonth.FieldConsumeToken:
  32510. v, ok := value.(int64)
  32511. if !ok {
  32512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32513. }
  32514. m.AddConsumeToken(v)
  32515. return nil
  32516. case usagestatisticmonth.FieldActiveUser:
  32517. v, ok := value.(int64)
  32518. if !ok {
  32519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32520. }
  32521. m.AddActiveUser(v)
  32522. return nil
  32523. case usagestatisticmonth.FieldNewUser:
  32524. v, ok := value.(int64)
  32525. if !ok {
  32526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32527. }
  32528. m.AddNewUser(v)
  32529. return nil
  32530. }
  32531. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32532. }
  32533. // ClearedFields returns all nullable fields that were cleared during this
  32534. // mutation.
  32535. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32536. var fields []string
  32537. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32538. fields = append(fields, usagestatisticmonth.FieldStatus)
  32539. }
  32540. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32541. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32542. }
  32543. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32544. fields = append(fields, usagestatisticmonth.FieldBotID)
  32545. }
  32546. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32547. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32548. }
  32549. return fields
  32550. }
  32551. // FieldCleared returns a boolean indicating if a field with the given name was
  32552. // cleared in this mutation.
  32553. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32554. _, ok := m.clearedFields[name]
  32555. return ok
  32556. }
  32557. // ClearField clears the value of the field with the given name. It returns an
  32558. // error if the field is not defined in the schema.
  32559. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32560. switch name {
  32561. case usagestatisticmonth.FieldStatus:
  32562. m.ClearStatus()
  32563. return nil
  32564. case usagestatisticmonth.FieldDeletedAt:
  32565. m.ClearDeletedAt()
  32566. return nil
  32567. case usagestatisticmonth.FieldBotID:
  32568. m.ClearBotID()
  32569. return nil
  32570. case usagestatisticmonth.FieldOrganizationID:
  32571. m.ClearOrganizationID()
  32572. return nil
  32573. }
  32574. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32575. }
  32576. // ResetField resets all changes in the mutation for the field with the given name.
  32577. // It returns an error if the field is not defined in the schema.
  32578. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32579. switch name {
  32580. case usagestatisticmonth.FieldCreatedAt:
  32581. m.ResetCreatedAt()
  32582. return nil
  32583. case usagestatisticmonth.FieldUpdatedAt:
  32584. m.ResetUpdatedAt()
  32585. return nil
  32586. case usagestatisticmonth.FieldStatus:
  32587. m.ResetStatus()
  32588. return nil
  32589. case usagestatisticmonth.FieldDeletedAt:
  32590. m.ResetDeletedAt()
  32591. return nil
  32592. case usagestatisticmonth.FieldAddtime:
  32593. m.ResetAddtime()
  32594. return nil
  32595. case usagestatisticmonth.FieldType:
  32596. m.ResetType()
  32597. return nil
  32598. case usagestatisticmonth.FieldBotID:
  32599. m.ResetBotID()
  32600. return nil
  32601. case usagestatisticmonth.FieldOrganizationID:
  32602. m.ResetOrganizationID()
  32603. return nil
  32604. case usagestatisticmonth.FieldAiResponse:
  32605. m.ResetAiResponse()
  32606. return nil
  32607. case usagestatisticmonth.FieldSopRun:
  32608. m.ResetSopRun()
  32609. return nil
  32610. case usagestatisticmonth.FieldTotalFriend:
  32611. m.ResetTotalFriend()
  32612. return nil
  32613. case usagestatisticmonth.FieldTotalGroup:
  32614. m.ResetTotalGroup()
  32615. return nil
  32616. case usagestatisticmonth.FieldAccountBalance:
  32617. m.ResetAccountBalance()
  32618. return nil
  32619. case usagestatisticmonth.FieldConsumeToken:
  32620. m.ResetConsumeToken()
  32621. return nil
  32622. case usagestatisticmonth.FieldActiveUser:
  32623. m.ResetActiveUser()
  32624. return nil
  32625. case usagestatisticmonth.FieldNewUser:
  32626. m.ResetNewUser()
  32627. return nil
  32628. case usagestatisticmonth.FieldLabelDist:
  32629. m.ResetLabelDist()
  32630. return nil
  32631. }
  32632. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32633. }
  32634. // AddedEdges returns all edge names that were set/added in this mutation.
  32635. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32636. edges := make([]string, 0, 0)
  32637. return edges
  32638. }
  32639. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32640. // name in this mutation.
  32641. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32642. return nil
  32643. }
  32644. // RemovedEdges returns all edge names that were removed in this mutation.
  32645. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32646. edges := make([]string, 0, 0)
  32647. return edges
  32648. }
  32649. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32650. // the given name in this mutation.
  32651. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32652. return nil
  32653. }
  32654. // ClearedEdges returns all edge names that were cleared in this mutation.
  32655. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32656. edges := make([]string, 0, 0)
  32657. return edges
  32658. }
  32659. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32660. // was cleared in this mutation.
  32661. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32662. return false
  32663. }
  32664. // ClearEdge clears the value of the edge with the given name. It returns an error
  32665. // if that edge is not defined in the schema.
  32666. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32667. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32668. }
  32669. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32670. // It returns an error if the edge is not defined in the schema.
  32671. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32672. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32673. }
  32674. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32675. type UsageTotalMutation struct {
  32676. config
  32677. op Op
  32678. typ string
  32679. id *uint64
  32680. created_at *time.Time
  32681. updated_at *time.Time
  32682. status *uint8
  32683. addstatus *int8
  32684. _type *int
  32685. add_type *int
  32686. bot_id *string
  32687. total_tokens *uint64
  32688. addtotal_tokens *int64
  32689. start_index *uint64
  32690. addstart_index *int64
  32691. end_index *uint64
  32692. addend_index *int64
  32693. organization_id *uint64
  32694. addorganization_id *int64
  32695. clearedFields map[string]struct{}
  32696. done bool
  32697. oldValue func(context.Context) (*UsageTotal, error)
  32698. predicates []predicate.UsageTotal
  32699. }
  32700. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32701. // usagetotalOption allows management of the mutation configuration using functional options.
  32702. type usagetotalOption func(*UsageTotalMutation)
  32703. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32704. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32705. m := &UsageTotalMutation{
  32706. config: c,
  32707. op: op,
  32708. typ: TypeUsageTotal,
  32709. clearedFields: make(map[string]struct{}),
  32710. }
  32711. for _, opt := range opts {
  32712. opt(m)
  32713. }
  32714. return m
  32715. }
  32716. // withUsageTotalID sets the ID field of the mutation.
  32717. func withUsageTotalID(id uint64) usagetotalOption {
  32718. return func(m *UsageTotalMutation) {
  32719. var (
  32720. err error
  32721. once sync.Once
  32722. value *UsageTotal
  32723. )
  32724. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32725. once.Do(func() {
  32726. if m.done {
  32727. err = errors.New("querying old values post mutation is not allowed")
  32728. } else {
  32729. value, err = m.Client().UsageTotal.Get(ctx, id)
  32730. }
  32731. })
  32732. return value, err
  32733. }
  32734. m.id = &id
  32735. }
  32736. }
  32737. // withUsageTotal sets the old UsageTotal of the mutation.
  32738. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32739. return func(m *UsageTotalMutation) {
  32740. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32741. return node, nil
  32742. }
  32743. m.id = &node.ID
  32744. }
  32745. }
  32746. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32747. // executed in a transaction (ent.Tx), a transactional client is returned.
  32748. func (m UsageTotalMutation) Client() *Client {
  32749. client := &Client{config: m.config}
  32750. client.init()
  32751. return client
  32752. }
  32753. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32754. // it returns an error otherwise.
  32755. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32756. if _, ok := m.driver.(*txDriver); !ok {
  32757. return nil, errors.New("ent: mutation is not running in a transaction")
  32758. }
  32759. tx := &Tx{config: m.config}
  32760. tx.init()
  32761. return tx, nil
  32762. }
  32763. // SetID sets the value of the id field. Note that this
  32764. // operation is only accepted on creation of UsageTotal entities.
  32765. func (m *UsageTotalMutation) SetID(id uint64) {
  32766. m.id = &id
  32767. }
  32768. // ID returns the ID value in the mutation. Note that the ID is only available
  32769. // if it was provided to the builder or after it was returned from the database.
  32770. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32771. if m.id == nil {
  32772. return
  32773. }
  32774. return *m.id, true
  32775. }
  32776. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32777. // That means, if the mutation is applied within a transaction with an isolation level such
  32778. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32779. // or updated by the mutation.
  32780. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32781. switch {
  32782. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32783. id, exists := m.ID()
  32784. if exists {
  32785. return []uint64{id}, nil
  32786. }
  32787. fallthrough
  32788. case m.op.Is(OpUpdate | OpDelete):
  32789. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32790. default:
  32791. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32792. }
  32793. }
  32794. // SetCreatedAt sets the "created_at" field.
  32795. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32796. m.created_at = &t
  32797. }
  32798. // CreatedAt returns the value of the "created_at" field in the mutation.
  32799. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32800. v := m.created_at
  32801. if v == nil {
  32802. return
  32803. }
  32804. return *v, true
  32805. }
  32806. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32807. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32809. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32810. if !m.op.Is(OpUpdateOne) {
  32811. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32812. }
  32813. if m.id == nil || m.oldValue == nil {
  32814. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32815. }
  32816. oldValue, err := m.oldValue(ctx)
  32817. if err != nil {
  32818. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32819. }
  32820. return oldValue.CreatedAt, nil
  32821. }
  32822. // ResetCreatedAt resets all changes to the "created_at" field.
  32823. func (m *UsageTotalMutation) ResetCreatedAt() {
  32824. m.created_at = nil
  32825. }
  32826. // SetUpdatedAt sets the "updated_at" field.
  32827. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32828. m.updated_at = &t
  32829. }
  32830. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32831. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32832. v := m.updated_at
  32833. if v == nil {
  32834. return
  32835. }
  32836. return *v, true
  32837. }
  32838. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32839. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32841. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32842. if !m.op.Is(OpUpdateOne) {
  32843. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32844. }
  32845. if m.id == nil || m.oldValue == nil {
  32846. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32847. }
  32848. oldValue, err := m.oldValue(ctx)
  32849. if err != nil {
  32850. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32851. }
  32852. return oldValue.UpdatedAt, nil
  32853. }
  32854. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32855. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32856. m.updated_at = nil
  32857. }
  32858. // SetStatus sets the "status" field.
  32859. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32860. m.status = &u
  32861. m.addstatus = nil
  32862. }
  32863. // Status returns the value of the "status" field in the mutation.
  32864. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32865. v := m.status
  32866. if v == nil {
  32867. return
  32868. }
  32869. return *v, true
  32870. }
  32871. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32872. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32874. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32875. if !m.op.Is(OpUpdateOne) {
  32876. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32877. }
  32878. if m.id == nil || m.oldValue == nil {
  32879. return v, errors.New("OldStatus requires an ID field in the mutation")
  32880. }
  32881. oldValue, err := m.oldValue(ctx)
  32882. if err != nil {
  32883. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32884. }
  32885. return oldValue.Status, nil
  32886. }
  32887. // AddStatus adds u to the "status" field.
  32888. func (m *UsageTotalMutation) AddStatus(u int8) {
  32889. if m.addstatus != nil {
  32890. *m.addstatus += u
  32891. } else {
  32892. m.addstatus = &u
  32893. }
  32894. }
  32895. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32896. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32897. v := m.addstatus
  32898. if v == nil {
  32899. return
  32900. }
  32901. return *v, true
  32902. }
  32903. // ClearStatus clears the value of the "status" field.
  32904. func (m *UsageTotalMutation) ClearStatus() {
  32905. m.status = nil
  32906. m.addstatus = nil
  32907. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32908. }
  32909. // StatusCleared returns if the "status" field was cleared in this mutation.
  32910. func (m *UsageTotalMutation) StatusCleared() bool {
  32911. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32912. return ok
  32913. }
  32914. // ResetStatus resets all changes to the "status" field.
  32915. func (m *UsageTotalMutation) ResetStatus() {
  32916. m.status = nil
  32917. m.addstatus = nil
  32918. delete(m.clearedFields, usagetotal.FieldStatus)
  32919. }
  32920. // SetType sets the "type" field.
  32921. func (m *UsageTotalMutation) SetType(i int) {
  32922. m._type = &i
  32923. m.add_type = nil
  32924. }
  32925. // GetType returns the value of the "type" field in the mutation.
  32926. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32927. v := m._type
  32928. if v == nil {
  32929. return
  32930. }
  32931. return *v, true
  32932. }
  32933. // OldType returns the old "type" field's value of the UsageTotal entity.
  32934. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32936. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  32937. if !m.op.Is(OpUpdateOne) {
  32938. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32939. }
  32940. if m.id == nil || m.oldValue == nil {
  32941. return v, errors.New("OldType requires an ID field in the mutation")
  32942. }
  32943. oldValue, err := m.oldValue(ctx)
  32944. if err != nil {
  32945. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32946. }
  32947. return oldValue.Type, nil
  32948. }
  32949. // AddType adds i to the "type" field.
  32950. func (m *UsageTotalMutation) AddType(i int) {
  32951. if m.add_type != nil {
  32952. *m.add_type += i
  32953. } else {
  32954. m.add_type = &i
  32955. }
  32956. }
  32957. // AddedType returns the value that was added to the "type" field in this mutation.
  32958. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  32959. v := m.add_type
  32960. if v == nil {
  32961. return
  32962. }
  32963. return *v, true
  32964. }
  32965. // ClearType clears the value of the "type" field.
  32966. func (m *UsageTotalMutation) ClearType() {
  32967. m._type = nil
  32968. m.add_type = nil
  32969. m.clearedFields[usagetotal.FieldType] = struct{}{}
  32970. }
  32971. // TypeCleared returns if the "type" field was cleared in this mutation.
  32972. func (m *UsageTotalMutation) TypeCleared() bool {
  32973. _, ok := m.clearedFields[usagetotal.FieldType]
  32974. return ok
  32975. }
  32976. // ResetType resets all changes to the "type" field.
  32977. func (m *UsageTotalMutation) ResetType() {
  32978. m._type = nil
  32979. m.add_type = nil
  32980. delete(m.clearedFields, usagetotal.FieldType)
  32981. }
  32982. // SetBotID sets the "bot_id" field.
  32983. func (m *UsageTotalMutation) SetBotID(s string) {
  32984. m.bot_id = &s
  32985. }
  32986. // BotID returns the value of the "bot_id" field in the mutation.
  32987. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  32988. v := m.bot_id
  32989. if v == nil {
  32990. return
  32991. }
  32992. return *v, true
  32993. }
  32994. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  32995. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32997. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  32998. if !m.op.Is(OpUpdateOne) {
  32999. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33000. }
  33001. if m.id == nil || m.oldValue == nil {
  33002. return v, errors.New("OldBotID requires an ID field in the mutation")
  33003. }
  33004. oldValue, err := m.oldValue(ctx)
  33005. if err != nil {
  33006. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33007. }
  33008. return oldValue.BotID, nil
  33009. }
  33010. // ResetBotID resets all changes to the "bot_id" field.
  33011. func (m *UsageTotalMutation) ResetBotID() {
  33012. m.bot_id = nil
  33013. }
  33014. // SetTotalTokens sets the "total_tokens" field.
  33015. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33016. m.total_tokens = &u
  33017. m.addtotal_tokens = nil
  33018. }
  33019. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33020. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33021. v := m.total_tokens
  33022. if v == nil {
  33023. return
  33024. }
  33025. return *v, true
  33026. }
  33027. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33028. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33030. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33031. if !m.op.Is(OpUpdateOne) {
  33032. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33033. }
  33034. if m.id == nil || m.oldValue == nil {
  33035. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33036. }
  33037. oldValue, err := m.oldValue(ctx)
  33038. if err != nil {
  33039. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33040. }
  33041. return oldValue.TotalTokens, nil
  33042. }
  33043. // AddTotalTokens adds u to the "total_tokens" field.
  33044. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33045. if m.addtotal_tokens != nil {
  33046. *m.addtotal_tokens += u
  33047. } else {
  33048. m.addtotal_tokens = &u
  33049. }
  33050. }
  33051. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33052. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33053. v := m.addtotal_tokens
  33054. if v == nil {
  33055. return
  33056. }
  33057. return *v, true
  33058. }
  33059. // ClearTotalTokens clears the value of the "total_tokens" field.
  33060. func (m *UsageTotalMutation) ClearTotalTokens() {
  33061. m.total_tokens = nil
  33062. m.addtotal_tokens = nil
  33063. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33064. }
  33065. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33066. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33067. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33068. return ok
  33069. }
  33070. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33071. func (m *UsageTotalMutation) ResetTotalTokens() {
  33072. m.total_tokens = nil
  33073. m.addtotal_tokens = nil
  33074. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33075. }
  33076. // SetStartIndex sets the "start_index" field.
  33077. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33078. m.start_index = &u
  33079. m.addstart_index = nil
  33080. }
  33081. // StartIndex returns the value of the "start_index" field in the mutation.
  33082. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33083. v := m.start_index
  33084. if v == nil {
  33085. return
  33086. }
  33087. return *v, true
  33088. }
  33089. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33090. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33092. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33093. if !m.op.Is(OpUpdateOne) {
  33094. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33095. }
  33096. if m.id == nil || m.oldValue == nil {
  33097. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33098. }
  33099. oldValue, err := m.oldValue(ctx)
  33100. if err != nil {
  33101. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33102. }
  33103. return oldValue.StartIndex, nil
  33104. }
  33105. // AddStartIndex adds u to the "start_index" field.
  33106. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33107. if m.addstart_index != nil {
  33108. *m.addstart_index += u
  33109. } else {
  33110. m.addstart_index = &u
  33111. }
  33112. }
  33113. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33114. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33115. v := m.addstart_index
  33116. if v == nil {
  33117. return
  33118. }
  33119. return *v, true
  33120. }
  33121. // ClearStartIndex clears the value of the "start_index" field.
  33122. func (m *UsageTotalMutation) ClearStartIndex() {
  33123. m.start_index = nil
  33124. m.addstart_index = nil
  33125. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33126. }
  33127. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33128. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33129. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33130. return ok
  33131. }
  33132. // ResetStartIndex resets all changes to the "start_index" field.
  33133. func (m *UsageTotalMutation) ResetStartIndex() {
  33134. m.start_index = nil
  33135. m.addstart_index = nil
  33136. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33137. }
  33138. // SetEndIndex sets the "end_index" field.
  33139. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33140. m.end_index = &u
  33141. m.addend_index = nil
  33142. }
  33143. // EndIndex returns the value of the "end_index" field in the mutation.
  33144. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33145. v := m.end_index
  33146. if v == nil {
  33147. return
  33148. }
  33149. return *v, true
  33150. }
  33151. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33152. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33154. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33155. if !m.op.Is(OpUpdateOne) {
  33156. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33157. }
  33158. if m.id == nil || m.oldValue == nil {
  33159. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33160. }
  33161. oldValue, err := m.oldValue(ctx)
  33162. if err != nil {
  33163. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33164. }
  33165. return oldValue.EndIndex, nil
  33166. }
  33167. // AddEndIndex adds u to the "end_index" field.
  33168. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33169. if m.addend_index != nil {
  33170. *m.addend_index += u
  33171. } else {
  33172. m.addend_index = &u
  33173. }
  33174. }
  33175. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33176. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33177. v := m.addend_index
  33178. if v == nil {
  33179. return
  33180. }
  33181. return *v, true
  33182. }
  33183. // ClearEndIndex clears the value of the "end_index" field.
  33184. func (m *UsageTotalMutation) ClearEndIndex() {
  33185. m.end_index = nil
  33186. m.addend_index = nil
  33187. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33188. }
  33189. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33190. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33191. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33192. return ok
  33193. }
  33194. // ResetEndIndex resets all changes to the "end_index" field.
  33195. func (m *UsageTotalMutation) ResetEndIndex() {
  33196. m.end_index = nil
  33197. m.addend_index = nil
  33198. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33199. }
  33200. // SetOrganizationID sets the "organization_id" field.
  33201. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33202. m.organization_id = &u
  33203. m.addorganization_id = nil
  33204. }
  33205. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33206. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33207. v := m.organization_id
  33208. if v == nil {
  33209. return
  33210. }
  33211. return *v, true
  33212. }
  33213. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33214. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33216. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33217. if !m.op.Is(OpUpdateOne) {
  33218. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33219. }
  33220. if m.id == nil || m.oldValue == nil {
  33221. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33222. }
  33223. oldValue, err := m.oldValue(ctx)
  33224. if err != nil {
  33225. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33226. }
  33227. return oldValue.OrganizationID, nil
  33228. }
  33229. // AddOrganizationID adds u to the "organization_id" field.
  33230. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33231. if m.addorganization_id != nil {
  33232. *m.addorganization_id += u
  33233. } else {
  33234. m.addorganization_id = &u
  33235. }
  33236. }
  33237. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33238. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33239. v := m.addorganization_id
  33240. if v == nil {
  33241. return
  33242. }
  33243. return *v, true
  33244. }
  33245. // ClearOrganizationID clears the value of the "organization_id" field.
  33246. func (m *UsageTotalMutation) ClearOrganizationID() {
  33247. m.organization_id = nil
  33248. m.addorganization_id = nil
  33249. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33250. }
  33251. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33252. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33253. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33254. return ok
  33255. }
  33256. // ResetOrganizationID resets all changes to the "organization_id" field.
  33257. func (m *UsageTotalMutation) ResetOrganizationID() {
  33258. m.organization_id = nil
  33259. m.addorganization_id = nil
  33260. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33261. }
  33262. // Where appends a list predicates to the UsageTotalMutation builder.
  33263. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33264. m.predicates = append(m.predicates, ps...)
  33265. }
  33266. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33267. // users can use type-assertion to append predicates that do not depend on any generated package.
  33268. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33269. p := make([]predicate.UsageTotal, len(ps))
  33270. for i := range ps {
  33271. p[i] = ps[i]
  33272. }
  33273. m.Where(p...)
  33274. }
  33275. // Op returns the operation name.
  33276. func (m *UsageTotalMutation) Op() Op {
  33277. return m.op
  33278. }
  33279. // SetOp allows setting the mutation operation.
  33280. func (m *UsageTotalMutation) SetOp(op Op) {
  33281. m.op = op
  33282. }
  33283. // Type returns the node type of this mutation (UsageTotal).
  33284. func (m *UsageTotalMutation) Type() string {
  33285. return m.typ
  33286. }
  33287. // Fields returns all fields that were changed during this mutation. Note that in
  33288. // order to get all numeric fields that were incremented/decremented, call
  33289. // AddedFields().
  33290. func (m *UsageTotalMutation) Fields() []string {
  33291. fields := make([]string, 0, 9)
  33292. if m.created_at != nil {
  33293. fields = append(fields, usagetotal.FieldCreatedAt)
  33294. }
  33295. if m.updated_at != nil {
  33296. fields = append(fields, usagetotal.FieldUpdatedAt)
  33297. }
  33298. if m.status != nil {
  33299. fields = append(fields, usagetotal.FieldStatus)
  33300. }
  33301. if m._type != nil {
  33302. fields = append(fields, usagetotal.FieldType)
  33303. }
  33304. if m.bot_id != nil {
  33305. fields = append(fields, usagetotal.FieldBotID)
  33306. }
  33307. if m.total_tokens != nil {
  33308. fields = append(fields, usagetotal.FieldTotalTokens)
  33309. }
  33310. if m.start_index != nil {
  33311. fields = append(fields, usagetotal.FieldStartIndex)
  33312. }
  33313. if m.end_index != nil {
  33314. fields = append(fields, usagetotal.FieldEndIndex)
  33315. }
  33316. if m.organization_id != nil {
  33317. fields = append(fields, usagetotal.FieldOrganizationID)
  33318. }
  33319. return fields
  33320. }
  33321. // Field returns the value of a field with the given name. The second boolean
  33322. // return value indicates that this field was not set, or was not defined in the
  33323. // schema.
  33324. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33325. switch name {
  33326. case usagetotal.FieldCreatedAt:
  33327. return m.CreatedAt()
  33328. case usagetotal.FieldUpdatedAt:
  33329. return m.UpdatedAt()
  33330. case usagetotal.FieldStatus:
  33331. return m.Status()
  33332. case usagetotal.FieldType:
  33333. return m.GetType()
  33334. case usagetotal.FieldBotID:
  33335. return m.BotID()
  33336. case usagetotal.FieldTotalTokens:
  33337. return m.TotalTokens()
  33338. case usagetotal.FieldStartIndex:
  33339. return m.StartIndex()
  33340. case usagetotal.FieldEndIndex:
  33341. return m.EndIndex()
  33342. case usagetotal.FieldOrganizationID:
  33343. return m.OrganizationID()
  33344. }
  33345. return nil, false
  33346. }
  33347. // OldField returns the old value of the field from the database. An error is
  33348. // returned if the mutation operation is not UpdateOne, or the query to the
  33349. // database failed.
  33350. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33351. switch name {
  33352. case usagetotal.FieldCreatedAt:
  33353. return m.OldCreatedAt(ctx)
  33354. case usagetotal.FieldUpdatedAt:
  33355. return m.OldUpdatedAt(ctx)
  33356. case usagetotal.FieldStatus:
  33357. return m.OldStatus(ctx)
  33358. case usagetotal.FieldType:
  33359. return m.OldType(ctx)
  33360. case usagetotal.FieldBotID:
  33361. return m.OldBotID(ctx)
  33362. case usagetotal.FieldTotalTokens:
  33363. return m.OldTotalTokens(ctx)
  33364. case usagetotal.FieldStartIndex:
  33365. return m.OldStartIndex(ctx)
  33366. case usagetotal.FieldEndIndex:
  33367. return m.OldEndIndex(ctx)
  33368. case usagetotal.FieldOrganizationID:
  33369. return m.OldOrganizationID(ctx)
  33370. }
  33371. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33372. }
  33373. // SetField sets the value of a field with the given name. It returns an error if
  33374. // the field is not defined in the schema, or if the type mismatched the field
  33375. // type.
  33376. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33377. switch name {
  33378. case usagetotal.FieldCreatedAt:
  33379. v, ok := value.(time.Time)
  33380. if !ok {
  33381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33382. }
  33383. m.SetCreatedAt(v)
  33384. return nil
  33385. case usagetotal.FieldUpdatedAt:
  33386. v, ok := value.(time.Time)
  33387. if !ok {
  33388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33389. }
  33390. m.SetUpdatedAt(v)
  33391. return nil
  33392. case usagetotal.FieldStatus:
  33393. v, ok := value.(uint8)
  33394. if !ok {
  33395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33396. }
  33397. m.SetStatus(v)
  33398. return nil
  33399. case usagetotal.FieldType:
  33400. v, ok := value.(int)
  33401. if !ok {
  33402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33403. }
  33404. m.SetType(v)
  33405. return nil
  33406. case usagetotal.FieldBotID:
  33407. v, ok := value.(string)
  33408. if !ok {
  33409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33410. }
  33411. m.SetBotID(v)
  33412. return nil
  33413. case usagetotal.FieldTotalTokens:
  33414. v, ok := value.(uint64)
  33415. if !ok {
  33416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33417. }
  33418. m.SetTotalTokens(v)
  33419. return nil
  33420. case usagetotal.FieldStartIndex:
  33421. v, ok := value.(uint64)
  33422. if !ok {
  33423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33424. }
  33425. m.SetStartIndex(v)
  33426. return nil
  33427. case usagetotal.FieldEndIndex:
  33428. v, ok := value.(uint64)
  33429. if !ok {
  33430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33431. }
  33432. m.SetEndIndex(v)
  33433. return nil
  33434. case usagetotal.FieldOrganizationID:
  33435. v, ok := value.(uint64)
  33436. if !ok {
  33437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33438. }
  33439. m.SetOrganizationID(v)
  33440. return nil
  33441. }
  33442. return fmt.Errorf("unknown UsageTotal field %s", name)
  33443. }
  33444. // AddedFields returns all numeric fields that were incremented/decremented during
  33445. // this mutation.
  33446. func (m *UsageTotalMutation) AddedFields() []string {
  33447. var fields []string
  33448. if m.addstatus != nil {
  33449. fields = append(fields, usagetotal.FieldStatus)
  33450. }
  33451. if m.add_type != nil {
  33452. fields = append(fields, usagetotal.FieldType)
  33453. }
  33454. if m.addtotal_tokens != nil {
  33455. fields = append(fields, usagetotal.FieldTotalTokens)
  33456. }
  33457. if m.addstart_index != nil {
  33458. fields = append(fields, usagetotal.FieldStartIndex)
  33459. }
  33460. if m.addend_index != nil {
  33461. fields = append(fields, usagetotal.FieldEndIndex)
  33462. }
  33463. if m.addorganization_id != nil {
  33464. fields = append(fields, usagetotal.FieldOrganizationID)
  33465. }
  33466. return fields
  33467. }
  33468. // AddedField returns the numeric value that was incremented/decremented on a field
  33469. // with the given name. The second boolean return value indicates that this field
  33470. // was not set, or was not defined in the schema.
  33471. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33472. switch name {
  33473. case usagetotal.FieldStatus:
  33474. return m.AddedStatus()
  33475. case usagetotal.FieldType:
  33476. return m.AddedType()
  33477. case usagetotal.FieldTotalTokens:
  33478. return m.AddedTotalTokens()
  33479. case usagetotal.FieldStartIndex:
  33480. return m.AddedStartIndex()
  33481. case usagetotal.FieldEndIndex:
  33482. return m.AddedEndIndex()
  33483. case usagetotal.FieldOrganizationID:
  33484. return m.AddedOrganizationID()
  33485. }
  33486. return nil, false
  33487. }
  33488. // AddField adds the value to the field with the given name. It returns an error if
  33489. // the field is not defined in the schema, or if the type mismatched the field
  33490. // type.
  33491. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33492. switch name {
  33493. case usagetotal.FieldStatus:
  33494. v, ok := value.(int8)
  33495. if !ok {
  33496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33497. }
  33498. m.AddStatus(v)
  33499. return nil
  33500. case usagetotal.FieldType:
  33501. v, ok := value.(int)
  33502. if !ok {
  33503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33504. }
  33505. m.AddType(v)
  33506. return nil
  33507. case usagetotal.FieldTotalTokens:
  33508. v, ok := value.(int64)
  33509. if !ok {
  33510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33511. }
  33512. m.AddTotalTokens(v)
  33513. return nil
  33514. case usagetotal.FieldStartIndex:
  33515. v, ok := value.(int64)
  33516. if !ok {
  33517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33518. }
  33519. m.AddStartIndex(v)
  33520. return nil
  33521. case usagetotal.FieldEndIndex:
  33522. v, ok := value.(int64)
  33523. if !ok {
  33524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33525. }
  33526. m.AddEndIndex(v)
  33527. return nil
  33528. case usagetotal.FieldOrganizationID:
  33529. v, ok := value.(int64)
  33530. if !ok {
  33531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33532. }
  33533. m.AddOrganizationID(v)
  33534. return nil
  33535. }
  33536. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33537. }
  33538. // ClearedFields returns all nullable fields that were cleared during this
  33539. // mutation.
  33540. func (m *UsageTotalMutation) ClearedFields() []string {
  33541. var fields []string
  33542. if m.FieldCleared(usagetotal.FieldStatus) {
  33543. fields = append(fields, usagetotal.FieldStatus)
  33544. }
  33545. if m.FieldCleared(usagetotal.FieldType) {
  33546. fields = append(fields, usagetotal.FieldType)
  33547. }
  33548. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33549. fields = append(fields, usagetotal.FieldTotalTokens)
  33550. }
  33551. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33552. fields = append(fields, usagetotal.FieldStartIndex)
  33553. }
  33554. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33555. fields = append(fields, usagetotal.FieldEndIndex)
  33556. }
  33557. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33558. fields = append(fields, usagetotal.FieldOrganizationID)
  33559. }
  33560. return fields
  33561. }
  33562. // FieldCleared returns a boolean indicating if a field with the given name was
  33563. // cleared in this mutation.
  33564. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33565. _, ok := m.clearedFields[name]
  33566. return ok
  33567. }
  33568. // ClearField clears the value of the field with the given name. It returns an
  33569. // error if the field is not defined in the schema.
  33570. func (m *UsageTotalMutation) ClearField(name string) error {
  33571. switch name {
  33572. case usagetotal.FieldStatus:
  33573. m.ClearStatus()
  33574. return nil
  33575. case usagetotal.FieldType:
  33576. m.ClearType()
  33577. return nil
  33578. case usagetotal.FieldTotalTokens:
  33579. m.ClearTotalTokens()
  33580. return nil
  33581. case usagetotal.FieldStartIndex:
  33582. m.ClearStartIndex()
  33583. return nil
  33584. case usagetotal.FieldEndIndex:
  33585. m.ClearEndIndex()
  33586. return nil
  33587. case usagetotal.FieldOrganizationID:
  33588. m.ClearOrganizationID()
  33589. return nil
  33590. }
  33591. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33592. }
  33593. // ResetField resets all changes in the mutation for the field with the given name.
  33594. // It returns an error if the field is not defined in the schema.
  33595. func (m *UsageTotalMutation) ResetField(name string) error {
  33596. switch name {
  33597. case usagetotal.FieldCreatedAt:
  33598. m.ResetCreatedAt()
  33599. return nil
  33600. case usagetotal.FieldUpdatedAt:
  33601. m.ResetUpdatedAt()
  33602. return nil
  33603. case usagetotal.FieldStatus:
  33604. m.ResetStatus()
  33605. return nil
  33606. case usagetotal.FieldType:
  33607. m.ResetType()
  33608. return nil
  33609. case usagetotal.FieldBotID:
  33610. m.ResetBotID()
  33611. return nil
  33612. case usagetotal.FieldTotalTokens:
  33613. m.ResetTotalTokens()
  33614. return nil
  33615. case usagetotal.FieldStartIndex:
  33616. m.ResetStartIndex()
  33617. return nil
  33618. case usagetotal.FieldEndIndex:
  33619. m.ResetEndIndex()
  33620. return nil
  33621. case usagetotal.FieldOrganizationID:
  33622. m.ResetOrganizationID()
  33623. return nil
  33624. }
  33625. return fmt.Errorf("unknown UsageTotal field %s", name)
  33626. }
  33627. // AddedEdges returns all edge names that were set/added in this mutation.
  33628. func (m *UsageTotalMutation) AddedEdges() []string {
  33629. edges := make([]string, 0, 0)
  33630. return edges
  33631. }
  33632. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33633. // name in this mutation.
  33634. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33635. return nil
  33636. }
  33637. // RemovedEdges returns all edge names that were removed in this mutation.
  33638. func (m *UsageTotalMutation) RemovedEdges() []string {
  33639. edges := make([]string, 0, 0)
  33640. return edges
  33641. }
  33642. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33643. // the given name in this mutation.
  33644. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33645. return nil
  33646. }
  33647. // ClearedEdges returns all edge names that were cleared in this mutation.
  33648. func (m *UsageTotalMutation) ClearedEdges() []string {
  33649. edges := make([]string, 0, 0)
  33650. return edges
  33651. }
  33652. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33653. // was cleared in this mutation.
  33654. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33655. return false
  33656. }
  33657. // ClearEdge clears the value of the edge with the given name. It returns an error
  33658. // if that edge is not defined in the schema.
  33659. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33660. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33661. }
  33662. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33663. // It returns an error if the edge is not defined in the schema.
  33664. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33665. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33666. }
  33667. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  33668. type WorkExperienceMutation struct {
  33669. config
  33670. op Op
  33671. typ string
  33672. id *uint64
  33673. created_at *time.Time
  33674. updated_at *time.Time
  33675. deleted_at *time.Time
  33676. start_date *time.Time
  33677. end_date *time.Time
  33678. company *string
  33679. experience *string
  33680. organization_id *uint64
  33681. addorganization_id *int64
  33682. clearedFields map[string]struct{}
  33683. employee *uint64
  33684. clearedemployee bool
  33685. done bool
  33686. oldValue func(context.Context) (*WorkExperience, error)
  33687. predicates []predicate.WorkExperience
  33688. }
  33689. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  33690. // workexperienceOption allows management of the mutation configuration using functional options.
  33691. type workexperienceOption func(*WorkExperienceMutation)
  33692. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  33693. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  33694. m := &WorkExperienceMutation{
  33695. config: c,
  33696. op: op,
  33697. typ: TypeWorkExperience,
  33698. clearedFields: make(map[string]struct{}),
  33699. }
  33700. for _, opt := range opts {
  33701. opt(m)
  33702. }
  33703. return m
  33704. }
  33705. // withWorkExperienceID sets the ID field of the mutation.
  33706. func withWorkExperienceID(id uint64) workexperienceOption {
  33707. return func(m *WorkExperienceMutation) {
  33708. var (
  33709. err error
  33710. once sync.Once
  33711. value *WorkExperience
  33712. )
  33713. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  33714. once.Do(func() {
  33715. if m.done {
  33716. err = errors.New("querying old values post mutation is not allowed")
  33717. } else {
  33718. value, err = m.Client().WorkExperience.Get(ctx, id)
  33719. }
  33720. })
  33721. return value, err
  33722. }
  33723. m.id = &id
  33724. }
  33725. }
  33726. // withWorkExperience sets the old WorkExperience of the mutation.
  33727. func withWorkExperience(node *WorkExperience) workexperienceOption {
  33728. return func(m *WorkExperienceMutation) {
  33729. m.oldValue = func(context.Context) (*WorkExperience, error) {
  33730. return node, nil
  33731. }
  33732. m.id = &node.ID
  33733. }
  33734. }
  33735. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33736. // executed in a transaction (ent.Tx), a transactional client is returned.
  33737. func (m WorkExperienceMutation) Client() *Client {
  33738. client := &Client{config: m.config}
  33739. client.init()
  33740. return client
  33741. }
  33742. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33743. // it returns an error otherwise.
  33744. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  33745. if _, ok := m.driver.(*txDriver); !ok {
  33746. return nil, errors.New("ent: mutation is not running in a transaction")
  33747. }
  33748. tx := &Tx{config: m.config}
  33749. tx.init()
  33750. return tx, nil
  33751. }
  33752. // SetID sets the value of the id field. Note that this
  33753. // operation is only accepted on creation of WorkExperience entities.
  33754. func (m *WorkExperienceMutation) SetID(id uint64) {
  33755. m.id = &id
  33756. }
  33757. // ID returns the ID value in the mutation. Note that the ID is only available
  33758. // if it was provided to the builder or after it was returned from the database.
  33759. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  33760. if m.id == nil {
  33761. return
  33762. }
  33763. return *m.id, true
  33764. }
  33765. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33766. // That means, if the mutation is applied within a transaction with an isolation level such
  33767. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33768. // or updated by the mutation.
  33769. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  33770. switch {
  33771. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33772. id, exists := m.ID()
  33773. if exists {
  33774. return []uint64{id}, nil
  33775. }
  33776. fallthrough
  33777. case m.op.Is(OpUpdate | OpDelete):
  33778. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  33779. default:
  33780. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33781. }
  33782. }
  33783. // SetCreatedAt sets the "created_at" field.
  33784. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  33785. m.created_at = &t
  33786. }
  33787. // CreatedAt returns the value of the "created_at" field in the mutation.
  33788. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  33789. v := m.created_at
  33790. if v == nil {
  33791. return
  33792. }
  33793. return *v, true
  33794. }
  33795. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  33796. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33798. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33799. if !m.op.Is(OpUpdateOne) {
  33800. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33801. }
  33802. if m.id == nil || m.oldValue == nil {
  33803. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33804. }
  33805. oldValue, err := m.oldValue(ctx)
  33806. if err != nil {
  33807. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33808. }
  33809. return oldValue.CreatedAt, nil
  33810. }
  33811. // ResetCreatedAt resets all changes to the "created_at" field.
  33812. func (m *WorkExperienceMutation) ResetCreatedAt() {
  33813. m.created_at = nil
  33814. }
  33815. // SetUpdatedAt sets the "updated_at" field.
  33816. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  33817. m.updated_at = &t
  33818. }
  33819. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33820. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  33821. v := m.updated_at
  33822. if v == nil {
  33823. return
  33824. }
  33825. return *v, true
  33826. }
  33827. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  33828. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33830. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33831. if !m.op.Is(OpUpdateOne) {
  33832. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33833. }
  33834. if m.id == nil || m.oldValue == nil {
  33835. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33836. }
  33837. oldValue, err := m.oldValue(ctx)
  33838. if err != nil {
  33839. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33840. }
  33841. return oldValue.UpdatedAt, nil
  33842. }
  33843. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33844. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  33845. m.updated_at = nil
  33846. }
  33847. // SetDeletedAt sets the "deleted_at" field.
  33848. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  33849. m.deleted_at = &t
  33850. }
  33851. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33852. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  33853. v := m.deleted_at
  33854. if v == nil {
  33855. return
  33856. }
  33857. return *v, true
  33858. }
  33859. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  33860. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33862. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33863. if !m.op.Is(OpUpdateOne) {
  33864. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33865. }
  33866. if m.id == nil || m.oldValue == nil {
  33867. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33868. }
  33869. oldValue, err := m.oldValue(ctx)
  33870. if err != nil {
  33871. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33872. }
  33873. return oldValue.DeletedAt, nil
  33874. }
  33875. // ClearDeletedAt clears the value of the "deleted_at" field.
  33876. func (m *WorkExperienceMutation) ClearDeletedAt() {
  33877. m.deleted_at = nil
  33878. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  33879. }
  33880. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33881. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  33882. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  33883. return ok
  33884. }
  33885. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33886. func (m *WorkExperienceMutation) ResetDeletedAt() {
  33887. m.deleted_at = nil
  33888. delete(m.clearedFields, workexperience.FieldDeletedAt)
  33889. }
  33890. // SetEmployeeID sets the "employee_id" field.
  33891. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  33892. m.employee = &u
  33893. }
  33894. // EmployeeID returns the value of the "employee_id" field in the mutation.
  33895. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  33896. v := m.employee
  33897. if v == nil {
  33898. return
  33899. }
  33900. return *v, true
  33901. }
  33902. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  33903. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33905. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  33906. if !m.op.Is(OpUpdateOne) {
  33907. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  33908. }
  33909. if m.id == nil || m.oldValue == nil {
  33910. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  33911. }
  33912. oldValue, err := m.oldValue(ctx)
  33913. if err != nil {
  33914. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  33915. }
  33916. return oldValue.EmployeeID, nil
  33917. }
  33918. // ResetEmployeeID resets all changes to the "employee_id" field.
  33919. func (m *WorkExperienceMutation) ResetEmployeeID() {
  33920. m.employee = nil
  33921. }
  33922. // SetStartDate sets the "start_date" field.
  33923. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  33924. m.start_date = &t
  33925. }
  33926. // StartDate returns the value of the "start_date" field in the mutation.
  33927. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  33928. v := m.start_date
  33929. if v == nil {
  33930. return
  33931. }
  33932. return *v, true
  33933. }
  33934. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  33935. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33937. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  33938. if !m.op.Is(OpUpdateOne) {
  33939. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  33940. }
  33941. if m.id == nil || m.oldValue == nil {
  33942. return v, errors.New("OldStartDate requires an ID field in the mutation")
  33943. }
  33944. oldValue, err := m.oldValue(ctx)
  33945. if err != nil {
  33946. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  33947. }
  33948. return oldValue.StartDate, nil
  33949. }
  33950. // ResetStartDate resets all changes to the "start_date" field.
  33951. func (m *WorkExperienceMutation) ResetStartDate() {
  33952. m.start_date = nil
  33953. }
  33954. // SetEndDate sets the "end_date" field.
  33955. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  33956. m.end_date = &t
  33957. }
  33958. // EndDate returns the value of the "end_date" field in the mutation.
  33959. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  33960. v := m.end_date
  33961. if v == nil {
  33962. return
  33963. }
  33964. return *v, true
  33965. }
  33966. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  33967. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33969. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  33970. if !m.op.Is(OpUpdateOne) {
  33971. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  33972. }
  33973. if m.id == nil || m.oldValue == nil {
  33974. return v, errors.New("OldEndDate requires an ID field in the mutation")
  33975. }
  33976. oldValue, err := m.oldValue(ctx)
  33977. if err != nil {
  33978. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  33979. }
  33980. return oldValue.EndDate, nil
  33981. }
  33982. // ResetEndDate resets all changes to the "end_date" field.
  33983. func (m *WorkExperienceMutation) ResetEndDate() {
  33984. m.end_date = nil
  33985. }
  33986. // SetCompany sets the "company" field.
  33987. func (m *WorkExperienceMutation) SetCompany(s string) {
  33988. m.company = &s
  33989. }
  33990. // Company returns the value of the "company" field in the mutation.
  33991. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  33992. v := m.company
  33993. if v == nil {
  33994. return
  33995. }
  33996. return *v, true
  33997. }
  33998. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  33999. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  34000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34001. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  34002. if !m.op.Is(OpUpdateOne) {
  34003. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  34004. }
  34005. if m.id == nil || m.oldValue == nil {
  34006. return v, errors.New("OldCompany requires an ID field in the mutation")
  34007. }
  34008. oldValue, err := m.oldValue(ctx)
  34009. if err != nil {
  34010. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  34011. }
  34012. return oldValue.Company, nil
  34013. }
  34014. // ResetCompany resets all changes to the "company" field.
  34015. func (m *WorkExperienceMutation) ResetCompany() {
  34016. m.company = nil
  34017. }
  34018. // SetExperience sets the "experience" field.
  34019. func (m *WorkExperienceMutation) SetExperience(s string) {
  34020. m.experience = &s
  34021. }
  34022. // Experience returns the value of the "experience" field in the mutation.
  34023. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  34024. v := m.experience
  34025. if v == nil {
  34026. return
  34027. }
  34028. return *v, true
  34029. }
  34030. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  34031. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  34032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34033. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  34034. if !m.op.Is(OpUpdateOne) {
  34035. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  34036. }
  34037. if m.id == nil || m.oldValue == nil {
  34038. return v, errors.New("OldExperience requires an ID field in the mutation")
  34039. }
  34040. oldValue, err := m.oldValue(ctx)
  34041. if err != nil {
  34042. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  34043. }
  34044. return oldValue.Experience, nil
  34045. }
  34046. // ResetExperience resets all changes to the "experience" field.
  34047. func (m *WorkExperienceMutation) ResetExperience() {
  34048. m.experience = nil
  34049. }
  34050. // SetOrganizationID sets the "organization_id" field.
  34051. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  34052. m.organization_id = &u
  34053. m.addorganization_id = nil
  34054. }
  34055. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34056. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  34057. v := m.organization_id
  34058. if v == nil {
  34059. return
  34060. }
  34061. return *v, true
  34062. }
  34063. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  34064. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  34065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34066. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34067. if !m.op.Is(OpUpdateOne) {
  34068. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34069. }
  34070. if m.id == nil || m.oldValue == nil {
  34071. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34072. }
  34073. oldValue, err := m.oldValue(ctx)
  34074. if err != nil {
  34075. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34076. }
  34077. return oldValue.OrganizationID, nil
  34078. }
  34079. // AddOrganizationID adds u to the "organization_id" field.
  34080. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  34081. if m.addorganization_id != nil {
  34082. *m.addorganization_id += u
  34083. } else {
  34084. m.addorganization_id = &u
  34085. }
  34086. }
  34087. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34088. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  34089. v := m.addorganization_id
  34090. if v == nil {
  34091. return
  34092. }
  34093. return *v, true
  34094. }
  34095. // ResetOrganizationID resets all changes to the "organization_id" field.
  34096. func (m *WorkExperienceMutation) ResetOrganizationID() {
  34097. m.organization_id = nil
  34098. m.addorganization_id = nil
  34099. }
  34100. // ClearEmployee clears the "employee" edge to the Employee entity.
  34101. func (m *WorkExperienceMutation) ClearEmployee() {
  34102. m.clearedemployee = true
  34103. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  34104. }
  34105. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  34106. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  34107. return m.clearedemployee
  34108. }
  34109. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  34110. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34111. // EmployeeID instead. It exists only for internal usage by the builders.
  34112. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  34113. if id := m.employee; id != nil {
  34114. ids = append(ids, *id)
  34115. }
  34116. return
  34117. }
  34118. // ResetEmployee resets all changes to the "employee" edge.
  34119. func (m *WorkExperienceMutation) ResetEmployee() {
  34120. m.employee = nil
  34121. m.clearedemployee = false
  34122. }
  34123. // Where appends a list predicates to the WorkExperienceMutation builder.
  34124. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  34125. m.predicates = append(m.predicates, ps...)
  34126. }
  34127. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  34128. // users can use type-assertion to append predicates that do not depend on any generated package.
  34129. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  34130. p := make([]predicate.WorkExperience, len(ps))
  34131. for i := range ps {
  34132. p[i] = ps[i]
  34133. }
  34134. m.Where(p...)
  34135. }
  34136. // Op returns the operation name.
  34137. func (m *WorkExperienceMutation) Op() Op {
  34138. return m.op
  34139. }
  34140. // SetOp allows setting the mutation operation.
  34141. func (m *WorkExperienceMutation) SetOp(op Op) {
  34142. m.op = op
  34143. }
  34144. // Type returns the node type of this mutation (WorkExperience).
  34145. func (m *WorkExperienceMutation) Type() string {
  34146. return m.typ
  34147. }
  34148. // Fields returns all fields that were changed during this mutation. Note that in
  34149. // order to get all numeric fields that were incremented/decremented, call
  34150. // AddedFields().
  34151. func (m *WorkExperienceMutation) Fields() []string {
  34152. fields := make([]string, 0, 9)
  34153. if m.created_at != nil {
  34154. fields = append(fields, workexperience.FieldCreatedAt)
  34155. }
  34156. if m.updated_at != nil {
  34157. fields = append(fields, workexperience.FieldUpdatedAt)
  34158. }
  34159. if m.deleted_at != nil {
  34160. fields = append(fields, workexperience.FieldDeletedAt)
  34161. }
  34162. if m.employee != nil {
  34163. fields = append(fields, workexperience.FieldEmployeeID)
  34164. }
  34165. if m.start_date != nil {
  34166. fields = append(fields, workexperience.FieldStartDate)
  34167. }
  34168. if m.end_date != nil {
  34169. fields = append(fields, workexperience.FieldEndDate)
  34170. }
  34171. if m.company != nil {
  34172. fields = append(fields, workexperience.FieldCompany)
  34173. }
  34174. if m.experience != nil {
  34175. fields = append(fields, workexperience.FieldExperience)
  34176. }
  34177. if m.organization_id != nil {
  34178. fields = append(fields, workexperience.FieldOrganizationID)
  34179. }
  34180. return fields
  34181. }
  34182. // Field returns the value of a field with the given name. The second boolean
  34183. // return value indicates that this field was not set, or was not defined in the
  34184. // schema.
  34185. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  34186. switch name {
  34187. case workexperience.FieldCreatedAt:
  34188. return m.CreatedAt()
  34189. case workexperience.FieldUpdatedAt:
  34190. return m.UpdatedAt()
  34191. case workexperience.FieldDeletedAt:
  34192. return m.DeletedAt()
  34193. case workexperience.FieldEmployeeID:
  34194. return m.EmployeeID()
  34195. case workexperience.FieldStartDate:
  34196. return m.StartDate()
  34197. case workexperience.FieldEndDate:
  34198. return m.EndDate()
  34199. case workexperience.FieldCompany:
  34200. return m.Company()
  34201. case workexperience.FieldExperience:
  34202. return m.Experience()
  34203. case workexperience.FieldOrganizationID:
  34204. return m.OrganizationID()
  34205. }
  34206. return nil, false
  34207. }
  34208. // OldField returns the old value of the field from the database. An error is
  34209. // returned if the mutation operation is not UpdateOne, or the query to the
  34210. // database failed.
  34211. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34212. switch name {
  34213. case workexperience.FieldCreatedAt:
  34214. return m.OldCreatedAt(ctx)
  34215. case workexperience.FieldUpdatedAt:
  34216. return m.OldUpdatedAt(ctx)
  34217. case workexperience.FieldDeletedAt:
  34218. return m.OldDeletedAt(ctx)
  34219. case workexperience.FieldEmployeeID:
  34220. return m.OldEmployeeID(ctx)
  34221. case workexperience.FieldStartDate:
  34222. return m.OldStartDate(ctx)
  34223. case workexperience.FieldEndDate:
  34224. return m.OldEndDate(ctx)
  34225. case workexperience.FieldCompany:
  34226. return m.OldCompany(ctx)
  34227. case workexperience.FieldExperience:
  34228. return m.OldExperience(ctx)
  34229. case workexperience.FieldOrganizationID:
  34230. return m.OldOrganizationID(ctx)
  34231. }
  34232. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  34233. }
  34234. // SetField sets the value of a field with the given name. It returns an error if
  34235. // the field is not defined in the schema, or if the type mismatched the field
  34236. // type.
  34237. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  34238. switch name {
  34239. case workexperience.FieldCreatedAt:
  34240. v, ok := value.(time.Time)
  34241. if !ok {
  34242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34243. }
  34244. m.SetCreatedAt(v)
  34245. return nil
  34246. case workexperience.FieldUpdatedAt:
  34247. v, ok := value.(time.Time)
  34248. if !ok {
  34249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34250. }
  34251. m.SetUpdatedAt(v)
  34252. return nil
  34253. case workexperience.FieldDeletedAt:
  34254. v, ok := value.(time.Time)
  34255. if !ok {
  34256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34257. }
  34258. m.SetDeletedAt(v)
  34259. return nil
  34260. case workexperience.FieldEmployeeID:
  34261. v, ok := value.(uint64)
  34262. if !ok {
  34263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34264. }
  34265. m.SetEmployeeID(v)
  34266. return nil
  34267. case workexperience.FieldStartDate:
  34268. v, ok := value.(time.Time)
  34269. if !ok {
  34270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34271. }
  34272. m.SetStartDate(v)
  34273. return nil
  34274. case workexperience.FieldEndDate:
  34275. v, ok := value.(time.Time)
  34276. if !ok {
  34277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34278. }
  34279. m.SetEndDate(v)
  34280. return nil
  34281. case workexperience.FieldCompany:
  34282. v, ok := value.(string)
  34283. if !ok {
  34284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34285. }
  34286. m.SetCompany(v)
  34287. return nil
  34288. case workexperience.FieldExperience:
  34289. v, ok := value.(string)
  34290. if !ok {
  34291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34292. }
  34293. m.SetExperience(v)
  34294. return nil
  34295. case workexperience.FieldOrganizationID:
  34296. v, ok := value.(uint64)
  34297. if !ok {
  34298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34299. }
  34300. m.SetOrganizationID(v)
  34301. return nil
  34302. }
  34303. return fmt.Errorf("unknown WorkExperience field %s", name)
  34304. }
  34305. // AddedFields returns all numeric fields that were incremented/decremented during
  34306. // this mutation.
  34307. func (m *WorkExperienceMutation) AddedFields() []string {
  34308. var fields []string
  34309. if m.addorganization_id != nil {
  34310. fields = append(fields, workexperience.FieldOrganizationID)
  34311. }
  34312. return fields
  34313. }
  34314. // AddedField returns the numeric value that was incremented/decremented on a field
  34315. // with the given name. The second boolean return value indicates that this field
  34316. // was not set, or was not defined in the schema.
  34317. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  34318. switch name {
  34319. case workexperience.FieldOrganizationID:
  34320. return m.AddedOrganizationID()
  34321. }
  34322. return nil, false
  34323. }
  34324. // AddField adds the value to the field with the given name. It returns an error if
  34325. // the field is not defined in the schema, or if the type mismatched the field
  34326. // type.
  34327. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  34328. switch name {
  34329. case workexperience.FieldOrganizationID:
  34330. v, ok := value.(int64)
  34331. if !ok {
  34332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34333. }
  34334. m.AddOrganizationID(v)
  34335. return nil
  34336. }
  34337. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  34338. }
  34339. // ClearedFields returns all nullable fields that were cleared during this
  34340. // mutation.
  34341. func (m *WorkExperienceMutation) ClearedFields() []string {
  34342. var fields []string
  34343. if m.FieldCleared(workexperience.FieldDeletedAt) {
  34344. fields = append(fields, workexperience.FieldDeletedAt)
  34345. }
  34346. return fields
  34347. }
  34348. // FieldCleared returns a boolean indicating if a field with the given name was
  34349. // cleared in this mutation.
  34350. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  34351. _, ok := m.clearedFields[name]
  34352. return ok
  34353. }
  34354. // ClearField clears the value of the field with the given name. It returns an
  34355. // error if the field is not defined in the schema.
  34356. func (m *WorkExperienceMutation) ClearField(name string) error {
  34357. switch name {
  34358. case workexperience.FieldDeletedAt:
  34359. m.ClearDeletedAt()
  34360. return nil
  34361. }
  34362. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  34363. }
  34364. // ResetField resets all changes in the mutation for the field with the given name.
  34365. // It returns an error if the field is not defined in the schema.
  34366. func (m *WorkExperienceMutation) ResetField(name string) error {
  34367. switch name {
  34368. case workexperience.FieldCreatedAt:
  34369. m.ResetCreatedAt()
  34370. return nil
  34371. case workexperience.FieldUpdatedAt:
  34372. m.ResetUpdatedAt()
  34373. return nil
  34374. case workexperience.FieldDeletedAt:
  34375. m.ResetDeletedAt()
  34376. return nil
  34377. case workexperience.FieldEmployeeID:
  34378. m.ResetEmployeeID()
  34379. return nil
  34380. case workexperience.FieldStartDate:
  34381. m.ResetStartDate()
  34382. return nil
  34383. case workexperience.FieldEndDate:
  34384. m.ResetEndDate()
  34385. return nil
  34386. case workexperience.FieldCompany:
  34387. m.ResetCompany()
  34388. return nil
  34389. case workexperience.FieldExperience:
  34390. m.ResetExperience()
  34391. return nil
  34392. case workexperience.FieldOrganizationID:
  34393. m.ResetOrganizationID()
  34394. return nil
  34395. }
  34396. return fmt.Errorf("unknown WorkExperience field %s", name)
  34397. }
  34398. // AddedEdges returns all edge names that were set/added in this mutation.
  34399. func (m *WorkExperienceMutation) AddedEdges() []string {
  34400. edges := make([]string, 0, 1)
  34401. if m.employee != nil {
  34402. edges = append(edges, workexperience.EdgeEmployee)
  34403. }
  34404. return edges
  34405. }
  34406. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34407. // name in this mutation.
  34408. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  34409. switch name {
  34410. case workexperience.EdgeEmployee:
  34411. if id := m.employee; id != nil {
  34412. return []ent.Value{*id}
  34413. }
  34414. }
  34415. return nil
  34416. }
  34417. // RemovedEdges returns all edge names that were removed in this mutation.
  34418. func (m *WorkExperienceMutation) RemovedEdges() []string {
  34419. edges := make([]string, 0, 1)
  34420. return edges
  34421. }
  34422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34423. // the given name in this mutation.
  34424. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  34425. return nil
  34426. }
  34427. // ClearedEdges returns all edge names that were cleared in this mutation.
  34428. func (m *WorkExperienceMutation) ClearedEdges() []string {
  34429. edges := make([]string, 0, 1)
  34430. if m.clearedemployee {
  34431. edges = append(edges, workexperience.EdgeEmployee)
  34432. }
  34433. return edges
  34434. }
  34435. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34436. // was cleared in this mutation.
  34437. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  34438. switch name {
  34439. case workexperience.EdgeEmployee:
  34440. return m.clearedemployee
  34441. }
  34442. return false
  34443. }
  34444. // ClearEdge clears the value of the edge with the given name. It returns an error
  34445. // if that edge is not defined in the schema.
  34446. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  34447. switch name {
  34448. case workexperience.EdgeEmployee:
  34449. m.ClearEmployee()
  34450. return nil
  34451. }
  34452. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  34453. }
  34454. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34455. // It returns an error if the edge is not defined in the schema.
  34456. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  34457. switch name {
  34458. case workexperience.EdgeEmployee:
  34459. m.ResetEmployee()
  34460. return nil
  34461. }
  34462. return fmt.Errorf("unknown WorkExperience edge %s", name)
  34463. }
  34464. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  34465. type WpChatroomMutation struct {
  34466. config
  34467. op Op
  34468. typ string
  34469. id *uint64
  34470. created_at *time.Time
  34471. updated_at *time.Time
  34472. status *uint8
  34473. addstatus *int8
  34474. wx_wxid *string
  34475. chatroom_id *string
  34476. nickname *string
  34477. owner *string
  34478. avatar *string
  34479. member_list *[]string
  34480. appendmember_list []string
  34481. clearedFields map[string]struct{}
  34482. done bool
  34483. oldValue func(context.Context) (*WpChatroom, error)
  34484. predicates []predicate.WpChatroom
  34485. }
  34486. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  34487. // wpchatroomOption allows management of the mutation configuration using functional options.
  34488. type wpchatroomOption func(*WpChatroomMutation)
  34489. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  34490. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  34491. m := &WpChatroomMutation{
  34492. config: c,
  34493. op: op,
  34494. typ: TypeWpChatroom,
  34495. clearedFields: make(map[string]struct{}),
  34496. }
  34497. for _, opt := range opts {
  34498. opt(m)
  34499. }
  34500. return m
  34501. }
  34502. // withWpChatroomID sets the ID field of the mutation.
  34503. func withWpChatroomID(id uint64) wpchatroomOption {
  34504. return func(m *WpChatroomMutation) {
  34505. var (
  34506. err error
  34507. once sync.Once
  34508. value *WpChatroom
  34509. )
  34510. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  34511. once.Do(func() {
  34512. if m.done {
  34513. err = errors.New("querying old values post mutation is not allowed")
  34514. } else {
  34515. value, err = m.Client().WpChatroom.Get(ctx, id)
  34516. }
  34517. })
  34518. return value, err
  34519. }
  34520. m.id = &id
  34521. }
  34522. }
  34523. // withWpChatroom sets the old WpChatroom of the mutation.
  34524. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  34525. return func(m *WpChatroomMutation) {
  34526. m.oldValue = func(context.Context) (*WpChatroom, error) {
  34527. return node, nil
  34528. }
  34529. m.id = &node.ID
  34530. }
  34531. }
  34532. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34533. // executed in a transaction (ent.Tx), a transactional client is returned.
  34534. func (m WpChatroomMutation) Client() *Client {
  34535. client := &Client{config: m.config}
  34536. client.init()
  34537. return client
  34538. }
  34539. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34540. // it returns an error otherwise.
  34541. func (m WpChatroomMutation) Tx() (*Tx, error) {
  34542. if _, ok := m.driver.(*txDriver); !ok {
  34543. return nil, errors.New("ent: mutation is not running in a transaction")
  34544. }
  34545. tx := &Tx{config: m.config}
  34546. tx.init()
  34547. return tx, nil
  34548. }
  34549. // SetID sets the value of the id field. Note that this
  34550. // operation is only accepted on creation of WpChatroom entities.
  34551. func (m *WpChatroomMutation) SetID(id uint64) {
  34552. m.id = &id
  34553. }
  34554. // ID returns the ID value in the mutation. Note that the ID is only available
  34555. // if it was provided to the builder or after it was returned from the database.
  34556. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  34557. if m.id == nil {
  34558. return
  34559. }
  34560. return *m.id, true
  34561. }
  34562. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34563. // That means, if the mutation is applied within a transaction with an isolation level such
  34564. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34565. // or updated by the mutation.
  34566. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  34567. switch {
  34568. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34569. id, exists := m.ID()
  34570. if exists {
  34571. return []uint64{id}, nil
  34572. }
  34573. fallthrough
  34574. case m.op.Is(OpUpdate | OpDelete):
  34575. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  34576. default:
  34577. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34578. }
  34579. }
  34580. // SetCreatedAt sets the "created_at" field.
  34581. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  34582. m.created_at = &t
  34583. }
  34584. // CreatedAt returns the value of the "created_at" field in the mutation.
  34585. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  34586. v := m.created_at
  34587. if v == nil {
  34588. return
  34589. }
  34590. return *v, true
  34591. }
  34592. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  34593. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34595. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34596. if !m.op.Is(OpUpdateOne) {
  34597. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34598. }
  34599. if m.id == nil || m.oldValue == nil {
  34600. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34601. }
  34602. oldValue, err := m.oldValue(ctx)
  34603. if err != nil {
  34604. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34605. }
  34606. return oldValue.CreatedAt, nil
  34607. }
  34608. // ResetCreatedAt resets all changes to the "created_at" field.
  34609. func (m *WpChatroomMutation) ResetCreatedAt() {
  34610. m.created_at = nil
  34611. }
  34612. // SetUpdatedAt sets the "updated_at" field.
  34613. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  34614. m.updated_at = &t
  34615. }
  34616. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34617. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  34618. v := m.updated_at
  34619. if v == nil {
  34620. return
  34621. }
  34622. return *v, true
  34623. }
  34624. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  34625. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34627. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34628. if !m.op.Is(OpUpdateOne) {
  34629. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34630. }
  34631. if m.id == nil || m.oldValue == nil {
  34632. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34633. }
  34634. oldValue, err := m.oldValue(ctx)
  34635. if err != nil {
  34636. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34637. }
  34638. return oldValue.UpdatedAt, nil
  34639. }
  34640. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34641. func (m *WpChatroomMutation) ResetUpdatedAt() {
  34642. m.updated_at = nil
  34643. }
  34644. // SetStatus sets the "status" field.
  34645. func (m *WpChatroomMutation) SetStatus(u uint8) {
  34646. m.status = &u
  34647. m.addstatus = nil
  34648. }
  34649. // Status returns the value of the "status" field in the mutation.
  34650. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  34651. v := m.status
  34652. if v == nil {
  34653. return
  34654. }
  34655. return *v, true
  34656. }
  34657. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  34658. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34660. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34661. if !m.op.Is(OpUpdateOne) {
  34662. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34663. }
  34664. if m.id == nil || m.oldValue == nil {
  34665. return v, errors.New("OldStatus requires an ID field in the mutation")
  34666. }
  34667. oldValue, err := m.oldValue(ctx)
  34668. if err != nil {
  34669. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34670. }
  34671. return oldValue.Status, nil
  34672. }
  34673. // AddStatus adds u to the "status" field.
  34674. func (m *WpChatroomMutation) AddStatus(u int8) {
  34675. if m.addstatus != nil {
  34676. *m.addstatus += u
  34677. } else {
  34678. m.addstatus = &u
  34679. }
  34680. }
  34681. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34682. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  34683. v := m.addstatus
  34684. if v == nil {
  34685. return
  34686. }
  34687. return *v, true
  34688. }
  34689. // ClearStatus clears the value of the "status" field.
  34690. func (m *WpChatroomMutation) ClearStatus() {
  34691. m.status = nil
  34692. m.addstatus = nil
  34693. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  34694. }
  34695. // StatusCleared returns if the "status" field was cleared in this mutation.
  34696. func (m *WpChatroomMutation) StatusCleared() bool {
  34697. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  34698. return ok
  34699. }
  34700. // ResetStatus resets all changes to the "status" field.
  34701. func (m *WpChatroomMutation) ResetStatus() {
  34702. m.status = nil
  34703. m.addstatus = nil
  34704. delete(m.clearedFields, wpchatroom.FieldStatus)
  34705. }
  34706. // SetWxWxid sets the "wx_wxid" field.
  34707. func (m *WpChatroomMutation) SetWxWxid(s string) {
  34708. m.wx_wxid = &s
  34709. }
  34710. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  34711. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  34712. v := m.wx_wxid
  34713. if v == nil {
  34714. return
  34715. }
  34716. return *v, true
  34717. }
  34718. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  34719. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34721. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  34722. if !m.op.Is(OpUpdateOne) {
  34723. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  34724. }
  34725. if m.id == nil || m.oldValue == nil {
  34726. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  34727. }
  34728. oldValue, err := m.oldValue(ctx)
  34729. if err != nil {
  34730. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  34731. }
  34732. return oldValue.WxWxid, nil
  34733. }
  34734. // ResetWxWxid resets all changes to the "wx_wxid" field.
  34735. func (m *WpChatroomMutation) ResetWxWxid() {
  34736. m.wx_wxid = nil
  34737. }
  34738. // SetChatroomID sets the "chatroom_id" field.
  34739. func (m *WpChatroomMutation) SetChatroomID(s string) {
  34740. m.chatroom_id = &s
  34741. }
  34742. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  34743. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  34744. v := m.chatroom_id
  34745. if v == nil {
  34746. return
  34747. }
  34748. return *v, true
  34749. }
  34750. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  34751. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34753. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  34754. if !m.op.Is(OpUpdateOne) {
  34755. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  34756. }
  34757. if m.id == nil || m.oldValue == nil {
  34758. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  34759. }
  34760. oldValue, err := m.oldValue(ctx)
  34761. if err != nil {
  34762. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  34763. }
  34764. return oldValue.ChatroomID, nil
  34765. }
  34766. // ResetChatroomID resets all changes to the "chatroom_id" field.
  34767. func (m *WpChatroomMutation) ResetChatroomID() {
  34768. m.chatroom_id = nil
  34769. }
  34770. // SetNickname sets the "nickname" field.
  34771. func (m *WpChatroomMutation) SetNickname(s string) {
  34772. m.nickname = &s
  34773. }
  34774. // Nickname returns the value of the "nickname" field in the mutation.
  34775. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  34776. v := m.nickname
  34777. if v == nil {
  34778. return
  34779. }
  34780. return *v, true
  34781. }
  34782. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  34783. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34785. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  34786. if !m.op.Is(OpUpdateOne) {
  34787. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34788. }
  34789. if m.id == nil || m.oldValue == nil {
  34790. return v, errors.New("OldNickname requires an ID field in the mutation")
  34791. }
  34792. oldValue, err := m.oldValue(ctx)
  34793. if err != nil {
  34794. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34795. }
  34796. return oldValue.Nickname, nil
  34797. }
  34798. // ResetNickname resets all changes to the "nickname" field.
  34799. func (m *WpChatroomMutation) ResetNickname() {
  34800. m.nickname = nil
  34801. }
  34802. // SetOwner sets the "owner" field.
  34803. func (m *WpChatroomMutation) SetOwner(s string) {
  34804. m.owner = &s
  34805. }
  34806. // Owner returns the value of the "owner" field in the mutation.
  34807. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  34808. v := m.owner
  34809. if v == nil {
  34810. return
  34811. }
  34812. return *v, true
  34813. }
  34814. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  34815. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34817. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  34818. if !m.op.Is(OpUpdateOne) {
  34819. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  34820. }
  34821. if m.id == nil || m.oldValue == nil {
  34822. return v, errors.New("OldOwner requires an ID field in the mutation")
  34823. }
  34824. oldValue, err := m.oldValue(ctx)
  34825. if err != nil {
  34826. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  34827. }
  34828. return oldValue.Owner, nil
  34829. }
  34830. // ResetOwner resets all changes to the "owner" field.
  34831. func (m *WpChatroomMutation) ResetOwner() {
  34832. m.owner = nil
  34833. }
  34834. // SetAvatar sets the "avatar" field.
  34835. func (m *WpChatroomMutation) SetAvatar(s string) {
  34836. m.avatar = &s
  34837. }
  34838. // Avatar returns the value of the "avatar" field in the mutation.
  34839. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  34840. v := m.avatar
  34841. if v == nil {
  34842. return
  34843. }
  34844. return *v, true
  34845. }
  34846. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  34847. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34849. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  34850. if !m.op.Is(OpUpdateOne) {
  34851. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  34852. }
  34853. if m.id == nil || m.oldValue == nil {
  34854. return v, errors.New("OldAvatar requires an ID field in the mutation")
  34855. }
  34856. oldValue, err := m.oldValue(ctx)
  34857. if err != nil {
  34858. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  34859. }
  34860. return oldValue.Avatar, nil
  34861. }
  34862. // ResetAvatar resets all changes to the "avatar" field.
  34863. func (m *WpChatroomMutation) ResetAvatar() {
  34864. m.avatar = nil
  34865. }
  34866. // SetMemberList sets the "member_list" field.
  34867. func (m *WpChatroomMutation) SetMemberList(s []string) {
  34868. m.member_list = &s
  34869. m.appendmember_list = nil
  34870. }
  34871. // MemberList returns the value of the "member_list" field in the mutation.
  34872. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  34873. v := m.member_list
  34874. if v == nil {
  34875. return
  34876. }
  34877. return *v, true
  34878. }
  34879. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  34880. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34882. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  34883. if !m.op.Is(OpUpdateOne) {
  34884. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  34885. }
  34886. if m.id == nil || m.oldValue == nil {
  34887. return v, errors.New("OldMemberList requires an ID field in the mutation")
  34888. }
  34889. oldValue, err := m.oldValue(ctx)
  34890. if err != nil {
  34891. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  34892. }
  34893. return oldValue.MemberList, nil
  34894. }
  34895. // AppendMemberList adds s to the "member_list" field.
  34896. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  34897. m.appendmember_list = append(m.appendmember_list, s...)
  34898. }
  34899. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  34900. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  34901. if len(m.appendmember_list) == 0 {
  34902. return nil, false
  34903. }
  34904. return m.appendmember_list, true
  34905. }
  34906. // ResetMemberList resets all changes to the "member_list" field.
  34907. func (m *WpChatroomMutation) ResetMemberList() {
  34908. m.member_list = nil
  34909. m.appendmember_list = nil
  34910. }
  34911. // Where appends a list predicates to the WpChatroomMutation builder.
  34912. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  34913. m.predicates = append(m.predicates, ps...)
  34914. }
  34915. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  34916. // users can use type-assertion to append predicates that do not depend on any generated package.
  34917. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  34918. p := make([]predicate.WpChatroom, len(ps))
  34919. for i := range ps {
  34920. p[i] = ps[i]
  34921. }
  34922. m.Where(p...)
  34923. }
  34924. // Op returns the operation name.
  34925. func (m *WpChatroomMutation) Op() Op {
  34926. return m.op
  34927. }
  34928. // SetOp allows setting the mutation operation.
  34929. func (m *WpChatroomMutation) SetOp(op Op) {
  34930. m.op = op
  34931. }
  34932. // Type returns the node type of this mutation (WpChatroom).
  34933. func (m *WpChatroomMutation) Type() string {
  34934. return m.typ
  34935. }
  34936. // Fields returns all fields that were changed during this mutation. Note that in
  34937. // order to get all numeric fields that were incremented/decremented, call
  34938. // AddedFields().
  34939. func (m *WpChatroomMutation) Fields() []string {
  34940. fields := make([]string, 0, 9)
  34941. if m.created_at != nil {
  34942. fields = append(fields, wpchatroom.FieldCreatedAt)
  34943. }
  34944. if m.updated_at != nil {
  34945. fields = append(fields, wpchatroom.FieldUpdatedAt)
  34946. }
  34947. if m.status != nil {
  34948. fields = append(fields, wpchatroom.FieldStatus)
  34949. }
  34950. if m.wx_wxid != nil {
  34951. fields = append(fields, wpchatroom.FieldWxWxid)
  34952. }
  34953. if m.chatroom_id != nil {
  34954. fields = append(fields, wpchatroom.FieldChatroomID)
  34955. }
  34956. if m.nickname != nil {
  34957. fields = append(fields, wpchatroom.FieldNickname)
  34958. }
  34959. if m.owner != nil {
  34960. fields = append(fields, wpchatroom.FieldOwner)
  34961. }
  34962. if m.avatar != nil {
  34963. fields = append(fields, wpchatroom.FieldAvatar)
  34964. }
  34965. if m.member_list != nil {
  34966. fields = append(fields, wpchatroom.FieldMemberList)
  34967. }
  34968. return fields
  34969. }
  34970. // Field returns the value of a field with the given name. The second boolean
  34971. // return value indicates that this field was not set, or was not defined in the
  34972. // schema.
  34973. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  34974. switch name {
  34975. case wpchatroom.FieldCreatedAt:
  34976. return m.CreatedAt()
  34977. case wpchatroom.FieldUpdatedAt:
  34978. return m.UpdatedAt()
  34979. case wpchatroom.FieldStatus:
  34980. return m.Status()
  34981. case wpchatroom.FieldWxWxid:
  34982. return m.WxWxid()
  34983. case wpchatroom.FieldChatroomID:
  34984. return m.ChatroomID()
  34985. case wpchatroom.FieldNickname:
  34986. return m.Nickname()
  34987. case wpchatroom.FieldOwner:
  34988. return m.Owner()
  34989. case wpchatroom.FieldAvatar:
  34990. return m.Avatar()
  34991. case wpchatroom.FieldMemberList:
  34992. return m.MemberList()
  34993. }
  34994. return nil, false
  34995. }
  34996. // OldField returns the old value of the field from the database. An error is
  34997. // returned if the mutation operation is not UpdateOne, or the query to the
  34998. // database failed.
  34999. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35000. switch name {
  35001. case wpchatroom.FieldCreatedAt:
  35002. return m.OldCreatedAt(ctx)
  35003. case wpchatroom.FieldUpdatedAt:
  35004. return m.OldUpdatedAt(ctx)
  35005. case wpchatroom.FieldStatus:
  35006. return m.OldStatus(ctx)
  35007. case wpchatroom.FieldWxWxid:
  35008. return m.OldWxWxid(ctx)
  35009. case wpchatroom.FieldChatroomID:
  35010. return m.OldChatroomID(ctx)
  35011. case wpchatroom.FieldNickname:
  35012. return m.OldNickname(ctx)
  35013. case wpchatroom.FieldOwner:
  35014. return m.OldOwner(ctx)
  35015. case wpchatroom.FieldAvatar:
  35016. return m.OldAvatar(ctx)
  35017. case wpchatroom.FieldMemberList:
  35018. return m.OldMemberList(ctx)
  35019. }
  35020. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  35021. }
  35022. // SetField sets the value of a field with the given name. It returns an error if
  35023. // the field is not defined in the schema, or if the type mismatched the field
  35024. // type.
  35025. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  35026. switch name {
  35027. case wpchatroom.FieldCreatedAt:
  35028. v, ok := value.(time.Time)
  35029. if !ok {
  35030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35031. }
  35032. m.SetCreatedAt(v)
  35033. return nil
  35034. case wpchatroom.FieldUpdatedAt:
  35035. v, ok := value.(time.Time)
  35036. if !ok {
  35037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35038. }
  35039. m.SetUpdatedAt(v)
  35040. return nil
  35041. case wpchatroom.FieldStatus:
  35042. v, ok := value.(uint8)
  35043. if !ok {
  35044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35045. }
  35046. m.SetStatus(v)
  35047. return nil
  35048. case wpchatroom.FieldWxWxid:
  35049. v, ok := value.(string)
  35050. if !ok {
  35051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35052. }
  35053. m.SetWxWxid(v)
  35054. return nil
  35055. case wpchatroom.FieldChatroomID:
  35056. v, ok := value.(string)
  35057. if !ok {
  35058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35059. }
  35060. m.SetChatroomID(v)
  35061. return nil
  35062. case wpchatroom.FieldNickname:
  35063. v, ok := value.(string)
  35064. if !ok {
  35065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35066. }
  35067. m.SetNickname(v)
  35068. return nil
  35069. case wpchatroom.FieldOwner:
  35070. v, ok := value.(string)
  35071. if !ok {
  35072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35073. }
  35074. m.SetOwner(v)
  35075. return nil
  35076. case wpchatroom.FieldAvatar:
  35077. v, ok := value.(string)
  35078. if !ok {
  35079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35080. }
  35081. m.SetAvatar(v)
  35082. return nil
  35083. case wpchatroom.FieldMemberList:
  35084. v, ok := value.([]string)
  35085. if !ok {
  35086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35087. }
  35088. m.SetMemberList(v)
  35089. return nil
  35090. }
  35091. return fmt.Errorf("unknown WpChatroom field %s", name)
  35092. }
  35093. // AddedFields returns all numeric fields that were incremented/decremented during
  35094. // this mutation.
  35095. func (m *WpChatroomMutation) AddedFields() []string {
  35096. var fields []string
  35097. if m.addstatus != nil {
  35098. fields = append(fields, wpchatroom.FieldStatus)
  35099. }
  35100. return fields
  35101. }
  35102. // AddedField returns the numeric value that was incremented/decremented on a field
  35103. // with the given name. The second boolean return value indicates that this field
  35104. // was not set, or was not defined in the schema.
  35105. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  35106. switch name {
  35107. case wpchatroom.FieldStatus:
  35108. return m.AddedStatus()
  35109. }
  35110. return nil, false
  35111. }
  35112. // AddField adds the value to the field with the given name. It returns an error if
  35113. // the field is not defined in the schema, or if the type mismatched the field
  35114. // type.
  35115. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  35116. switch name {
  35117. case wpchatroom.FieldStatus:
  35118. v, ok := value.(int8)
  35119. if !ok {
  35120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35121. }
  35122. m.AddStatus(v)
  35123. return nil
  35124. }
  35125. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  35126. }
  35127. // ClearedFields returns all nullable fields that were cleared during this
  35128. // mutation.
  35129. func (m *WpChatroomMutation) ClearedFields() []string {
  35130. var fields []string
  35131. if m.FieldCleared(wpchatroom.FieldStatus) {
  35132. fields = append(fields, wpchatroom.FieldStatus)
  35133. }
  35134. return fields
  35135. }
  35136. // FieldCleared returns a boolean indicating if a field with the given name was
  35137. // cleared in this mutation.
  35138. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  35139. _, ok := m.clearedFields[name]
  35140. return ok
  35141. }
  35142. // ClearField clears the value of the field with the given name. It returns an
  35143. // error if the field is not defined in the schema.
  35144. func (m *WpChatroomMutation) ClearField(name string) error {
  35145. switch name {
  35146. case wpchatroom.FieldStatus:
  35147. m.ClearStatus()
  35148. return nil
  35149. }
  35150. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  35151. }
  35152. // ResetField resets all changes in the mutation for the field with the given name.
  35153. // It returns an error if the field is not defined in the schema.
  35154. func (m *WpChatroomMutation) ResetField(name string) error {
  35155. switch name {
  35156. case wpchatroom.FieldCreatedAt:
  35157. m.ResetCreatedAt()
  35158. return nil
  35159. case wpchatroom.FieldUpdatedAt:
  35160. m.ResetUpdatedAt()
  35161. return nil
  35162. case wpchatroom.FieldStatus:
  35163. m.ResetStatus()
  35164. return nil
  35165. case wpchatroom.FieldWxWxid:
  35166. m.ResetWxWxid()
  35167. return nil
  35168. case wpchatroom.FieldChatroomID:
  35169. m.ResetChatroomID()
  35170. return nil
  35171. case wpchatroom.FieldNickname:
  35172. m.ResetNickname()
  35173. return nil
  35174. case wpchatroom.FieldOwner:
  35175. m.ResetOwner()
  35176. return nil
  35177. case wpchatroom.FieldAvatar:
  35178. m.ResetAvatar()
  35179. return nil
  35180. case wpchatroom.FieldMemberList:
  35181. m.ResetMemberList()
  35182. return nil
  35183. }
  35184. return fmt.Errorf("unknown WpChatroom field %s", name)
  35185. }
  35186. // AddedEdges returns all edge names that were set/added in this mutation.
  35187. func (m *WpChatroomMutation) AddedEdges() []string {
  35188. edges := make([]string, 0, 0)
  35189. return edges
  35190. }
  35191. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35192. // name in this mutation.
  35193. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  35194. return nil
  35195. }
  35196. // RemovedEdges returns all edge names that were removed in this mutation.
  35197. func (m *WpChatroomMutation) RemovedEdges() []string {
  35198. edges := make([]string, 0, 0)
  35199. return edges
  35200. }
  35201. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35202. // the given name in this mutation.
  35203. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  35204. return nil
  35205. }
  35206. // ClearedEdges returns all edge names that were cleared in this mutation.
  35207. func (m *WpChatroomMutation) ClearedEdges() []string {
  35208. edges := make([]string, 0, 0)
  35209. return edges
  35210. }
  35211. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35212. // was cleared in this mutation.
  35213. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  35214. return false
  35215. }
  35216. // ClearEdge clears the value of the edge with the given name. It returns an error
  35217. // if that edge is not defined in the schema.
  35218. func (m *WpChatroomMutation) ClearEdge(name string) error {
  35219. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  35220. }
  35221. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35222. // It returns an error if the edge is not defined in the schema.
  35223. func (m *WpChatroomMutation) ResetEdge(name string) error {
  35224. return fmt.Errorf("unknown WpChatroom edge %s", name)
  35225. }
  35226. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  35227. type WpChatroomMemberMutation struct {
  35228. config
  35229. op Op
  35230. typ string
  35231. id *uint64
  35232. created_at *time.Time
  35233. updated_at *time.Time
  35234. status *uint8
  35235. addstatus *int8
  35236. wx_wxid *string
  35237. wxid *string
  35238. nickname *string
  35239. avatar *string
  35240. clearedFields map[string]struct{}
  35241. done bool
  35242. oldValue func(context.Context) (*WpChatroomMember, error)
  35243. predicates []predicate.WpChatroomMember
  35244. }
  35245. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  35246. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  35247. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  35248. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  35249. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  35250. m := &WpChatroomMemberMutation{
  35251. config: c,
  35252. op: op,
  35253. typ: TypeWpChatroomMember,
  35254. clearedFields: make(map[string]struct{}),
  35255. }
  35256. for _, opt := range opts {
  35257. opt(m)
  35258. }
  35259. return m
  35260. }
  35261. // withWpChatroomMemberID sets the ID field of the mutation.
  35262. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  35263. return func(m *WpChatroomMemberMutation) {
  35264. var (
  35265. err error
  35266. once sync.Once
  35267. value *WpChatroomMember
  35268. )
  35269. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  35270. once.Do(func() {
  35271. if m.done {
  35272. err = errors.New("querying old values post mutation is not allowed")
  35273. } else {
  35274. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  35275. }
  35276. })
  35277. return value, err
  35278. }
  35279. m.id = &id
  35280. }
  35281. }
  35282. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  35283. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  35284. return func(m *WpChatroomMemberMutation) {
  35285. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  35286. return node, nil
  35287. }
  35288. m.id = &node.ID
  35289. }
  35290. }
  35291. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35292. // executed in a transaction (ent.Tx), a transactional client is returned.
  35293. func (m WpChatroomMemberMutation) Client() *Client {
  35294. client := &Client{config: m.config}
  35295. client.init()
  35296. return client
  35297. }
  35298. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35299. // it returns an error otherwise.
  35300. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  35301. if _, ok := m.driver.(*txDriver); !ok {
  35302. return nil, errors.New("ent: mutation is not running in a transaction")
  35303. }
  35304. tx := &Tx{config: m.config}
  35305. tx.init()
  35306. return tx, nil
  35307. }
  35308. // SetID sets the value of the id field. Note that this
  35309. // operation is only accepted on creation of WpChatroomMember entities.
  35310. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  35311. m.id = &id
  35312. }
  35313. // ID returns the ID value in the mutation. Note that the ID is only available
  35314. // if it was provided to the builder or after it was returned from the database.
  35315. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  35316. if m.id == nil {
  35317. return
  35318. }
  35319. return *m.id, true
  35320. }
  35321. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35322. // That means, if the mutation is applied within a transaction with an isolation level such
  35323. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35324. // or updated by the mutation.
  35325. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  35326. switch {
  35327. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35328. id, exists := m.ID()
  35329. if exists {
  35330. return []uint64{id}, nil
  35331. }
  35332. fallthrough
  35333. case m.op.Is(OpUpdate | OpDelete):
  35334. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  35335. default:
  35336. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35337. }
  35338. }
  35339. // SetCreatedAt sets the "created_at" field.
  35340. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  35341. m.created_at = &t
  35342. }
  35343. // CreatedAt returns the value of the "created_at" field in the mutation.
  35344. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  35345. v := m.created_at
  35346. if v == nil {
  35347. return
  35348. }
  35349. return *v, true
  35350. }
  35351. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  35352. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35354. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35355. if !m.op.Is(OpUpdateOne) {
  35356. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35357. }
  35358. if m.id == nil || m.oldValue == nil {
  35359. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35360. }
  35361. oldValue, err := m.oldValue(ctx)
  35362. if err != nil {
  35363. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35364. }
  35365. return oldValue.CreatedAt, nil
  35366. }
  35367. // ResetCreatedAt resets all changes to the "created_at" field.
  35368. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  35369. m.created_at = nil
  35370. }
  35371. // SetUpdatedAt sets the "updated_at" field.
  35372. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  35373. m.updated_at = &t
  35374. }
  35375. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35376. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  35377. v := m.updated_at
  35378. if v == nil {
  35379. return
  35380. }
  35381. return *v, true
  35382. }
  35383. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  35384. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35386. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35387. if !m.op.Is(OpUpdateOne) {
  35388. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35389. }
  35390. if m.id == nil || m.oldValue == nil {
  35391. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35392. }
  35393. oldValue, err := m.oldValue(ctx)
  35394. if err != nil {
  35395. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35396. }
  35397. return oldValue.UpdatedAt, nil
  35398. }
  35399. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35400. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  35401. m.updated_at = nil
  35402. }
  35403. // SetStatus sets the "status" field.
  35404. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  35405. m.status = &u
  35406. m.addstatus = nil
  35407. }
  35408. // Status returns the value of the "status" field in the mutation.
  35409. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  35410. v := m.status
  35411. if v == nil {
  35412. return
  35413. }
  35414. return *v, true
  35415. }
  35416. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  35417. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35419. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35420. if !m.op.Is(OpUpdateOne) {
  35421. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35422. }
  35423. if m.id == nil || m.oldValue == nil {
  35424. return v, errors.New("OldStatus requires an ID field in the mutation")
  35425. }
  35426. oldValue, err := m.oldValue(ctx)
  35427. if err != nil {
  35428. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35429. }
  35430. return oldValue.Status, nil
  35431. }
  35432. // AddStatus adds u to the "status" field.
  35433. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  35434. if m.addstatus != nil {
  35435. *m.addstatus += u
  35436. } else {
  35437. m.addstatus = &u
  35438. }
  35439. }
  35440. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35441. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  35442. v := m.addstatus
  35443. if v == nil {
  35444. return
  35445. }
  35446. return *v, true
  35447. }
  35448. // ClearStatus clears the value of the "status" field.
  35449. func (m *WpChatroomMemberMutation) ClearStatus() {
  35450. m.status = nil
  35451. m.addstatus = nil
  35452. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  35453. }
  35454. // StatusCleared returns if the "status" field was cleared in this mutation.
  35455. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  35456. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  35457. return ok
  35458. }
  35459. // ResetStatus resets all changes to the "status" field.
  35460. func (m *WpChatroomMemberMutation) ResetStatus() {
  35461. m.status = nil
  35462. m.addstatus = nil
  35463. delete(m.clearedFields, wpchatroommember.FieldStatus)
  35464. }
  35465. // SetWxWxid sets the "wx_wxid" field.
  35466. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  35467. m.wx_wxid = &s
  35468. }
  35469. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  35470. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  35471. v := m.wx_wxid
  35472. if v == nil {
  35473. return
  35474. }
  35475. return *v, true
  35476. }
  35477. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  35478. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35480. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  35481. if !m.op.Is(OpUpdateOne) {
  35482. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  35483. }
  35484. if m.id == nil || m.oldValue == nil {
  35485. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  35486. }
  35487. oldValue, err := m.oldValue(ctx)
  35488. if err != nil {
  35489. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  35490. }
  35491. return oldValue.WxWxid, nil
  35492. }
  35493. // ResetWxWxid resets all changes to the "wx_wxid" field.
  35494. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  35495. m.wx_wxid = nil
  35496. }
  35497. // SetWxid sets the "wxid" field.
  35498. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  35499. m.wxid = &s
  35500. }
  35501. // Wxid returns the value of the "wxid" field in the mutation.
  35502. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  35503. v := m.wxid
  35504. if v == nil {
  35505. return
  35506. }
  35507. return *v, true
  35508. }
  35509. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  35510. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35512. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  35513. if !m.op.Is(OpUpdateOne) {
  35514. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  35515. }
  35516. if m.id == nil || m.oldValue == nil {
  35517. return v, errors.New("OldWxid requires an ID field in the mutation")
  35518. }
  35519. oldValue, err := m.oldValue(ctx)
  35520. if err != nil {
  35521. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  35522. }
  35523. return oldValue.Wxid, nil
  35524. }
  35525. // ResetWxid resets all changes to the "wxid" field.
  35526. func (m *WpChatroomMemberMutation) ResetWxid() {
  35527. m.wxid = nil
  35528. }
  35529. // SetNickname sets the "nickname" field.
  35530. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  35531. m.nickname = &s
  35532. }
  35533. // Nickname returns the value of the "nickname" field in the mutation.
  35534. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  35535. v := m.nickname
  35536. if v == nil {
  35537. return
  35538. }
  35539. return *v, true
  35540. }
  35541. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  35542. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35544. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  35545. if !m.op.Is(OpUpdateOne) {
  35546. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  35547. }
  35548. if m.id == nil || m.oldValue == nil {
  35549. return v, errors.New("OldNickname requires an ID field in the mutation")
  35550. }
  35551. oldValue, err := m.oldValue(ctx)
  35552. if err != nil {
  35553. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  35554. }
  35555. return oldValue.Nickname, nil
  35556. }
  35557. // ResetNickname resets all changes to the "nickname" field.
  35558. func (m *WpChatroomMemberMutation) ResetNickname() {
  35559. m.nickname = nil
  35560. }
  35561. // SetAvatar sets the "avatar" field.
  35562. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  35563. m.avatar = &s
  35564. }
  35565. // Avatar returns the value of the "avatar" field in the mutation.
  35566. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  35567. v := m.avatar
  35568. if v == nil {
  35569. return
  35570. }
  35571. return *v, true
  35572. }
  35573. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  35574. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35576. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  35577. if !m.op.Is(OpUpdateOne) {
  35578. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  35579. }
  35580. if m.id == nil || m.oldValue == nil {
  35581. return v, errors.New("OldAvatar requires an ID field in the mutation")
  35582. }
  35583. oldValue, err := m.oldValue(ctx)
  35584. if err != nil {
  35585. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  35586. }
  35587. return oldValue.Avatar, nil
  35588. }
  35589. // ResetAvatar resets all changes to the "avatar" field.
  35590. func (m *WpChatroomMemberMutation) ResetAvatar() {
  35591. m.avatar = nil
  35592. }
  35593. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  35594. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  35595. m.predicates = append(m.predicates, ps...)
  35596. }
  35597. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  35598. // users can use type-assertion to append predicates that do not depend on any generated package.
  35599. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  35600. p := make([]predicate.WpChatroomMember, len(ps))
  35601. for i := range ps {
  35602. p[i] = ps[i]
  35603. }
  35604. m.Where(p...)
  35605. }
  35606. // Op returns the operation name.
  35607. func (m *WpChatroomMemberMutation) Op() Op {
  35608. return m.op
  35609. }
  35610. // SetOp allows setting the mutation operation.
  35611. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  35612. m.op = op
  35613. }
  35614. // Type returns the node type of this mutation (WpChatroomMember).
  35615. func (m *WpChatroomMemberMutation) Type() string {
  35616. return m.typ
  35617. }
  35618. // Fields returns all fields that were changed during this mutation. Note that in
  35619. // order to get all numeric fields that were incremented/decremented, call
  35620. // AddedFields().
  35621. func (m *WpChatroomMemberMutation) Fields() []string {
  35622. fields := make([]string, 0, 7)
  35623. if m.created_at != nil {
  35624. fields = append(fields, wpchatroommember.FieldCreatedAt)
  35625. }
  35626. if m.updated_at != nil {
  35627. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  35628. }
  35629. if m.status != nil {
  35630. fields = append(fields, wpchatroommember.FieldStatus)
  35631. }
  35632. if m.wx_wxid != nil {
  35633. fields = append(fields, wpchatroommember.FieldWxWxid)
  35634. }
  35635. if m.wxid != nil {
  35636. fields = append(fields, wpchatroommember.FieldWxid)
  35637. }
  35638. if m.nickname != nil {
  35639. fields = append(fields, wpchatroommember.FieldNickname)
  35640. }
  35641. if m.avatar != nil {
  35642. fields = append(fields, wpchatroommember.FieldAvatar)
  35643. }
  35644. return fields
  35645. }
  35646. // Field returns the value of a field with the given name. The second boolean
  35647. // return value indicates that this field was not set, or was not defined in the
  35648. // schema.
  35649. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  35650. switch name {
  35651. case wpchatroommember.FieldCreatedAt:
  35652. return m.CreatedAt()
  35653. case wpchatroommember.FieldUpdatedAt:
  35654. return m.UpdatedAt()
  35655. case wpchatroommember.FieldStatus:
  35656. return m.Status()
  35657. case wpchatroommember.FieldWxWxid:
  35658. return m.WxWxid()
  35659. case wpchatroommember.FieldWxid:
  35660. return m.Wxid()
  35661. case wpchatroommember.FieldNickname:
  35662. return m.Nickname()
  35663. case wpchatroommember.FieldAvatar:
  35664. return m.Avatar()
  35665. }
  35666. return nil, false
  35667. }
  35668. // OldField returns the old value of the field from the database. An error is
  35669. // returned if the mutation operation is not UpdateOne, or the query to the
  35670. // database failed.
  35671. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35672. switch name {
  35673. case wpchatroommember.FieldCreatedAt:
  35674. return m.OldCreatedAt(ctx)
  35675. case wpchatroommember.FieldUpdatedAt:
  35676. return m.OldUpdatedAt(ctx)
  35677. case wpchatroommember.FieldStatus:
  35678. return m.OldStatus(ctx)
  35679. case wpchatroommember.FieldWxWxid:
  35680. return m.OldWxWxid(ctx)
  35681. case wpchatroommember.FieldWxid:
  35682. return m.OldWxid(ctx)
  35683. case wpchatroommember.FieldNickname:
  35684. return m.OldNickname(ctx)
  35685. case wpchatroommember.FieldAvatar:
  35686. return m.OldAvatar(ctx)
  35687. }
  35688. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  35689. }
  35690. // SetField sets the value of a field with the given name. It returns an error if
  35691. // the field is not defined in the schema, or if the type mismatched the field
  35692. // type.
  35693. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  35694. switch name {
  35695. case wpchatroommember.FieldCreatedAt:
  35696. v, ok := value.(time.Time)
  35697. if !ok {
  35698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35699. }
  35700. m.SetCreatedAt(v)
  35701. return nil
  35702. case wpchatroommember.FieldUpdatedAt:
  35703. v, ok := value.(time.Time)
  35704. if !ok {
  35705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35706. }
  35707. m.SetUpdatedAt(v)
  35708. return nil
  35709. case wpchatroommember.FieldStatus:
  35710. v, ok := value.(uint8)
  35711. if !ok {
  35712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35713. }
  35714. m.SetStatus(v)
  35715. return nil
  35716. case wpchatroommember.FieldWxWxid:
  35717. v, ok := value.(string)
  35718. if !ok {
  35719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35720. }
  35721. m.SetWxWxid(v)
  35722. return nil
  35723. case wpchatroommember.FieldWxid:
  35724. v, ok := value.(string)
  35725. if !ok {
  35726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35727. }
  35728. m.SetWxid(v)
  35729. return nil
  35730. case wpchatroommember.FieldNickname:
  35731. v, ok := value.(string)
  35732. if !ok {
  35733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35734. }
  35735. m.SetNickname(v)
  35736. return nil
  35737. case wpchatroommember.FieldAvatar:
  35738. v, ok := value.(string)
  35739. if !ok {
  35740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35741. }
  35742. m.SetAvatar(v)
  35743. return nil
  35744. }
  35745. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  35746. }
  35747. // AddedFields returns all numeric fields that were incremented/decremented during
  35748. // this mutation.
  35749. func (m *WpChatroomMemberMutation) AddedFields() []string {
  35750. var fields []string
  35751. if m.addstatus != nil {
  35752. fields = append(fields, wpchatroommember.FieldStatus)
  35753. }
  35754. return fields
  35755. }
  35756. // AddedField returns the numeric value that was incremented/decremented on a field
  35757. // with the given name. The second boolean return value indicates that this field
  35758. // was not set, or was not defined in the schema.
  35759. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  35760. switch name {
  35761. case wpchatroommember.FieldStatus:
  35762. return m.AddedStatus()
  35763. }
  35764. return nil, false
  35765. }
  35766. // AddField adds the value to the field with the given name. It returns an error if
  35767. // the field is not defined in the schema, or if the type mismatched the field
  35768. // type.
  35769. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  35770. switch name {
  35771. case wpchatroommember.FieldStatus:
  35772. v, ok := value.(int8)
  35773. if !ok {
  35774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35775. }
  35776. m.AddStatus(v)
  35777. return nil
  35778. }
  35779. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  35780. }
  35781. // ClearedFields returns all nullable fields that were cleared during this
  35782. // mutation.
  35783. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  35784. var fields []string
  35785. if m.FieldCleared(wpchatroommember.FieldStatus) {
  35786. fields = append(fields, wpchatroommember.FieldStatus)
  35787. }
  35788. return fields
  35789. }
  35790. // FieldCleared returns a boolean indicating if a field with the given name was
  35791. // cleared in this mutation.
  35792. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  35793. _, ok := m.clearedFields[name]
  35794. return ok
  35795. }
  35796. // ClearField clears the value of the field with the given name. It returns an
  35797. // error if the field is not defined in the schema.
  35798. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  35799. switch name {
  35800. case wpchatroommember.FieldStatus:
  35801. m.ClearStatus()
  35802. return nil
  35803. }
  35804. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  35805. }
  35806. // ResetField resets all changes in the mutation for the field with the given name.
  35807. // It returns an error if the field is not defined in the schema.
  35808. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  35809. switch name {
  35810. case wpchatroommember.FieldCreatedAt:
  35811. m.ResetCreatedAt()
  35812. return nil
  35813. case wpchatroommember.FieldUpdatedAt:
  35814. m.ResetUpdatedAt()
  35815. return nil
  35816. case wpchatroommember.FieldStatus:
  35817. m.ResetStatus()
  35818. return nil
  35819. case wpchatroommember.FieldWxWxid:
  35820. m.ResetWxWxid()
  35821. return nil
  35822. case wpchatroommember.FieldWxid:
  35823. m.ResetWxid()
  35824. return nil
  35825. case wpchatroommember.FieldNickname:
  35826. m.ResetNickname()
  35827. return nil
  35828. case wpchatroommember.FieldAvatar:
  35829. m.ResetAvatar()
  35830. return nil
  35831. }
  35832. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  35833. }
  35834. // AddedEdges returns all edge names that were set/added in this mutation.
  35835. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  35836. edges := make([]string, 0, 0)
  35837. return edges
  35838. }
  35839. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35840. // name in this mutation.
  35841. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  35842. return nil
  35843. }
  35844. // RemovedEdges returns all edge names that were removed in this mutation.
  35845. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  35846. edges := make([]string, 0, 0)
  35847. return edges
  35848. }
  35849. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35850. // the given name in this mutation.
  35851. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  35852. return nil
  35853. }
  35854. // ClearedEdges returns all edge names that were cleared in this mutation.
  35855. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  35856. edges := make([]string, 0, 0)
  35857. return edges
  35858. }
  35859. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35860. // was cleared in this mutation.
  35861. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  35862. return false
  35863. }
  35864. // ClearEdge clears the value of the edge with the given name. It returns an error
  35865. // if that edge is not defined in the schema.
  35866. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  35867. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  35868. }
  35869. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35870. // It returns an error if the edge is not defined in the schema.
  35871. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  35872. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  35873. }
  35874. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  35875. type WxMutation struct {
  35876. config
  35877. op Op
  35878. typ string
  35879. id *uint64
  35880. created_at *time.Time
  35881. updated_at *time.Time
  35882. status *uint8
  35883. addstatus *int8
  35884. deleted_at *time.Time
  35885. port *string
  35886. process_id *string
  35887. callback *string
  35888. wxid *string
  35889. account *string
  35890. nickname *string
  35891. tel *string
  35892. head_big *string
  35893. organization_id *uint64
  35894. addorganization_id *int64
  35895. api_base *string
  35896. api_key *string
  35897. allow_list *[]string
  35898. appendallow_list []string
  35899. group_allow_list *[]string
  35900. appendgroup_allow_list []string
  35901. block_list *[]string
  35902. appendblock_list []string
  35903. group_block_list *[]string
  35904. appendgroup_block_list []string
  35905. clearedFields map[string]struct{}
  35906. server *uint64
  35907. clearedserver bool
  35908. agent *uint64
  35909. clearedagent bool
  35910. done bool
  35911. oldValue func(context.Context) (*Wx, error)
  35912. predicates []predicate.Wx
  35913. }
  35914. var _ ent.Mutation = (*WxMutation)(nil)
  35915. // wxOption allows management of the mutation configuration using functional options.
  35916. type wxOption func(*WxMutation)
  35917. // newWxMutation creates new mutation for the Wx entity.
  35918. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  35919. m := &WxMutation{
  35920. config: c,
  35921. op: op,
  35922. typ: TypeWx,
  35923. clearedFields: make(map[string]struct{}),
  35924. }
  35925. for _, opt := range opts {
  35926. opt(m)
  35927. }
  35928. return m
  35929. }
  35930. // withWxID sets the ID field of the mutation.
  35931. func withWxID(id uint64) wxOption {
  35932. return func(m *WxMutation) {
  35933. var (
  35934. err error
  35935. once sync.Once
  35936. value *Wx
  35937. )
  35938. m.oldValue = func(ctx context.Context) (*Wx, error) {
  35939. once.Do(func() {
  35940. if m.done {
  35941. err = errors.New("querying old values post mutation is not allowed")
  35942. } else {
  35943. value, err = m.Client().Wx.Get(ctx, id)
  35944. }
  35945. })
  35946. return value, err
  35947. }
  35948. m.id = &id
  35949. }
  35950. }
  35951. // withWx sets the old Wx of the mutation.
  35952. func withWx(node *Wx) wxOption {
  35953. return func(m *WxMutation) {
  35954. m.oldValue = func(context.Context) (*Wx, error) {
  35955. return node, nil
  35956. }
  35957. m.id = &node.ID
  35958. }
  35959. }
  35960. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35961. // executed in a transaction (ent.Tx), a transactional client is returned.
  35962. func (m WxMutation) Client() *Client {
  35963. client := &Client{config: m.config}
  35964. client.init()
  35965. return client
  35966. }
  35967. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35968. // it returns an error otherwise.
  35969. func (m WxMutation) Tx() (*Tx, error) {
  35970. if _, ok := m.driver.(*txDriver); !ok {
  35971. return nil, errors.New("ent: mutation is not running in a transaction")
  35972. }
  35973. tx := &Tx{config: m.config}
  35974. tx.init()
  35975. return tx, nil
  35976. }
  35977. // SetID sets the value of the id field. Note that this
  35978. // operation is only accepted on creation of Wx entities.
  35979. func (m *WxMutation) SetID(id uint64) {
  35980. m.id = &id
  35981. }
  35982. // ID returns the ID value in the mutation. Note that the ID is only available
  35983. // if it was provided to the builder or after it was returned from the database.
  35984. func (m *WxMutation) ID() (id uint64, exists bool) {
  35985. if m.id == nil {
  35986. return
  35987. }
  35988. return *m.id, true
  35989. }
  35990. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35991. // That means, if the mutation is applied within a transaction with an isolation level such
  35992. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35993. // or updated by the mutation.
  35994. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  35995. switch {
  35996. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35997. id, exists := m.ID()
  35998. if exists {
  35999. return []uint64{id}, nil
  36000. }
  36001. fallthrough
  36002. case m.op.Is(OpUpdate | OpDelete):
  36003. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  36004. default:
  36005. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36006. }
  36007. }
  36008. // SetCreatedAt sets the "created_at" field.
  36009. func (m *WxMutation) SetCreatedAt(t time.Time) {
  36010. m.created_at = &t
  36011. }
  36012. // CreatedAt returns the value of the "created_at" field in the mutation.
  36013. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  36014. v := m.created_at
  36015. if v == nil {
  36016. return
  36017. }
  36018. return *v, true
  36019. }
  36020. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  36021. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36023. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36024. if !m.op.Is(OpUpdateOne) {
  36025. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36026. }
  36027. if m.id == nil || m.oldValue == nil {
  36028. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36029. }
  36030. oldValue, err := m.oldValue(ctx)
  36031. if err != nil {
  36032. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36033. }
  36034. return oldValue.CreatedAt, nil
  36035. }
  36036. // ResetCreatedAt resets all changes to the "created_at" field.
  36037. func (m *WxMutation) ResetCreatedAt() {
  36038. m.created_at = nil
  36039. }
  36040. // SetUpdatedAt sets the "updated_at" field.
  36041. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  36042. m.updated_at = &t
  36043. }
  36044. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36045. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  36046. v := m.updated_at
  36047. if v == nil {
  36048. return
  36049. }
  36050. return *v, true
  36051. }
  36052. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  36053. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36055. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36056. if !m.op.Is(OpUpdateOne) {
  36057. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36058. }
  36059. if m.id == nil || m.oldValue == nil {
  36060. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36061. }
  36062. oldValue, err := m.oldValue(ctx)
  36063. if err != nil {
  36064. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36065. }
  36066. return oldValue.UpdatedAt, nil
  36067. }
  36068. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36069. func (m *WxMutation) ResetUpdatedAt() {
  36070. m.updated_at = nil
  36071. }
  36072. // SetStatus sets the "status" field.
  36073. func (m *WxMutation) SetStatus(u uint8) {
  36074. m.status = &u
  36075. m.addstatus = nil
  36076. }
  36077. // Status returns the value of the "status" field in the mutation.
  36078. func (m *WxMutation) Status() (r uint8, exists bool) {
  36079. v := m.status
  36080. if v == nil {
  36081. return
  36082. }
  36083. return *v, true
  36084. }
  36085. // OldStatus returns the old "status" field's value of the Wx entity.
  36086. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36088. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36089. if !m.op.Is(OpUpdateOne) {
  36090. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36091. }
  36092. if m.id == nil || m.oldValue == nil {
  36093. return v, errors.New("OldStatus requires an ID field in the mutation")
  36094. }
  36095. oldValue, err := m.oldValue(ctx)
  36096. if err != nil {
  36097. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36098. }
  36099. return oldValue.Status, nil
  36100. }
  36101. // AddStatus adds u to the "status" field.
  36102. func (m *WxMutation) AddStatus(u int8) {
  36103. if m.addstatus != nil {
  36104. *m.addstatus += u
  36105. } else {
  36106. m.addstatus = &u
  36107. }
  36108. }
  36109. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36110. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  36111. v := m.addstatus
  36112. if v == nil {
  36113. return
  36114. }
  36115. return *v, true
  36116. }
  36117. // ClearStatus clears the value of the "status" field.
  36118. func (m *WxMutation) ClearStatus() {
  36119. m.status = nil
  36120. m.addstatus = nil
  36121. m.clearedFields[wx.FieldStatus] = struct{}{}
  36122. }
  36123. // StatusCleared returns if the "status" field was cleared in this mutation.
  36124. func (m *WxMutation) StatusCleared() bool {
  36125. _, ok := m.clearedFields[wx.FieldStatus]
  36126. return ok
  36127. }
  36128. // ResetStatus resets all changes to the "status" field.
  36129. func (m *WxMutation) ResetStatus() {
  36130. m.status = nil
  36131. m.addstatus = nil
  36132. delete(m.clearedFields, wx.FieldStatus)
  36133. }
  36134. // SetDeletedAt sets the "deleted_at" field.
  36135. func (m *WxMutation) SetDeletedAt(t time.Time) {
  36136. m.deleted_at = &t
  36137. }
  36138. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36139. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  36140. v := m.deleted_at
  36141. if v == nil {
  36142. return
  36143. }
  36144. return *v, true
  36145. }
  36146. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  36147. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36149. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36150. if !m.op.Is(OpUpdateOne) {
  36151. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36152. }
  36153. if m.id == nil || m.oldValue == nil {
  36154. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36155. }
  36156. oldValue, err := m.oldValue(ctx)
  36157. if err != nil {
  36158. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36159. }
  36160. return oldValue.DeletedAt, nil
  36161. }
  36162. // ClearDeletedAt clears the value of the "deleted_at" field.
  36163. func (m *WxMutation) ClearDeletedAt() {
  36164. m.deleted_at = nil
  36165. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  36166. }
  36167. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36168. func (m *WxMutation) DeletedAtCleared() bool {
  36169. _, ok := m.clearedFields[wx.FieldDeletedAt]
  36170. return ok
  36171. }
  36172. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36173. func (m *WxMutation) ResetDeletedAt() {
  36174. m.deleted_at = nil
  36175. delete(m.clearedFields, wx.FieldDeletedAt)
  36176. }
  36177. // SetServerID sets the "server_id" field.
  36178. func (m *WxMutation) SetServerID(u uint64) {
  36179. m.server = &u
  36180. }
  36181. // ServerID returns the value of the "server_id" field in the mutation.
  36182. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  36183. v := m.server
  36184. if v == nil {
  36185. return
  36186. }
  36187. return *v, true
  36188. }
  36189. // OldServerID returns the old "server_id" field's value of the Wx entity.
  36190. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36192. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  36193. if !m.op.Is(OpUpdateOne) {
  36194. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  36195. }
  36196. if m.id == nil || m.oldValue == nil {
  36197. return v, errors.New("OldServerID requires an ID field in the mutation")
  36198. }
  36199. oldValue, err := m.oldValue(ctx)
  36200. if err != nil {
  36201. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  36202. }
  36203. return oldValue.ServerID, nil
  36204. }
  36205. // ClearServerID clears the value of the "server_id" field.
  36206. func (m *WxMutation) ClearServerID() {
  36207. m.server = nil
  36208. m.clearedFields[wx.FieldServerID] = struct{}{}
  36209. }
  36210. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  36211. func (m *WxMutation) ServerIDCleared() bool {
  36212. _, ok := m.clearedFields[wx.FieldServerID]
  36213. return ok
  36214. }
  36215. // ResetServerID resets all changes to the "server_id" field.
  36216. func (m *WxMutation) ResetServerID() {
  36217. m.server = nil
  36218. delete(m.clearedFields, wx.FieldServerID)
  36219. }
  36220. // SetPort sets the "port" field.
  36221. func (m *WxMutation) SetPort(s string) {
  36222. m.port = &s
  36223. }
  36224. // Port returns the value of the "port" field in the mutation.
  36225. func (m *WxMutation) Port() (r string, exists bool) {
  36226. v := m.port
  36227. if v == nil {
  36228. return
  36229. }
  36230. return *v, true
  36231. }
  36232. // OldPort returns the old "port" field's value of the Wx entity.
  36233. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36235. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  36236. if !m.op.Is(OpUpdateOne) {
  36237. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  36238. }
  36239. if m.id == nil || m.oldValue == nil {
  36240. return v, errors.New("OldPort requires an ID field in the mutation")
  36241. }
  36242. oldValue, err := m.oldValue(ctx)
  36243. if err != nil {
  36244. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  36245. }
  36246. return oldValue.Port, nil
  36247. }
  36248. // ResetPort resets all changes to the "port" field.
  36249. func (m *WxMutation) ResetPort() {
  36250. m.port = nil
  36251. }
  36252. // SetProcessID sets the "process_id" field.
  36253. func (m *WxMutation) SetProcessID(s string) {
  36254. m.process_id = &s
  36255. }
  36256. // ProcessID returns the value of the "process_id" field in the mutation.
  36257. func (m *WxMutation) ProcessID() (r string, exists bool) {
  36258. v := m.process_id
  36259. if v == nil {
  36260. return
  36261. }
  36262. return *v, true
  36263. }
  36264. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  36265. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36267. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  36268. if !m.op.Is(OpUpdateOne) {
  36269. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  36270. }
  36271. if m.id == nil || m.oldValue == nil {
  36272. return v, errors.New("OldProcessID requires an ID field in the mutation")
  36273. }
  36274. oldValue, err := m.oldValue(ctx)
  36275. if err != nil {
  36276. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  36277. }
  36278. return oldValue.ProcessID, nil
  36279. }
  36280. // ResetProcessID resets all changes to the "process_id" field.
  36281. func (m *WxMutation) ResetProcessID() {
  36282. m.process_id = nil
  36283. }
  36284. // SetCallback sets the "callback" field.
  36285. func (m *WxMutation) SetCallback(s string) {
  36286. m.callback = &s
  36287. }
  36288. // Callback returns the value of the "callback" field in the mutation.
  36289. func (m *WxMutation) Callback() (r string, exists bool) {
  36290. v := m.callback
  36291. if v == nil {
  36292. return
  36293. }
  36294. return *v, true
  36295. }
  36296. // OldCallback returns the old "callback" field's value of the Wx entity.
  36297. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36299. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  36300. if !m.op.Is(OpUpdateOne) {
  36301. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36302. }
  36303. if m.id == nil || m.oldValue == nil {
  36304. return v, errors.New("OldCallback requires an ID field in the mutation")
  36305. }
  36306. oldValue, err := m.oldValue(ctx)
  36307. if err != nil {
  36308. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36309. }
  36310. return oldValue.Callback, nil
  36311. }
  36312. // ResetCallback resets all changes to the "callback" field.
  36313. func (m *WxMutation) ResetCallback() {
  36314. m.callback = nil
  36315. }
  36316. // SetWxid sets the "wxid" field.
  36317. func (m *WxMutation) SetWxid(s string) {
  36318. m.wxid = &s
  36319. }
  36320. // Wxid returns the value of the "wxid" field in the mutation.
  36321. func (m *WxMutation) Wxid() (r string, exists bool) {
  36322. v := m.wxid
  36323. if v == nil {
  36324. return
  36325. }
  36326. return *v, true
  36327. }
  36328. // OldWxid returns the old "wxid" field's value of the Wx entity.
  36329. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36331. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  36332. if !m.op.Is(OpUpdateOne) {
  36333. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  36334. }
  36335. if m.id == nil || m.oldValue == nil {
  36336. return v, errors.New("OldWxid requires an ID field in the mutation")
  36337. }
  36338. oldValue, err := m.oldValue(ctx)
  36339. if err != nil {
  36340. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  36341. }
  36342. return oldValue.Wxid, nil
  36343. }
  36344. // ResetWxid resets all changes to the "wxid" field.
  36345. func (m *WxMutation) ResetWxid() {
  36346. m.wxid = nil
  36347. }
  36348. // SetAccount sets the "account" field.
  36349. func (m *WxMutation) SetAccount(s string) {
  36350. m.account = &s
  36351. }
  36352. // Account returns the value of the "account" field in the mutation.
  36353. func (m *WxMutation) Account() (r string, exists bool) {
  36354. v := m.account
  36355. if v == nil {
  36356. return
  36357. }
  36358. return *v, true
  36359. }
  36360. // OldAccount returns the old "account" field's value of the Wx entity.
  36361. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36363. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  36364. if !m.op.Is(OpUpdateOne) {
  36365. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36366. }
  36367. if m.id == nil || m.oldValue == nil {
  36368. return v, errors.New("OldAccount requires an ID field in the mutation")
  36369. }
  36370. oldValue, err := m.oldValue(ctx)
  36371. if err != nil {
  36372. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36373. }
  36374. return oldValue.Account, nil
  36375. }
  36376. // ResetAccount resets all changes to the "account" field.
  36377. func (m *WxMutation) ResetAccount() {
  36378. m.account = nil
  36379. }
  36380. // SetNickname sets the "nickname" field.
  36381. func (m *WxMutation) SetNickname(s string) {
  36382. m.nickname = &s
  36383. }
  36384. // Nickname returns the value of the "nickname" field in the mutation.
  36385. func (m *WxMutation) Nickname() (r string, exists bool) {
  36386. v := m.nickname
  36387. if v == nil {
  36388. return
  36389. }
  36390. return *v, true
  36391. }
  36392. // OldNickname returns the old "nickname" field's value of the Wx entity.
  36393. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36395. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  36396. if !m.op.Is(OpUpdateOne) {
  36397. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36398. }
  36399. if m.id == nil || m.oldValue == nil {
  36400. return v, errors.New("OldNickname requires an ID field in the mutation")
  36401. }
  36402. oldValue, err := m.oldValue(ctx)
  36403. if err != nil {
  36404. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36405. }
  36406. return oldValue.Nickname, nil
  36407. }
  36408. // ResetNickname resets all changes to the "nickname" field.
  36409. func (m *WxMutation) ResetNickname() {
  36410. m.nickname = nil
  36411. }
  36412. // SetTel sets the "tel" field.
  36413. func (m *WxMutation) SetTel(s string) {
  36414. m.tel = &s
  36415. }
  36416. // Tel returns the value of the "tel" field in the mutation.
  36417. func (m *WxMutation) Tel() (r string, exists bool) {
  36418. v := m.tel
  36419. if v == nil {
  36420. return
  36421. }
  36422. return *v, true
  36423. }
  36424. // OldTel returns the old "tel" field's value of the Wx entity.
  36425. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36427. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  36428. if !m.op.Is(OpUpdateOne) {
  36429. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  36430. }
  36431. if m.id == nil || m.oldValue == nil {
  36432. return v, errors.New("OldTel requires an ID field in the mutation")
  36433. }
  36434. oldValue, err := m.oldValue(ctx)
  36435. if err != nil {
  36436. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  36437. }
  36438. return oldValue.Tel, nil
  36439. }
  36440. // ResetTel resets all changes to the "tel" field.
  36441. func (m *WxMutation) ResetTel() {
  36442. m.tel = nil
  36443. }
  36444. // SetHeadBig sets the "head_big" field.
  36445. func (m *WxMutation) SetHeadBig(s string) {
  36446. m.head_big = &s
  36447. }
  36448. // HeadBig returns the value of the "head_big" field in the mutation.
  36449. func (m *WxMutation) HeadBig() (r string, exists bool) {
  36450. v := m.head_big
  36451. if v == nil {
  36452. return
  36453. }
  36454. return *v, true
  36455. }
  36456. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  36457. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36459. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  36460. if !m.op.Is(OpUpdateOne) {
  36461. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  36462. }
  36463. if m.id == nil || m.oldValue == nil {
  36464. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  36465. }
  36466. oldValue, err := m.oldValue(ctx)
  36467. if err != nil {
  36468. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  36469. }
  36470. return oldValue.HeadBig, nil
  36471. }
  36472. // ResetHeadBig resets all changes to the "head_big" field.
  36473. func (m *WxMutation) ResetHeadBig() {
  36474. m.head_big = nil
  36475. }
  36476. // SetOrganizationID sets the "organization_id" field.
  36477. func (m *WxMutation) SetOrganizationID(u uint64) {
  36478. m.organization_id = &u
  36479. m.addorganization_id = nil
  36480. }
  36481. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36482. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  36483. v := m.organization_id
  36484. if v == nil {
  36485. return
  36486. }
  36487. return *v, true
  36488. }
  36489. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  36490. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36492. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36493. if !m.op.Is(OpUpdateOne) {
  36494. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36495. }
  36496. if m.id == nil || m.oldValue == nil {
  36497. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36498. }
  36499. oldValue, err := m.oldValue(ctx)
  36500. if err != nil {
  36501. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36502. }
  36503. return oldValue.OrganizationID, nil
  36504. }
  36505. // AddOrganizationID adds u to the "organization_id" field.
  36506. func (m *WxMutation) AddOrganizationID(u int64) {
  36507. if m.addorganization_id != nil {
  36508. *m.addorganization_id += u
  36509. } else {
  36510. m.addorganization_id = &u
  36511. }
  36512. }
  36513. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36514. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  36515. v := m.addorganization_id
  36516. if v == nil {
  36517. return
  36518. }
  36519. return *v, true
  36520. }
  36521. // ClearOrganizationID clears the value of the "organization_id" field.
  36522. func (m *WxMutation) ClearOrganizationID() {
  36523. m.organization_id = nil
  36524. m.addorganization_id = nil
  36525. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  36526. }
  36527. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36528. func (m *WxMutation) OrganizationIDCleared() bool {
  36529. _, ok := m.clearedFields[wx.FieldOrganizationID]
  36530. return ok
  36531. }
  36532. // ResetOrganizationID resets all changes to the "organization_id" field.
  36533. func (m *WxMutation) ResetOrganizationID() {
  36534. m.organization_id = nil
  36535. m.addorganization_id = nil
  36536. delete(m.clearedFields, wx.FieldOrganizationID)
  36537. }
  36538. // SetAgentID sets the "agent_id" field.
  36539. func (m *WxMutation) SetAgentID(u uint64) {
  36540. m.agent = &u
  36541. }
  36542. // AgentID returns the value of the "agent_id" field in the mutation.
  36543. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  36544. v := m.agent
  36545. if v == nil {
  36546. return
  36547. }
  36548. return *v, true
  36549. }
  36550. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  36551. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36553. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36554. if !m.op.Is(OpUpdateOne) {
  36555. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36556. }
  36557. if m.id == nil || m.oldValue == nil {
  36558. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36559. }
  36560. oldValue, err := m.oldValue(ctx)
  36561. if err != nil {
  36562. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36563. }
  36564. return oldValue.AgentID, nil
  36565. }
  36566. // ResetAgentID resets all changes to the "agent_id" field.
  36567. func (m *WxMutation) ResetAgentID() {
  36568. m.agent = nil
  36569. }
  36570. // SetAPIBase sets the "api_base" field.
  36571. func (m *WxMutation) SetAPIBase(s string) {
  36572. m.api_base = &s
  36573. }
  36574. // APIBase returns the value of the "api_base" field in the mutation.
  36575. func (m *WxMutation) APIBase() (r string, exists bool) {
  36576. v := m.api_base
  36577. if v == nil {
  36578. return
  36579. }
  36580. return *v, true
  36581. }
  36582. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  36583. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36585. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36586. if !m.op.Is(OpUpdateOne) {
  36587. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36588. }
  36589. if m.id == nil || m.oldValue == nil {
  36590. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  36591. }
  36592. oldValue, err := m.oldValue(ctx)
  36593. if err != nil {
  36594. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  36595. }
  36596. return oldValue.APIBase, nil
  36597. }
  36598. // ClearAPIBase clears the value of the "api_base" field.
  36599. func (m *WxMutation) ClearAPIBase() {
  36600. m.api_base = nil
  36601. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  36602. }
  36603. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  36604. func (m *WxMutation) APIBaseCleared() bool {
  36605. _, ok := m.clearedFields[wx.FieldAPIBase]
  36606. return ok
  36607. }
  36608. // ResetAPIBase resets all changes to the "api_base" field.
  36609. func (m *WxMutation) ResetAPIBase() {
  36610. m.api_base = nil
  36611. delete(m.clearedFields, wx.FieldAPIBase)
  36612. }
  36613. // SetAPIKey sets the "api_key" field.
  36614. func (m *WxMutation) SetAPIKey(s string) {
  36615. m.api_key = &s
  36616. }
  36617. // APIKey returns the value of the "api_key" field in the mutation.
  36618. func (m *WxMutation) APIKey() (r string, exists bool) {
  36619. v := m.api_key
  36620. if v == nil {
  36621. return
  36622. }
  36623. return *v, true
  36624. }
  36625. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  36626. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36628. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  36629. if !m.op.Is(OpUpdateOne) {
  36630. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  36631. }
  36632. if m.id == nil || m.oldValue == nil {
  36633. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  36634. }
  36635. oldValue, err := m.oldValue(ctx)
  36636. if err != nil {
  36637. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  36638. }
  36639. return oldValue.APIKey, nil
  36640. }
  36641. // ClearAPIKey clears the value of the "api_key" field.
  36642. func (m *WxMutation) ClearAPIKey() {
  36643. m.api_key = nil
  36644. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  36645. }
  36646. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  36647. func (m *WxMutation) APIKeyCleared() bool {
  36648. _, ok := m.clearedFields[wx.FieldAPIKey]
  36649. return ok
  36650. }
  36651. // ResetAPIKey resets all changes to the "api_key" field.
  36652. func (m *WxMutation) ResetAPIKey() {
  36653. m.api_key = nil
  36654. delete(m.clearedFields, wx.FieldAPIKey)
  36655. }
  36656. // SetAllowList sets the "allow_list" field.
  36657. func (m *WxMutation) SetAllowList(s []string) {
  36658. m.allow_list = &s
  36659. m.appendallow_list = nil
  36660. }
  36661. // AllowList returns the value of the "allow_list" field in the mutation.
  36662. func (m *WxMutation) AllowList() (r []string, exists bool) {
  36663. v := m.allow_list
  36664. if v == nil {
  36665. return
  36666. }
  36667. return *v, true
  36668. }
  36669. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  36670. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36672. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  36673. if !m.op.Is(OpUpdateOne) {
  36674. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  36675. }
  36676. if m.id == nil || m.oldValue == nil {
  36677. return v, errors.New("OldAllowList requires an ID field in the mutation")
  36678. }
  36679. oldValue, err := m.oldValue(ctx)
  36680. if err != nil {
  36681. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  36682. }
  36683. return oldValue.AllowList, nil
  36684. }
  36685. // AppendAllowList adds s to the "allow_list" field.
  36686. func (m *WxMutation) AppendAllowList(s []string) {
  36687. m.appendallow_list = append(m.appendallow_list, s...)
  36688. }
  36689. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  36690. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  36691. if len(m.appendallow_list) == 0 {
  36692. return nil, false
  36693. }
  36694. return m.appendallow_list, true
  36695. }
  36696. // ResetAllowList resets all changes to the "allow_list" field.
  36697. func (m *WxMutation) ResetAllowList() {
  36698. m.allow_list = nil
  36699. m.appendallow_list = nil
  36700. }
  36701. // SetGroupAllowList sets the "group_allow_list" field.
  36702. func (m *WxMutation) SetGroupAllowList(s []string) {
  36703. m.group_allow_list = &s
  36704. m.appendgroup_allow_list = nil
  36705. }
  36706. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  36707. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  36708. v := m.group_allow_list
  36709. if v == nil {
  36710. return
  36711. }
  36712. return *v, true
  36713. }
  36714. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  36715. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36717. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  36718. if !m.op.Is(OpUpdateOne) {
  36719. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  36720. }
  36721. if m.id == nil || m.oldValue == nil {
  36722. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  36723. }
  36724. oldValue, err := m.oldValue(ctx)
  36725. if err != nil {
  36726. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  36727. }
  36728. return oldValue.GroupAllowList, nil
  36729. }
  36730. // AppendGroupAllowList adds s to the "group_allow_list" field.
  36731. func (m *WxMutation) AppendGroupAllowList(s []string) {
  36732. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  36733. }
  36734. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  36735. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  36736. if len(m.appendgroup_allow_list) == 0 {
  36737. return nil, false
  36738. }
  36739. return m.appendgroup_allow_list, true
  36740. }
  36741. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  36742. func (m *WxMutation) ResetGroupAllowList() {
  36743. m.group_allow_list = nil
  36744. m.appendgroup_allow_list = nil
  36745. }
  36746. // SetBlockList sets the "block_list" field.
  36747. func (m *WxMutation) SetBlockList(s []string) {
  36748. m.block_list = &s
  36749. m.appendblock_list = nil
  36750. }
  36751. // BlockList returns the value of the "block_list" field in the mutation.
  36752. func (m *WxMutation) BlockList() (r []string, exists bool) {
  36753. v := m.block_list
  36754. if v == nil {
  36755. return
  36756. }
  36757. return *v, true
  36758. }
  36759. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  36760. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36762. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  36763. if !m.op.Is(OpUpdateOne) {
  36764. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  36765. }
  36766. if m.id == nil || m.oldValue == nil {
  36767. return v, errors.New("OldBlockList requires an ID field in the mutation")
  36768. }
  36769. oldValue, err := m.oldValue(ctx)
  36770. if err != nil {
  36771. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  36772. }
  36773. return oldValue.BlockList, nil
  36774. }
  36775. // AppendBlockList adds s to the "block_list" field.
  36776. func (m *WxMutation) AppendBlockList(s []string) {
  36777. m.appendblock_list = append(m.appendblock_list, s...)
  36778. }
  36779. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  36780. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  36781. if len(m.appendblock_list) == 0 {
  36782. return nil, false
  36783. }
  36784. return m.appendblock_list, true
  36785. }
  36786. // ResetBlockList resets all changes to the "block_list" field.
  36787. func (m *WxMutation) ResetBlockList() {
  36788. m.block_list = nil
  36789. m.appendblock_list = nil
  36790. }
  36791. // SetGroupBlockList sets the "group_block_list" field.
  36792. func (m *WxMutation) SetGroupBlockList(s []string) {
  36793. m.group_block_list = &s
  36794. m.appendgroup_block_list = nil
  36795. }
  36796. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  36797. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  36798. v := m.group_block_list
  36799. if v == nil {
  36800. return
  36801. }
  36802. return *v, true
  36803. }
  36804. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  36805. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36807. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  36808. if !m.op.Is(OpUpdateOne) {
  36809. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  36810. }
  36811. if m.id == nil || m.oldValue == nil {
  36812. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  36813. }
  36814. oldValue, err := m.oldValue(ctx)
  36815. if err != nil {
  36816. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  36817. }
  36818. return oldValue.GroupBlockList, nil
  36819. }
  36820. // AppendGroupBlockList adds s to the "group_block_list" field.
  36821. func (m *WxMutation) AppendGroupBlockList(s []string) {
  36822. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  36823. }
  36824. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  36825. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  36826. if len(m.appendgroup_block_list) == 0 {
  36827. return nil, false
  36828. }
  36829. return m.appendgroup_block_list, true
  36830. }
  36831. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  36832. func (m *WxMutation) ResetGroupBlockList() {
  36833. m.group_block_list = nil
  36834. m.appendgroup_block_list = nil
  36835. }
  36836. // ClearServer clears the "server" edge to the Server entity.
  36837. func (m *WxMutation) ClearServer() {
  36838. m.clearedserver = true
  36839. m.clearedFields[wx.FieldServerID] = struct{}{}
  36840. }
  36841. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  36842. func (m *WxMutation) ServerCleared() bool {
  36843. return m.ServerIDCleared() || m.clearedserver
  36844. }
  36845. // ServerIDs returns the "server" edge IDs in the mutation.
  36846. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36847. // ServerID instead. It exists only for internal usage by the builders.
  36848. func (m *WxMutation) ServerIDs() (ids []uint64) {
  36849. if id := m.server; id != nil {
  36850. ids = append(ids, *id)
  36851. }
  36852. return
  36853. }
  36854. // ResetServer resets all changes to the "server" edge.
  36855. func (m *WxMutation) ResetServer() {
  36856. m.server = nil
  36857. m.clearedserver = false
  36858. }
  36859. // ClearAgent clears the "agent" edge to the Agent entity.
  36860. func (m *WxMutation) ClearAgent() {
  36861. m.clearedagent = true
  36862. m.clearedFields[wx.FieldAgentID] = struct{}{}
  36863. }
  36864. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  36865. func (m *WxMutation) AgentCleared() bool {
  36866. return m.clearedagent
  36867. }
  36868. // AgentIDs returns the "agent" edge IDs in the mutation.
  36869. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36870. // AgentID instead. It exists only for internal usage by the builders.
  36871. func (m *WxMutation) AgentIDs() (ids []uint64) {
  36872. if id := m.agent; id != nil {
  36873. ids = append(ids, *id)
  36874. }
  36875. return
  36876. }
  36877. // ResetAgent resets all changes to the "agent" edge.
  36878. func (m *WxMutation) ResetAgent() {
  36879. m.agent = nil
  36880. m.clearedagent = false
  36881. }
  36882. // Where appends a list predicates to the WxMutation builder.
  36883. func (m *WxMutation) Where(ps ...predicate.Wx) {
  36884. m.predicates = append(m.predicates, ps...)
  36885. }
  36886. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  36887. // users can use type-assertion to append predicates that do not depend on any generated package.
  36888. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  36889. p := make([]predicate.Wx, len(ps))
  36890. for i := range ps {
  36891. p[i] = ps[i]
  36892. }
  36893. m.Where(p...)
  36894. }
  36895. // Op returns the operation name.
  36896. func (m *WxMutation) Op() Op {
  36897. return m.op
  36898. }
  36899. // SetOp allows setting the mutation operation.
  36900. func (m *WxMutation) SetOp(op Op) {
  36901. m.op = op
  36902. }
  36903. // Type returns the node type of this mutation (Wx).
  36904. func (m *WxMutation) Type() string {
  36905. return m.typ
  36906. }
  36907. // Fields returns all fields that were changed during this mutation. Note that in
  36908. // order to get all numeric fields that were incremented/decremented, call
  36909. // AddedFields().
  36910. func (m *WxMutation) Fields() []string {
  36911. fields := make([]string, 0, 21)
  36912. if m.created_at != nil {
  36913. fields = append(fields, wx.FieldCreatedAt)
  36914. }
  36915. if m.updated_at != nil {
  36916. fields = append(fields, wx.FieldUpdatedAt)
  36917. }
  36918. if m.status != nil {
  36919. fields = append(fields, wx.FieldStatus)
  36920. }
  36921. if m.deleted_at != nil {
  36922. fields = append(fields, wx.FieldDeletedAt)
  36923. }
  36924. if m.server != nil {
  36925. fields = append(fields, wx.FieldServerID)
  36926. }
  36927. if m.port != nil {
  36928. fields = append(fields, wx.FieldPort)
  36929. }
  36930. if m.process_id != nil {
  36931. fields = append(fields, wx.FieldProcessID)
  36932. }
  36933. if m.callback != nil {
  36934. fields = append(fields, wx.FieldCallback)
  36935. }
  36936. if m.wxid != nil {
  36937. fields = append(fields, wx.FieldWxid)
  36938. }
  36939. if m.account != nil {
  36940. fields = append(fields, wx.FieldAccount)
  36941. }
  36942. if m.nickname != nil {
  36943. fields = append(fields, wx.FieldNickname)
  36944. }
  36945. if m.tel != nil {
  36946. fields = append(fields, wx.FieldTel)
  36947. }
  36948. if m.head_big != nil {
  36949. fields = append(fields, wx.FieldHeadBig)
  36950. }
  36951. if m.organization_id != nil {
  36952. fields = append(fields, wx.FieldOrganizationID)
  36953. }
  36954. if m.agent != nil {
  36955. fields = append(fields, wx.FieldAgentID)
  36956. }
  36957. if m.api_base != nil {
  36958. fields = append(fields, wx.FieldAPIBase)
  36959. }
  36960. if m.api_key != nil {
  36961. fields = append(fields, wx.FieldAPIKey)
  36962. }
  36963. if m.allow_list != nil {
  36964. fields = append(fields, wx.FieldAllowList)
  36965. }
  36966. if m.group_allow_list != nil {
  36967. fields = append(fields, wx.FieldGroupAllowList)
  36968. }
  36969. if m.block_list != nil {
  36970. fields = append(fields, wx.FieldBlockList)
  36971. }
  36972. if m.group_block_list != nil {
  36973. fields = append(fields, wx.FieldGroupBlockList)
  36974. }
  36975. return fields
  36976. }
  36977. // Field returns the value of a field with the given name. The second boolean
  36978. // return value indicates that this field was not set, or was not defined in the
  36979. // schema.
  36980. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  36981. switch name {
  36982. case wx.FieldCreatedAt:
  36983. return m.CreatedAt()
  36984. case wx.FieldUpdatedAt:
  36985. return m.UpdatedAt()
  36986. case wx.FieldStatus:
  36987. return m.Status()
  36988. case wx.FieldDeletedAt:
  36989. return m.DeletedAt()
  36990. case wx.FieldServerID:
  36991. return m.ServerID()
  36992. case wx.FieldPort:
  36993. return m.Port()
  36994. case wx.FieldProcessID:
  36995. return m.ProcessID()
  36996. case wx.FieldCallback:
  36997. return m.Callback()
  36998. case wx.FieldWxid:
  36999. return m.Wxid()
  37000. case wx.FieldAccount:
  37001. return m.Account()
  37002. case wx.FieldNickname:
  37003. return m.Nickname()
  37004. case wx.FieldTel:
  37005. return m.Tel()
  37006. case wx.FieldHeadBig:
  37007. return m.HeadBig()
  37008. case wx.FieldOrganizationID:
  37009. return m.OrganizationID()
  37010. case wx.FieldAgentID:
  37011. return m.AgentID()
  37012. case wx.FieldAPIBase:
  37013. return m.APIBase()
  37014. case wx.FieldAPIKey:
  37015. return m.APIKey()
  37016. case wx.FieldAllowList:
  37017. return m.AllowList()
  37018. case wx.FieldGroupAllowList:
  37019. return m.GroupAllowList()
  37020. case wx.FieldBlockList:
  37021. return m.BlockList()
  37022. case wx.FieldGroupBlockList:
  37023. return m.GroupBlockList()
  37024. }
  37025. return nil, false
  37026. }
  37027. // OldField returns the old value of the field from the database. An error is
  37028. // returned if the mutation operation is not UpdateOne, or the query to the
  37029. // database failed.
  37030. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37031. switch name {
  37032. case wx.FieldCreatedAt:
  37033. return m.OldCreatedAt(ctx)
  37034. case wx.FieldUpdatedAt:
  37035. return m.OldUpdatedAt(ctx)
  37036. case wx.FieldStatus:
  37037. return m.OldStatus(ctx)
  37038. case wx.FieldDeletedAt:
  37039. return m.OldDeletedAt(ctx)
  37040. case wx.FieldServerID:
  37041. return m.OldServerID(ctx)
  37042. case wx.FieldPort:
  37043. return m.OldPort(ctx)
  37044. case wx.FieldProcessID:
  37045. return m.OldProcessID(ctx)
  37046. case wx.FieldCallback:
  37047. return m.OldCallback(ctx)
  37048. case wx.FieldWxid:
  37049. return m.OldWxid(ctx)
  37050. case wx.FieldAccount:
  37051. return m.OldAccount(ctx)
  37052. case wx.FieldNickname:
  37053. return m.OldNickname(ctx)
  37054. case wx.FieldTel:
  37055. return m.OldTel(ctx)
  37056. case wx.FieldHeadBig:
  37057. return m.OldHeadBig(ctx)
  37058. case wx.FieldOrganizationID:
  37059. return m.OldOrganizationID(ctx)
  37060. case wx.FieldAgentID:
  37061. return m.OldAgentID(ctx)
  37062. case wx.FieldAPIBase:
  37063. return m.OldAPIBase(ctx)
  37064. case wx.FieldAPIKey:
  37065. return m.OldAPIKey(ctx)
  37066. case wx.FieldAllowList:
  37067. return m.OldAllowList(ctx)
  37068. case wx.FieldGroupAllowList:
  37069. return m.OldGroupAllowList(ctx)
  37070. case wx.FieldBlockList:
  37071. return m.OldBlockList(ctx)
  37072. case wx.FieldGroupBlockList:
  37073. return m.OldGroupBlockList(ctx)
  37074. }
  37075. return nil, fmt.Errorf("unknown Wx field %s", name)
  37076. }
  37077. // SetField sets the value of a field with the given name. It returns an error if
  37078. // the field is not defined in the schema, or if the type mismatched the field
  37079. // type.
  37080. func (m *WxMutation) SetField(name string, value ent.Value) error {
  37081. switch name {
  37082. case wx.FieldCreatedAt:
  37083. v, ok := value.(time.Time)
  37084. if !ok {
  37085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37086. }
  37087. m.SetCreatedAt(v)
  37088. return nil
  37089. case wx.FieldUpdatedAt:
  37090. v, ok := value.(time.Time)
  37091. if !ok {
  37092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37093. }
  37094. m.SetUpdatedAt(v)
  37095. return nil
  37096. case wx.FieldStatus:
  37097. v, ok := value.(uint8)
  37098. if !ok {
  37099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37100. }
  37101. m.SetStatus(v)
  37102. return nil
  37103. case wx.FieldDeletedAt:
  37104. v, ok := value.(time.Time)
  37105. if !ok {
  37106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37107. }
  37108. m.SetDeletedAt(v)
  37109. return nil
  37110. case wx.FieldServerID:
  37111. v, ok := value.(uint64)
  37112. if !ok {
  37113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37114. }
  37115. m.SetServerID(v)
  37116. return nil
  37117. case wx.FieldPort:
  37118. v, ok := value.(string)
  37119. if !ok {
  37120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37121. }
  37122. m.SetPort(v)
  37123. return nil
  37124. case wx.FieldProcessID:
  37125. v, ok := value.(string)
  37126. if !ok {
  37127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37128. }
  37129. m.SetProcessID(v)
  37130. return nil
  37131. case wx.FieldCallback:
  37132. v, ok := value.(string)
  37133. if !ok {
  37134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37135. }
  37136. m.SetCallback(v)
  37137. return nil
  37138. case wx.FieldWxid:
  37139. v, ok := value.(string)
  37140. if !ok {
  37141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37142. }
  37143. m.SetWxid(v)
  37144. return nil
  37145. case wx.FieldAccount:
  37146. v, ok := value.(string)
  37147. if !ok {
  37148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37149. }
  37150. m.SetAccount(v)
  37151. return nil
  37152. case wx.FieldNickname:
  37153. v, ok := value.(string)
  37154. if !ok {
  37155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37156. }
  37157. m.SetNickname(v)
  37158. return nil
  37159. case wx.FieldTel:
  37160. v, ok := value.(string)
  37161. if !ok {
  37162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37163. }
  37164. m.SetTel(v)
  37165. return nil
  37166. case wx.FieldHeadBig:
  37167. v, ok := value.(string)
  37168. if !ok {
  37169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37170. }
  37171. m.SetHeadBig(v)
  37172. return nil
  37173. case wx.FieldOrganizationID:
  37174. v, ok := value.(uint64)
  37175. if !ok {
  37176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37177. }
  37178. m.SetOrganizationID(v)
  37179. return nil
  37180. case wx.FieldAgentID:
  37181. v, ok := value.(uint64)
  37182. if !ok {
  37183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37184. }
  37185. m.SetAgentID(v)
  37186. return nil
  37187. case wx.FieldAPIBase:
  37188. v, ok := value.(string)
  37189. if !ok {
  37190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37191. }
  37192. m.SetAPIBase(v)
  37193. return nil
  37194. case wx.FieldAPIKey:
  37195. v, ok := value.(string)
  37196. if !ok {
  37197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37198. }
  37199. m.SetAPIKey(v)
  37200. return nil
  37201. case wx.FieldAllowList:
  37202. v, ok := value.([]string)
  37203. if !ok {
  37204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37205. }
  37206. m.SetAllowList(v)
  37207. return nil
  37208. case wx.FieldGroupAllowList:
  37209. v, ok := value.([]string)
  37210. if !ok {
  37211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37212. }
  37213. m.SetGroupAllowList(v)
  37214. return nil
  37215. case wx.FieldBlockList:
  37216. v, ok := value.([]string)
  37217. if !ok {
  37218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37219. }
  37220. m.SetBlockList(v)
  37221. return nil
  37222. case wx.FieldGroupBlockList:
  37223. v, ok := value.([]string)
  37224. if !ok {
  37225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37226. }
  37227. m.SetGroupBlockList(v)
  37228. return nil
  37229. }
  37230. return fmt.Errorf("unknown Wx field %s", name)
  37231. }
  37232. // AddedFields returns all numeric fields that were incremented/decremented during
  37233. // this mutation.
  37234. func (m *WxMutation) AddedFields() []string {
  37235. var fields []string
  37236. if m.addstatus != nil {
  37237. fields = append(fields, wx.FieldStatus)
  37238. }
  37239. if m.addorganization_id != nil {
  37240. fields = append(fields, wx.FieldOrganizationID)
  37241. }
  37242. return fields
  37243. }
  37244. // AddedField returns the numeric value that was incremented/decremented on a field
  37245. // with the given name. The second boolean return value indicates that this field
  37246. // was not set, or was not defined in the schema.
  37247. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  37248. switch name {
  37249. case wx.FieldStatus:
  37250. return m.AddedStatus()
  37251. case wx.FieldOrganizationID:
  37252. return m.AddedOrganizationID()
  37253. }
  37254. return nil, false
  37255. }
  37256. // AddField adds the value to the field with the given name. It returns an error if
  37257. // the field is not defined in the schema, or if the type mismatched the field
  37258. // type.
  37259. func (m *WxMutation) AddField(name string, value ent.Value) error {
  37260. switch name {
  37261. case wx.FieldStatus:
  37262. v, ok := value.(int8)
  37263. if !ok {
  37264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37265. }
  37266. m.AddStatus(v)
  37267. return nil
  37268. case wx.FieldOrganizationID:
  37269. v, ok := value.(int64)
  37270. if !ok {
  37271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37272. }
  37273. m.AddOrganizationID(v)
  37274. return nil
  37275. }
  37276. return fmt.Errorf("unknown Wx numeric field %s", name)
  37277. }
  37278. // ClearedFields returns all nullable fields that were cleared during this
  37279. // mutation.
  37280. func (m *WxMutation) ClearedFields() []string {
  37281. var fields []string
  37282. if m.FieldCleared(wx.FieldStatus) {
  37283. fields = append(fields, wx.FieldStatus)
  37284. }
  37285. if m.FieldCleared(wx.FieldDeletedAt) {
  37286. fields = append(fields, wx.FieldDeletedAt)
  37287. }
  37288. if m.FieldCleared(wx.FieldServerID) {
  37289. fields = append(fields, wx.FieldServerID)
  37290. }
  37291. if m.FieldCleared(wx.FieldOrganizationID) {
  37292. fields = append(fields, wx.FieldOrganizationID)
  37293. }
  37294. if m.FieldCleared(wx.FieldAPIBase) {
  37295. fields = append(fields, wx.FieldAPIBase)
  37296. }
  37297. if m.FieldCleared(wx.FieldAPIKey) {
  37298. fields = append(fields, wx.FieldAPIKey)
  37299. }
  37300. return fields
  37301. }
  37302. // FieldCleared returns a boolean indicating if a field with the given name was
  37303. // cleared in this mutation.
  37304. func (m *WxMutation) FieldCleared(name string) bool {
  37305. _, ok := m.clearedFields[name]
  37306. return ok
  37307. }
  37308. // ClearField clears the value of the field with the given name. It returns an
  37309. // error if the field is not defined in the schema.
  37310. func (m *WxMutation) ClearField(name string) error {
  37311. switch name {
  37312. case wx.FieldStatus:
  37313. m.ClearStatus()
  37314. return nil
  37315. case wx.FieldDeletedAt:
  37316. m.ClearDeletedAt()
  37317. return nil
  37318. case wx.FieldServerID:
  37319. m.ClearServerID()
  37320. return nil
  37321. case wx.FieldOrganizationID:
  37322. m.ClearOrganizationID()
  37323. return nil
  37324. case wx.FieldAPIBase:
  37325. m.ClearAPIBase()
  37326. return nil
  37327. case wx.FieldAPIKey:
  37328. m.ClearAPIKey()
  37329. return nil
  37330. }
  37331. return fmt.Errorf("unknown Wx nullable field %s", name)
  37332. }
  37333. // ResetField resets all changes in the mutation for the field with the given name.
  37334. // It returns an error if the field is not defined in the schema.
  37335. func (m *WxMutation) ResetField(name string) error {
  37336. switch name {
  37337. case wx.FieldCreatedAt:
  37338. m.ResetCreatedAt()
  37339. return nil
  37340. case wx.FieldUpdatedAt:
  37341. m.ResetUpdatedAt()
  37342. return nil
  37343. case wx.FieldStatus:
  37344. m.ResetStatus()
  37345. return nil
  37346. case wx.FieldDeletedAt:
  37347. m.ResetDeletedAt()
  37348. return nil
  37349. case wx.FieldServerID:
  37350. m.ResetServerID()
  37351. return nil
  37352. case wx.FieldPort:
  37353. m.ResetPort()
  37354. return nil
  37355. case wx.FieldProcessID:
  37356. m.ResetProcessID()
  37357. return nil
  37358. case wx.FieldCallback:
  37359. m.ResetCallback()
  37360. return nil
  37361. case wx.FieldWxid:
  37362. m.ResetWxid()
  37363. return nil
  37364. case wx.FieldAccount:
  37365. m.ResetAccount()
  37366. return nil
  37367. case wx.FieldNickname:
  37368. m.ResetNickname()
  37369. return nil
  37370. case wx.FieldTel:
  37371. m.ResetTel()
  37372. return nil
  37373. case wx.FieldHeadBig:
  37374. m.ResetHeadBig()
  37375. return nil
  37376. case wx.FieldOrganizationID:
  37377. m.ResetOrganizationID()
  37378. return nil
  37379. case wx.FieldAgentID:
  37380. m.ResetAgentID()
  37381. return nil
  37382. case wx.FieldAPIBase:
  37383. m.ResetAPIBase()
  37384. return nil
  37385. case wx.FieldAPIKey:
  37386. m.ResetAPIKey()
  37387. return nil
  37388. case wx.FieldAllowList:
  37389. m.ResetAllowList()
  37390. return nil
  37391. case wx.FieldGroupAllowList:
  37392. m.ResetGroupAllowList()
  37393. return nil
  37394. case wx.FieldBlockList:
  37395. m.ResetBlockList()
  37396. return nil
  37397. case wx.FieldGroupBlockList:
  37398. m.ResetGroupBlockList()
  37399. return nil
  37400. }
  37401. return fmt.Errorf("unknown Wx field %s", name)
  37402. }
  37403. // AddedEdges returns all edge names that were set/added in this mutation.
  37404. func (m *WxMutation) AddedEdges() []string {
  37405. edges := make([]string, 0, 2)
  37406. if m.server != nil {
  37407. edges = append(edges, wx.EdgeServer)
  37408. }
  37409. if m.agent != nil {
  37410. edges = append(edges, wx.EdgeAgent)
  37411. }
  37412. return edges
  37413. }
  37414. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37415. // name in this mutation.
  37416. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  37417. switch name {
  37418. case wx.EdgeServer:
  37419. if id := m.server; id != nil {
  37420. return []ent.Value{*id}
  37421. }
  37422. case wx.EdgeAgent:
  37423. if id := m.agent; id != nil {
  37424. return []ent.Value{*id}
  37425. }
  37426. }
  37427. return nil
  37428. }
  37429. // RemovedEdges returns all edge names that were removed in this mutation.
  37430. func (m *WxMutation) RemovedEdges() []string {
  37431. edges := make([]string, 0, 2)
  37432. return edges
  37433. }
  37434. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37435. // the given name in this mutation.
  37436. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  37437. return nil
  37438. }
  37439. // ClearedEdges returns all edge names that were cleared in this mutation.
  37440. func (m *WxMutation) ClearedEdges() []string {
  37441. edges := make([]string, 0, 2)
  37442. if m.clearedserver {
  37443. edges = append(edges, wx.EdgeServer)
  37444. }
  37445. if m.clearedagent {
  37446. edges = append(edges, wx.EdgeAgent)
  37447. }
  37448. return edges
  37449. }
  37450. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37451. // was cleared in this mutation.
  37452. func (m *WxMutation) EdgeCleared(name string) bool {
  37453. switch name {
  37454. case wx.EdgeServer:
  37455. return m.clearedserver
  37456. case wx.EdgeAgent:
  37457. return m.clearedagent
  37458. }
  37459. return false
  37460. }
  37461. // ClearEdge clears the value of the edge with the given name. It returns an error
  37462. // if that edge is not defined in the schema.
  37463. func (m *WxMutation) ClearEdge(name string) error {
  37464. switch name {
  37465. case wx.EdgeServer:
  37466. m.ClearServer()
  37467. return nil
  37468. case wx.EdgeAgent:
  37469. m.ClearAgent()
  37470. return nil
  37471. }
  37472. return fmt.Errorf("unknown Wx unique edge %s", name)
  37473. }
  37474. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37475. // It returns an error if the edge is not defined in the schema.
  37476. func (m *WxMutation) ResetEdge(name string) error {
  37477. switch name {
  37478. case wx.EdgeServer:
  37479. m.ResetServer()
  37480. return nil
  37481. case wx.EdgeAgent:
  37482. m.ResetAgent()
  37483. return nil
  37484. }
  37485. return fmt.Errorf("unknown Wx edge %s", name)
  37486. }
  37487. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  37488. type WxCardMutation struct {
  37489. config
  37490. op Op
  37491. typ string
  37492. id *uint64
  37493. created_at *time.Time
  37494. updated_at *time.Time
  37495. deleted_at *time.Time
  37496. user_id *uint64
  37497. adduser_id *int64
  37498. wx_user_id *uint64
  37499. addwx_user_id *int64
  37500. avatar *string
  37501. logo *string
  37502. name *string
  37503. company *string
  37504. address *string
  37505. phone *string
  37506. official_account *string
  37507. wechat_account *string
  37508. email *string
  37509. api_base *string
  37510. api_key *string
  37511. ai_info *string
  37512. intro *string
  37513. clearedFields map[string]struct{}
  37514. done bool
  37515. oldValue func(context.Context) (*WxCard, error)
  37516. predicates []predicate.WxCard
  37517. }
  37518. var _ ent.Mutation = (*WxCardMutation)(nil)
  37519. // wxcardOption allows management of the mutation configuration using functional options.
  37520. type wxcardOption func(*WxCardMutation)
  37521. // newWxCardMutation creates new mutation for the WxCard entity.
  37522. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  37523. m := &WxCardMutation{
  37524. config: c,
  37525. op: op,
  37526. typ: TypeWxCard,
  37527. clearedFields: make(map[string]struct{}),
  37528. }
  37529. for _, opt := range opts {
  37530. opt(m)
  37531. }
  37532. return m
  37533. }
  37534. // withWxCardID sets the ID field of the mutation.
  37535. func withWxCardID(id uint64) wxcardOption {
  37536. return func(m *WxCardMutation) {
  37537. var (
  37538. err error
  37539. once sync.Once
  37540. value *WxCard
  37541. )
  37542. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  37543. once.Do(func() {
  37544. if m.done {
  37545. err = errors.New("querying old values post mutation is not allowed")
  37546. } else {
  37547. value, err = m.Client().WxCard.Get(ctx, id)
  37548. }
  37549. })
  37550. return value, err
  37551. }
  37552. m.id = &id
  37553. }
  37554. }
  37555. // withWxCard sets the old WxCard of the mutation.
  37556. func withWxCard(node *WxCard) wxcardOption {
  37557. return func(m *WxCardMutation) {
  37558. m.oldValue = func(context.Context) (*WxCard, error) {
  37559. return node, nil
  37560. }
  37561. m.id = &node.ID
  37562. }
  37563. }
  37564. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37565. // executed in a transaction (ent.Tx), a transactional client is returned.
  37566. func (m WxCardMutation) Client() *Client {
  37567. client := &Client{config: m.config}
  37568. client.init()
  37569. return client
  37570. }
  37571. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37572. // it returns an error otherwise.
  37573. func (m WxCardMutation) Tx() (*Tx, error) {
  37574. if _, ok := m.driver.(*txDriver); !ok {
  37575. return nil, errors.New("ent: mutation is not running in a transaction")
  37576. }
  37577. tx := &Tx{config: m.config}
  37578. tx.init()
  37579. return tx, nil
  37580. }
  37581. // SetID sets the value of the id field. Note that this
  37582. // operation is only accepted on creation of WxCard entities.
  37583. func (m *WxCardMutation) SetID(id uint64) {
  37584. m.id = &id
  37585. }
  37586. // ID returns the ID value in the mutation. Note that the ID is only available
  37587. // if it was provided to the builder or after it was returned from the database.
  37588. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  37589. if m.id == nil {
  37590. return
  37591. }
  37592. return *m.id, true
  37593. }
  37594. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37595. // That means, if the mutation is applied within a transaction with an isolation level such
  37596. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37597. // or updated by the mutation.
  37598. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  37599. switch {
  37600. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37601. id, exists := m.ID()
  37602. if exists {
  37603. return []uint64{id}, nil
  37604. }
  37605. fallthrough
  37606. case m.op.Is(OpUpdate | OpDelete):
  37607. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  37608. default:
  37609. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37610. }
  37611. }
  37612. // SetCreatedAt sets the "created_at" field.
  37613. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  37614. m.created_at = &t
  37615. }
  37616. // CreatedAt returns the value of the "created_at" field in the mutation.
  37617. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  37618. v := m.created_at
  37619. if v == nil {
  37620. return
  37621. }
  37622. return *v, true
  37623. }
  37624. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  37625. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37627. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37628. if !m.op.Is(OpUpdateOne) {
  37629. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37630. }
  37631. if m.id == nil || m.oldValue == nil {
  37632. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37633. }
  37634. oldValue, err := m.oldValue(ctx)
  37635. if err != nil {
  37636. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37637. }
  37638. return oldValue.CreatedAt, nil
  37639. }
  37640. // ResetCreatedAt resets all changes to the "created_at" field.
  37641. func (m *WxCardMutation) ResetCreatedAt() {
  37642. m.created_at = nil
  37643. }
  37644. // SetUpdatedAt sets the "updated_at" field.
  37645. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  37646. m.updated_at = &t
  37647. }
  37648. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37649. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  37650. v := m.updated_at
  37651. if v == nil {
  37652. return
  37653. }
  37654. return *v, true
  37655. }
  37656. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  37657. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37659. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37660. if !m.op.Is(OpUpdateOne) {
  37661. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37662. }
  37663. if m.id == nil || m.oldValue == nil {
  37664. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37665. }
  37666. oldValue, err := m.oldValue(ctx)
  37667. if err != nil {
  37668. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37669. }
  37670. return oldValue.UpdatedAt, nil
  37671. }
  37672. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37673. func (m *WxCardMutation) ResetUpdatedAt() {
  37674. m.updated_at = nil
  37675. }
  37676. // SetDeletedAt sets the "deleted_at" field.
  37677. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  37678. m.deleted_at = &t
  37679. }
  37680. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37681. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  37682. v := m.deleted_at
  37683. if v == nil {
  37684. return
  37685. }
  37686. return *v, true
  37687. }
  37688. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  37689. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37691. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37692. if !m.op.Is(OpUpdateOne) {
  37693. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37694. }
  37695. if m.id == nil || m.oldValue == nil {
  37696. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37697. }
  37698. oldValue, err := m.oldValue(ctx)
  37699. if err != nil {
  37700. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37701. }
  37702. return oldValue.DeletedAt, nil
  37703. }
  37704. // ClearDeletedAt clears the value of the "deleted_at" field.
  37705. func (m *WxCardMutation) ClearDeletedAt() {
  37706. m.deleted_at = nil
  37707. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  37708. }
  37709. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37710. func (m *WxCardMutation) DeletedAtCleared() bool {
  37711. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  37712. return ok
  37713. }
  37714. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37715. func (m *WxCardMutation) ResetDeletedAt() {
  37716. m.deleted_at = nil
  37717. delete(m.clearedFields, wxcard.FieldDeletedAt)
  37718. }
  37719. // SetUserID sets the "user_id" field.
  37720. func (m *WxCardMutation) SetUserID(u uint64) {
  37721. m.user_id = &u
  37722. m.adduser_id = nil
  37723. }
  37724. // UserID returns the value of the "user_id" field in the mutation.
  37725. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  37726. v := m.user_id
  37727. if v == nil {
  37728. return
  37729. }
  37730. return *v, true
  37731. }
  37732. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  37733. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37735. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  37736. if !m.op.Is(OpUpdateOne) {
  37737. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  37738. }
  37739. if m.id == nil || m.oldValue == nil {
  37740. return v, errors.New("OldUserID requires an ID field in the mutation")
  37741. }
  37742. oldValue, err := m.oldValue(ctx)
  37743. if err != nil {
  37744. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  37745. }
  37746. return oldValue.UserID, nil
  37747. }
  37748. // AddUserID adds u to the "user_id" field.
  37749. func (m *WxCardMutation) AddUserID(u int64) {
  37750. if m.adduser_id != nil {
  37751. *m.adduser_id += u
  37752. } else {
  37753. m.adduser_id = &u
  37754. }
  37755. }
  37756. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  37757. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  37758. v := m.adduser_id
  37759. if v == nil {
  37760. return
  37761. }
  37762. return *v, true
  37763. }
  37764. // ClearUserID clears the value of the "user_id" field.
  37765. func (m *WxCardMutation) ClearUserID() {
  37766. m.user_id = nil
  37767. m.adduser_id = nil
  37768. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  37769. }
  37770. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  37771. func (m *WxCardMutation) UserIDCleared() bool {
  37772. _, ok := m.clearedFields[wxcard.FieldUserID]
  37773. return ok
  37774. }
  37775. // ResetUserID resets all changes to the "user_id" field.
  37776. func (m *WxCardMutation) ResetUserID() {
  37777. m.user_id = nil
  37778. m.adduser_id = nil
  37779. delete(m.clearedFields, wxcard.FieldUserID)
  37780. }
  37781. // SetWxUserID sets the "wx_user_id" field.
  37782. func (m *WxCardMutation) SetWxUserID(u uint64) {
  37783. m.wx_user_id = &u
  37784. m.addwx_user_id = nil
  37785. }
  37786. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  37787. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  37788. v := m.wx_user_id
  37789. if v == nil {
  37790. return
  37791. }
  37792. return *v, true
  37793. }
  37794. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  37795. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37797. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  37798. if !m.op.Is(OpUpdateOne) {
  37799. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  37800. }
  37801. if m.id == nil || m.oldValue == nil {
  37802. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  37803. }
  37804. oldValue, err := m.oldValue(ctx)
  37805. if err != nil {
  37806. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  37807. }
  37808. return oldValue.WxUserID, nil
  37809. }
  37810. // AddWxUserID adds u to the "wx_user_id" field.
  37811. func (m *WxCardMutation) AddWxUserID(u int64) {
  37812. if m.addwx_user_id != nil {
  37813. *m.addwx_user_id += u
  37814. } else {
  37815. m.addwx_user_id = &u
  37816. }
  37817. }
  37818. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  37819. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  37820. v := m.addwx_user_id
  37821. if v == nil {
  37822. return
  37823. }
  37824. return *v, true
  37825. }
  37826. // ClearWxUserID clears the value of the "wx_user_id" field.
  37827. func (m *WxCardMutation) ClearWxUserID() {
  37828. m.wx_user_id = nil
  37829. m.addwx_user_id = nil
  37830. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  37831. }
  37832. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  37833. func (m *WxCardMutation) WxUserIDCleared() bool {
  37834. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  37835. return ok
  37836. }
  37837. // ResetWxUserID resets all changes to the "wx_user_id" field.
  37838. func (m *WxCardMutation) ResetWxUserID() {
  37839. m.wx_user_id = nil
  37840. m.addwx_user_id = nil
  37841. delete(m.clearedFields, wxcard.FieldWxUserID)
  37842. }
  37843. // SetAvatar sets the "avatar" field.
  37844. func (m *WxCardMutation) SetAvatar(s string) {
  37845. m.avatar = &s
  37846. }
  37847. // Avatar returns the value of the "avatar" field in the mutation.
  37848. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  37849. v := m.avatar
  37850. if v == nil {
  37851. return
  37852. }
  37853. return *v, true
  37854. }
  37855. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  37856. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37858. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37859. if !m.op.Is(OpUpdateOne) {
  37860. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37861. }
  37862. if m.id == nil || m.oldValue == nil {
  37863. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37864. }
  37865. oldValue, err := m.oldValue(ctx)
  37866. if err != nil {
  37867. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37868. }
  37869. return oldValue.Avatar, nil
  37870. }
  37871. // ResetAvatar resets all changes to the "avatar" field.
  37872. func (m *WxCardMutation) ResetAvatar() {
  37873. m.avatar = nil
  37874. }
  37875. // SetLogo sets the "logo" field.
  37876. func (m *WxCardMutation) SetLogo(s string) {
  37877. m.logo = &s
  37878. }
  37879. // Logo returns the value of the "logo" field in the mutation.
  37880. func (m *WxCardMutation) Logo() (r string, exists bool) {
  37881. v := m.logo
  37882. if v == nil {
  37883. return
  37884. }
  37885. return *v, true
  37886. }
  37887. // OldLogo returns the old "logo" field's value of the WxCard entity.
  37888. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37890. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  37891. if !m.op.Is(OpUpdateOne) {
  37892. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  37893. }
  37894. if m.id == nil || m.oldValue == nil {
  37895. return v, errors.New("OldLogo requires an ID field in the mutation")
  37896. }
  37897. oldValue, err := m.oldValue(ctx)
  37898. if err != nil {
  37899. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  37900. }
  37901. return oldValue.Logo, nil
  37902. }
  37903. // ResetLogo resets all changes to the "logo" field.
  37904. func (m *WxCardMutation) ResetLogo() {
  37905. m.logo = nil
  37906. }
  37907. // SetName sets the "name" field.
  37908. func (m *WxCardMutation) SetName(s string) {
  37909. m.name = &s
  37910. }
  37911. // Name returns the value of the "name" field in the mutation.
  37912. func (m *WxCardMutation) Name() (r string, exists bool) {
  37913. v := m.name
  37914. if v == nil {
  37915. return
  37916. }
  37917. return *v, true
  37918. }
  37919. // OldName returns the old "name" field's value of the WxCard entity.
  37920. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37922. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  37923. if !m.op.Is(OpUpdateOne) {
  37924. return v, errors.New("OldName is only allowed on UpdateOne operations")
  37925. }
  37926. if m.id == nil || m.oldValue == nil {
  37927. return v, errors.New("OldName requires an ID field in the mutation")
  37928. }
  37929. oldValue, err := m.oldValue(ctx)
  37930. if err != nil {
  37931. return v, fmt.Errorf("querying old value for OldName: %w", err)
  37932. }
  37933. return oldValue.Name, nil
  37934. }
  37935. // ResetName resets all changes to the "name" field.
  37936. func (m *WxCardMutation) ResetName() {
  37937. m.name = nil
  37938. }
  37939. // SetCompany sets the "company" field.
  37940. func (m *WxCardMutation) SetCompany(s string) {
  37941. m.company = &s
  37942. }
  37943. // Company returns the value of the "company" field in the mutation.
  37944. func (m *WxCardMutation) Company() (r string, exists bool) {
  37945. v := m.company
  37946. if v == nil {
  37947. return
  37948. }
  37949. return *v, true
  37950. }
  37951. // OldCompany returns the old "company" field's value of the WxCard entity.
  37952. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37954. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  37955. if !m.op.Is(OpUpdateOne) {
  37956. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  37957. }
  37958. if m.id == nil || m.oldValue == nil {
  37959. return v, errors.New("OldCompany requires an ID field in the mutation")
  37960. }
  37961. oldValue, err := m.oldValue(ctx)
  37962. if err != nil {
  37963. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  37964. }
  37965. return oldValue.Company, nil
  37966. }
  37967. // ResetCompany resets all changes to the "company" field.
  37968. func (m *WxCardMutation) ResetCompany() {
  37969. m.company = nil
  37970. }
  37971. // SetAddress sets the "address" field.
  37972. func (m *WxCardMutation) SetAddress(s string) {
  37973. m.address = &s
  37974. }
  37975. // Address returns the value of the "address" field in the mutation.
  37976. func (m *WxCardMutation) Address() (r string, exists bool) {
  37977. v := m.address
  37978. if v == nil {
  37979. return
  37980. }
  37981. return *v, true
  37982. }
  37983. // OldAddress returns the old "address" field's value of the WxCard entity.
  37984. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37986. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  37987. if !m.op.Is(OpUpdateOne) {
  37988. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  37989. }
  37990. if m.id == nil || m.oldValue == nil {
  37991. return v, errors.New("OldAddress requires an ID field in the mutation")
  37992. }
  37993. oldValue, err := m.oldValue(ctx)
  37994. if err != nil {
  37995. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  37996. }
  37997. return oldValue.Address, nil
  37998. }
  37999. // ResetAddress resets all changes to the "address" field.
  38000. func (m *WxCardMutation) ResetAddress() {
  38001. m.address = nil
  38002. }
  38003. // SetPhone sets the "phone" field.
  38004. func (m *WxCardMutation) SetPhone(s string) {
  38005. m.phone = &s
  38006. }
  38007. // Phone returns the value of the "phone" field in the mutation.
  38008. func (m *WxCardMutation) Phone() (r string, exists bool) {
  38009. v := m.phone
  38010. if v == nil {
  38011. return
  38012. }
  38013. return *v, true
  38014. }
  38015. // OldPhone returns the old "phone" field's value of the WxCard entity.
  38016. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38018. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  38019. if !m.op.Is(OpUpdateOne) {
  38020. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  38021. }
  38022. if m.id == nil || m.oldValue == nil {
  38023. return v, errors.New("OldPhone requires an ID field in the mutation")
  38024. }
  38025. oldValue, err := m.oldValue(ctx)
  38026. if err != nil {
  38027. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  38028. }
  38029. return oldValue.Phone, nil
  38030. }
  38031. // ResetPhone resets all changes to the "phone" field.
  38032. func (m *WxCardMutation) ResetPhone() {
  38033. m.phone = nil
  38034. }
  38035. // SetOfficialAccount sets the "official_account" field.
  38036. func (m *WxCardMutation) SetOfficialAccount(s string) {
  38037. m.official_account = &s
  38038. }
  38039. // OfficialAccount returns the value of the "official_account" field in the mutation.
  38040. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  38041. v := m.official_account
  38042. if v == nil {
  38043. return
  38044. }
  38045. return *v, true
  38046. }
  38047. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  38048. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38050. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  38051. if !m.op.Is(OpUpdateOne) {
  38052. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  38053. }
  38054. if m.id == nil || m.oldValue == nil {
  38055. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  38056. }
  38057. oldValue, err := m.oldValue(ctx)
  38058. if err != nil {
  38059. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  38060. }
  38061. return oldValue.OfficialAccount, nil
  38062. }
  38063. // ResetOfficialAccount resets all changes to the "official_account" field.
  38064. func (m *WxCardMutation) ResetOfficialAccount() {
  38065. m.official_account = nil
  38066. }
  38067. // SetWechatAccount sets the "wechat_account" field.
  38068. func (m *WxCardMutation) SetWechatAccount(s string) {
  38069. m.wechat_account = &s
  38070. }
  38071. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  38072. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  38073. v := m.wechat_account
  38074. if v == nil {
  38075. return
  38076. }
  38077. return *v, true
  38078. }
  38079. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  38080. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38082. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  38083. if !m.op.Is(OpUpdateOne) {
  38084. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  38085. }
  38086. if m.id == nil || m.oldValue == nil {
  38087. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  38088. }
  38089. oldValue, err := m.oldValue(ctx)
  38090. if err != nil {
  38091. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  38092. }
  38093. return oldValue.WechatAccount, nil
  38094. }
  38095. // ResetWechatAccount resets all changes to the "wechat_account" field.
  38096. func (m *WxCardMutation) ResetWechatAccount() {
  38097. m.wechat_account = nil
  38098. }
  38099. // SetEmail sets the "email" field.
  38100. func (m *WxCardMutation) SetEmail(s string) {
  38101. m.email = &s
  38102. }
  38103. // Email returns the value of the "email" field in the mutation.
  38104. func (m *WxCardMutation) Email() (r string, exists bool) {
  38105. v := m.email
  38106. if v == nil {
  38107. return
  38108. }
  38109. return *v, true
  38110. }
  38111. // OldEmail returns the old "email" field's value of the WxCard entity.
  38112. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38114. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  38115. if !m.op.Is(OpUpdateOne) {
  38116. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  38117. }
  38118. if m.id == nil || m.oldValue == nil {
  38119. return v, errors.New("OldEmail requires an ID field in the mutation")
  38120. }
  38121. oldValue, err := m.oldValue(ctx)
  38122. if err != nil {
  38123. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  38124. }
  38125. return oldValue.Email, nil
  38126. }
  38127. // ClearEmail clears the value of the "email" field.
  38128. func (m *WxCardMutation) ClearEmail() {
  38129. m.email = nil
  38130. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  38131. }
  38132. // EmailCleared returns if the "email" field was cleared in this mutation.
  38133. func (m *WxCardMutation) EmailCleared() bool {
  38134. _, ok := m.clearedFields[wxcard.FieldEmail]
  38135. return ok
  38136. }
  38137. // ResetEmail resets all changes to the "email" field.
  38138. func (m *WxCardMutation) ResetEmail() {
  38139. m.email = nil
  38140. delete(m.clearedFields, wxcard.FieldEmail)
  38141. }
  38142. // SetAPIBase sets the "api_base" field.
  38143. func (m *WxCardMutation) SetAPIBase(s string) {
  38144. m.api_base = &s
  38145. }
  38146. // APIBase returns the value of the "api_base" field in the mutation.
  38147. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  38148. v := m.api_base
  38149. if v == nil {
  38150. return
  38151. }
  38152. return *v, true
  38153. }
  38154. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  38155. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38157. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38158. if !m.op.Is(OpUpdateOne) {
  38159. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38160. }
  38161. if m.id == nil || m.oldValue == nil {
  38162. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38163. }
  38164. oldValue, err := m.oldValue(ctx)
  38165. if err != nil {
  38166. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38167. }
  38168. return oldValue.APIBase, nil
  38169. }
  38170. // ClearAPIBase clears the value of the "api_base" field.
  38171. func (m *WxCardMutation) ClearAPIBase() {
  38172. m.api_base = nil
  38173. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  38174. }
  38175. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38176. func (m *WxCardMutation) APIBaseCleared() bool {
  38177. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  38178. return ok
  38179. }
  38180. // ResetAPIBase resets all changes to the "api_base" field.
  38181. func (m *WxCardMutation) ResetAPIBase() {
  38182. m.api_base = nil
  38183. delete(m.clearedFields, wxcard.FieldAPIBase)
  38184. }
  38185. // SetAPIKey sets the "api_key" field.
  38186. func (m *WxCardMutation) SetAPIKey(s string) {
  38187. m.api_key = &s
  38188. }
  38189. // APIKey returns the value of the "api_key" field in the mutation.
  38190. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  38191. v := m.api_key
  38192. if v == nil {
  38193. return
  38194. }
  38195. return *v, true
  38196. }
  38197. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  38198. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38200. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38201. if !m.op.Is(OpUpdateOne) {
  38202. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38203. }
  38204. if m.id == nil || m.oldValue == nil {
  38205. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38206. }
  38207. oldValue, err := m.oldValue(ctx)
  38208. if err != nil {
  38209. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38210. }
  38211. return oldValue.APIKey, nil
  38212. }
  38213. // ClearAPIKey clears the value of the "api_key" field.
  38214. func (m *WxCardMutation) ClearAPIKey() {
  38215. m.api_key = nil
  38216. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  38217. }
  38218. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38219. func (m *WxCardMutation) APIKeyCleared() bool {
  38220. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  38221. return ok
  38222. }
  38223. // ResetAPIKey resets all changes to the "api_key" field.
  38224. func (m *WxCardMutation) ResetAPIKey() {
  38225. m.api_key = nil
  38226. delete(m.clearedFields, wxcard.FieldAPIKey)
  38227. }
  38228. // SetAiInfo sets the "ai_info" field.
  38229. func (m *WxCardMutation) SetAiInfo(s string) {
  38230. m.ai_info = &s
  38231. }
  38232. // AiInfo returns the value of the "ai_info" field in the mutation.
  38233. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  38234. v := m.ai_info
  38235. if v == nil {
  38236. return
  38237. }
  38238. return *v, true
  38239. }
  38240. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  38241. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38243. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  38244. if !m.op.Is(OpUpdateOne) {
  38245. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  38246. }
  38247. if m.id == nil || m.oldValue == nil {
  38248. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  38249. }
  38250. oldValue, err := m.oldValue(ctx)
  38251. if err != nil {
  38252. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  38253. }
  38254. return oldValue.AiInfo, nil
  38255. }
  38256. // ClearAiInfo clears the value of the "ai_info" field.
  38257. func (m *WxCardMutation) ClearAiInfo() {
  38258. m.ai_info = nil
  38259. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  38260. }
  38261. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  38262. func (m *WxCardMutation) AiInfoCleared() bool {
  38263. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  38264. return ok
  38265. }
  38266. // ResetAiInfo resets all changes to the "ai_info" field.
  38267. func (m *WxCardMutation) ResetAiInfo() {
  38268. m.ai_info = nil
  38269. delete(m.clearedFields, wxcard.FieldAiInfo)
  38270. }
  38271. // SetIntro sets the "intro" field.
  38272. func (m *WxCardMutation) SetIntro(s string) {
  38273. m.intro = &s
  38274. }
  38275. // Intro returns the value of the "intro" field in the mutation.
  38276. func (m *WxCardMutation) Intro() (r string, exists bool) {
  38277. v := m.intro
  38278. if v == nil {
  38279. return
  38280. }
  38281. return *v, true
  38282. }
  38283. // OldIntro returns the old "intro" field's value of the WxCard entity.
  38284. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38286. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  38287. if !m.op.Is(OpUpdateOne) {
  38288. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  38289. }
  38290. if m.id == nil || m.oldValue == nil {
  38291. return v, errors.New("OldIntro requires an ID field in the mutation")
  38292. }
  38293. oldValue, err := m.oldValue(ctx)
  38294. if err != nil {
  38295. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  38296. }
  38297. return oldValue.Intro, nil
  38298. }
  38299. // ClearIntro clears the value of the "intro" field.
  38300. func (m *WxCardMutation) ClearIntro() {
  38301. m.intro = nil
  38302. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  38303. }
  38304. // IntroCleared returns if the "intro" field was cleared in this mutation.
  38305. func (m *WxCardMutation) IntroCleared() bool {
  38306. _, ok := m.clearedFields[wxcard.FieldIntro]
  38307. return ok
  38308. }
  38309. // ResetIntro resets all changes to the "intro" field.
  38310. func (m *WxCardMutation) ResetIntro() {
  38311. m.intro = nil
  38312. delete(m.clearedFields, wxcard.FieldIntro)
  38313. }
  38314. // Where appends a list predicates to the WxCardMutation builder.
  38315. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  38316. m.predicates = append(m.predicates, ps...)
  38317. }
  38318. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  38319. // users can use type-assertion to append predicates that do not depend on any generated package.
  38320. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  38321. p := make([]predicate.WxCard, len(ps))
  38322. for i := range ps {
  38323. p[i] = ps[i]
  38324. }
  38325. m.Where(p...)
  38326. }
  38327. // Op returns the operation name.
  38328. func (m *WxCardMutation) Op() Op {
  38329. return m.op
  38330. }
  38331. // SetOp allows setting the mutation operation.
  38332. func (m *WxCardMutation) SetOp(op Op) {
  38333. m.op = op
  38334. }
  38335. // Type returns the node type of this mutation (WxCard).
  38336. func (m *WxCardMutation) Type() string {
  38337. return m.typ
  38338. }
  38339. // Fields returns all fields that were changed during this mutation. Note that in
  38340. // order to get all numeric fields that were incremented/decremented, call
  38341. // AddedFields().
  38342. func (m *WxCardMutation) Fields() []string {
  38343. fields := make([]string, 0, 18)
  38344. if m.created_at != nil {
  38345. fields = append(fields, wxcard.FieldCreatedAt)
  38346. }
  38347. if m.updated_at != nil {
  38348. fields = append(fields, wxcard.FieldUpdatedAt)
  38349. }
  38350. if m.deleted_at != nil {
  38351. fields = append(fields, wxcard.FieldDeletedAt)
  38352. }
  38353. if m.user_id != nil {
  38354. fields = append(fields, wxcard.FieldUserID)
  38355. }
  38356. if m.wx_user_id != nil {
  38357. fields = append(fields, wxcard.FieldWxUserID)
  38358. }
  38359. if m.avatar != nil {
  38360. fields = append(fields, wxcard.FieldAvatar)
  38361. }
  38362. if m.logo != nil {
  38363. fields = append(fields, wxcard.FieldLogo)
  38364. }
  38365. if m.name != nil {
  38366. fields = append(fields, wxcard.FieldName)
  38367. }
  38368. if m.company != nil {
  38369. fields = append(fields, wxcard.FieldCompany)
  38370. }
  38371. if m.address != nil {
  38372. fields = append(fields, wxcard.FieldAddress)
  38373. }
  38374. if m.phone != nil {
  38375. fields = append(fields, wxcard.FieldPhone)
  38376. }
  38377. if m.official_account != nil {
  38378. fields = append(fields, wxcard.FieldOfficialAccount)
  38379. }
  38380. if m.wechat_account != nil {
  38381. fields = append(fields, wxcard.FieldWechatAccount)
  38382. }
  38383. if m.email != nil {
  38384. fields = append(fields, wxcard.FieldEmail)
  38385. }
  38386. if m.api_base != nil {
  38387. fields = append(fields, wxcard.FieldAPIBase)
  38388. }
  38389. if m.api_key != nil {
  38390. fields = append(fields, wxcard.FieldAPIKey)
  38391. }
  38392. if m.ai_info != nil {
  38393. fields = append(fields, wxcard.FieldAiInfo)
  38394. }
  38395. if m.intro != nil {
  38396. fields = append(fields, wxcard.FieldIntro)
  38397. }
  38398. return fields
  38399. }
  38400. // Field returns the value of a field with the given name. The second boolean
  38401. // return value indicates that this field was not set, or was not defined in the
  38402. // schema.
  38403. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  38404. switch name {
  38405. case wxcard.FieldCreatedAt:
  38406. return m.CreatedAt()
  38407. case wxcard.FieldUpdatedAt:
  38408. return m.UpdatedAt()
  38409. case wxcard.FieldDeletedAt:
  38410. return m.DeletedAt()
  38411. case wxcard.FieldUserID:
  38412. return m.UserID()
  38413. case wxcard.FieldWxUserID:
  38414. return m.WxUserID()
  38415. case wxcard.FieldAvatar:
  38416. return m.Avatar()
  38417. case wxcard.FieldLogo:
  38418. return m.Logo()
  38419. case wxcard.FieldName:
  38420. return m.Name()
  38421. case wxcard.FieldCompany:
  38422. return m.Company()
  38423. case wxcard.FieldAddress:
  38424. return m.Address()
  38425. case wxcard.FieldPhone:
  38426. return m.Phone()
  38427. case wxcard.FieldOfficialAccount:
  38428. return m.OfficialAccount()
  38429. case wxcard.FieldWechatAccount:
  38430. return m.WechatAccount()
  38431. case wxcard.FieldEmail:
  38432. return m.Email()
  38433. case wxcard.FieldAPIBase:
  38434. return m.APIBase()
  38435. case wxcard.FieldAPIKey:
  38436. return m.APIKey()
  38437. case wxcard.FieldAiInfo:
  38438. return m.AiInfo()
  38439. case wxcard.FieldIntro:
  38440. return m.Intro()
  38441. }
  38442. return nil, false
  38443. }
  38444. // OldField returns the old value of the field from the database. An error is
  38445. // returned if the mutation operation is not UpdateOne, or the query to the
  38446. // database failed.
  38447. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38448. switch name {
  38449. case wxcard.FieldCreatedAt:
  38450. return m.OldCreatedAt(ctx)
  38451. case wxcard.FieldUpdatedAt:
  38452. return m.OldUpdatedAt(ctx)
  38453. case wxcard.FieldDeletedAt:
  38454. return m.OldDeletedAt(ctx)
  38455. case wxcard.FieldUserID:
  38456. return m.OldUserID(ctx)
  38457. case wxcard.FieldWxUserID:
  38458. return m.OldWxUserID(ctx)
  38459. case wxcard.FieldAvatar:
  38460. return m.OldAvatar(ctx)
  38461. case wxcard.FieldLogo:
  38462. return m.OldLogo(ctx)
  38463. case wxcard.FieldName:
  38464. return m.OldName(ctx)
  38465. case wxcard.FieldCompany:
  38466. return m.OldCompany(ctx)
  38467. case wxcard.FieldAddress:
  38468. return m.OldAddress(ctx)
  38469. case wxcard.FieldPhone:
  38470. return m.OldPhone(ctx)
  38471. case wxcard.FieldOfficialAccount:
  38472. return m.OldOfficialAccount(ctx)
  38473. case wxcard.FieldWechatAccount:
  38474. return m.OldWechatAccount(ctx)
  38475. case wxcard.FieldEmail:
  38476. return m.OldEmail(ctx)
  38477. case wxcard.FieldAPIBase:
  38478. return m.OldAPIBase(ctx)
  38479. case wxcard.FieldAPIKey:
  38480. return m.OldAPIKey(ctx)
  38481. case wxcard.FieldAiInfo:
  38482. return m.OldAiInfo(ctx)
  38483. case wxcard.FieldIntro:
  38484. return m.OldIntro(ctx)
  38485. }
  38486. return nil, fmt.Errorf("unknown WxCard field %s", name)
  38487. }
  38488. // SetField sets the value of a field with the given name. It returns an error if
  38489. // the field is not defined in the schema, or if the type mismatched the field
  38490. // type.
  38491. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  38492. switch name {
  38493. case wxcard.FieldCreatedAt:
  38494. v, ok := value.(time.Time)
  38495. if !ok {
  38496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38497. }
  38498. m.SetCreatedAt(v)
  38499. return nil
  38500. case wxcard.FieldUpdatedAt:
  38501. v, ok := value.(time.Time)
  38502. if !ok {
  38503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38504. }
  38505. m.SetUpdatedAt(v)
  38506. return nil
  38507. case wxcard.FieldDeletedAt:
  38508. v, ok := value.(time.Time)
  38509. if !ok {
  38510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38511. }
  38512. m.SetDeletedAt(v)
  38513. return nil
  38514. case wxcard.FieldUserID:
  38515. v, ok := value.(uint64)
  38516. if !ok {
  38517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38518. }
  38519. m.SetUserID(v)
  38520. return nil
  38521. case wxcard.FieldWxUserID:
  38522. v, ok := value.(uint64)
  38523. if !ok {
  38524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38525. }
  38526. m.SetWxUserID(v)
  38527. return nil
  38528. case wxcard.FieldAvatar:
  38529. v, ok := value.(string)
  38530. if !ok {
  38531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38532. }
  38533. m.SetAvatar(v)
  38534. return nil
  38535. case wxcard.FieldLogo:
  38536. v, ok := value.(string)
  38537. if !ok {
  38538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38539. }
  38540. m.SetLogo(v)
  38541. return nil
  38542. case wxcard.FieldName:
  38543. v, ok := value.(string)
  38544. if !ok {
  38545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38546. }
  38547. m.SetName(v)
  38548. return nil
  38549. case wxcard.FieldCompany:
  38550. v, ok := value.(string)
  38551. if !ok {
  38552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38553. }
  38554. m.SetCompany(v)
  38555. return nil
  38556. case wxcard.FieldAddress:
  38557. v, ok := value.(string)
  38558. if !ok {
  38559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38560. }
  38561. m.SetAddress(v)
  38562. return nil
  38563. case wxcard.FieldPhone:
  38564. v, ok := value.(string)
  38565. if !ok {
  38566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38567. }
  38568. m.SetPhone(v)
  38569. return nil
  38570. case wxcard.FieldOfficialAccount:
  38571. v, ok := value.(string)
  38572. if !ok {
  38573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38574. }
  38575. m.SetOfficialAccount(v)
  38576. return nil
  38577. case wxcard.FieldWechatAccount:
  38578. v, ok := value.(string)
  38579. if !ok {
  38580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38581. }
  38582. m.SetWechatAccount(v)
  38583. return nil
  38584. case wxcard.FieldEmail:
  38585. v, ok := value.(string)
  38586. if !ok {
  38587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38588. }
  38589. m.SetEmail(v)
  38590. return nil
  38591. case wxcard.FieldAPIBase:
  38592. v, ok := value.(string)
  38593. if !ok {
  38594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38595. }
  38596. m.SetAPIBase(v)
  38597. return nil
  38598. case wxcard.FieldAPIKey:
  38599. v, ok := value.(string)
  38600. if !ok {
  38601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38602. }
  38603. m.SetAPIKey(v)
  38604. return nil
  38605. case wxcard.FieldAiInfo:
  38606. v, ok := value.(string)
  38607. if !ok {
  38608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38609. }
  38610. m.SetAiInfo(v)
  38611. return nil
  38612. case wxcard.FieldIntro:
  38613. v, ok := value.(string)
  38614. if !ok {
  38615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38616. }
  38617. m.SetIntro(v)
  38618. return nil
  38619. }
  38620. return fmt.Errorf("unknown WxCard field %s", name)
  38621. }
  38622. // AddedFields returns all numeric fields that were incremented/decremented during
  38623. // this mutation.
  38624. func (m *WxCardMutation) AddedFields() []string {
  38625. var fields []string
  38626. if m.adduser_id != nil {
  38627. fields = append(fields, wxcard.FieldUserID)
  38628. }
  38629. if m.addwx_user_id != nil {
  38630. fields = append(fields, wxcard.FieldWxUserID)
  38631. }
  38632. return fields
  38633. }
  38634. // AddedField returns the numeric value that was incremented/decremented on a field
  38635. // with the given name. The second boolean return value indicates that this field
  38636. // was not set, or was not defined in the schema.
  38637. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  38638. switch name {
  38639. case wxcard.FieldUserID:
  38640. return m.AddedUserID()
  38641. case wxcard.FieldWxUserID:
  38642. return m.AddedWxUserID()
  38643. }
  38644. return nil, false
  38645. }
  38646. // AddField adds the value to the field with the given name. It returns an error if
  38647. // the field is not defined in the schema, or if the type mismatched the field
  38648. // type.
  38649. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  38650. switch name {
  38651. case wxcard.FieldUserID:
  38652. v, ok := value.(int64)
  38653. if !ok {
  38654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38655. }
  38656. m.AddUserID(v)
  38657. return nil
  38658. case wxcard.FieldWxUserID:
  38659. v, ok := value.(int64)
  38660. if !ok {
  38661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38662. }
  38663. m.AddWxUserID(v)
  38664. return nil
  38665. }
  38666. return fmt.Errorf("unknown WxCard numeric field %s", name)
  38667. }
  38668. // ClearedFields returns all nullable fields that were cleared during this
  38669. // mutation.
  38670. func (m *WxCardMutation) ClearedFields() []string {
  38671. var fields []string
  38672. if m.FieldCleared(wxcard.FieldDeletedAt) {
  38673. fields = append(fields, wxcard.FieldDeletedAt)
  38674. }
  38675. if m.FieldCleared(wxcard.FieldUserID) {
  38676. fields = append(fields, wxcard.FieldUserID)
  38677. }
  38678. if m.FieldCleared(wxcard.FieldWxUserID) {
  38679. fields = append(fields, wxcard.FieldWxUserID)
  38680. }
  38681. if m.FieldCleared(wxcard.FieldEmail) {
  38682. fields = append(fields, wxcard.FieldEmail)
  38683. }
  38684. if m.FieldCleared(wxcard.FieldAPIBase) {
  38685. fields = append(fields, wxcard.FieldAPIBase)
  38686. }
  38687. if m.FieldCleared(wxcard.FieldAPIKey) {
  38688. fields = append(fields, wxcard.FieldAPIKey)
  38689. }
  38690. if m.FieldCleared(wxcard.FieldAiInfo) {
  38691. fields = append(fields, wxcard.FieldAiInfo)
  38692. }
  38693. if m.FieldCleared(wxcard.FieldIntro) {
  38694. fields = append(fields, wxcard.FieldIntro)
  38695. }
  38696. return fields
  38697. }
  38698. // FieldCleared returns a boolean indicating if a field with the given name was
  38699. // cleared in this mutation.
  38700. func (m *WxCardMutation) FieldCleared(name string) bool {
  38701. _, ok := m.clearedFields[name]
  38702. return ok
  38703. }
  38704. // ClearField clears the value of the field with the given name. It returns an
  38705. // error if the field is not defined in the schema.
  38706. func (m *WxCardMutation) ClearField(name string) error {
  38707. switch name {
  38708. case wxcard.FieldDeletedAt:
  38709. m.ClearDeletedAt()
  38710. return nil
  38711. case wxcard.FieldUserID:
  38712. m.ClearUserID()
  38713. return nil
  38714. case wxcard.FieldWxUserID:
  38715. m.ClearWxUserID()
  38716. return nil
  38717. case wxcard.FieldEmail:
  38718. m.ClearEmail()
  38719. return nil
  38720. case wxcard.FieldAPIBase:
  38721. m.ClearAPIBase()
  38722. return nil
  38723. case wxcard.FieldAPIKey:
  38724. m.ClearAPIKey()
  38725. return nil
  38726. case wxcard.FieldAiInfo:
  38727. m.ClearAiInfo()
  38728. return nil
  38729. case wxcard.FieldIntro:
  38730. m.ClearIntro()
  38731. return nil
  38732. }
  38733. return fmt.Errorf("unknown WxCard nullable field %s", name)
  38734. }
  38735. // ResetField resets all changes in the mutation for the field with the given name.
  38736. // It returns an error if the field is not defined in the schema.
  38737. func (m *WxCardMutation) ResetField(name string) error {
  38738. switch name {
  38739. case wxcard.FieldCreatedAt:
  38740. m.ResetCreatedAt()
  38741. return nil
  38742. case wxcard.FieldUpdatedAt:
  38743. m.ResetUpdatedAt()
  38744. return nil
  38745. case wxcard.FieldDeletedAt:
  38746. m.ResetDeletedAt()
  38747. return nil
  38748. case wxcard.FieldUserID:
  38749. m.ResetUserID()
  38750. return nil
  38751. case wxcard.FieldWxUserID:
  38752. m.ResetWxUserID()
  38753. return nil
  38754. case wxcard.FieldAvatar:
  38755. m.ResetAvatar()
  38756. return nil
  38757. case wxcard.FieldLogo:
  38758. m.ResetLogo()
  38759. return nil
  38760. case wxcard.FieldName:
  38761. m.ResetName()
  38762. return nil
  38763. case wxcard.FieldCompany:
  38764. m.ResetCompany()
  38765. return nil
  38766. case wxcard.FieldAddress:
  38767. m.ResetAddress()
  38768. return nil
  38769. case wxcard.FieldPhone:
  38770. m.ResetPhone()
  38771. return nil
  38772. case wxcard.FieldOfficialAccount:
  38773. m.ResetOfficialAccount()
  38774. return nil
  38775. case wxcard.FieldWechatAccount:
  38776. m.ResetWechatAccount()
  38777. return nil
  38778. case wxcard.FieldEmail:
  38779. m.ResetEmail()
  38780. return nil
  38781. case wxcard.FieldAPIBase:
  38782. m.ResetAPIBase()
  38783. return nil
  38784. case wxcard.FieldAPIKey:
  38785. m.ResetAPIKey()
  38786. return nil
  38787. case wxcard.FieldAiInfo:
  38788. m.ResetAiInfo()
  38789. return nil
  38790. case wxcard.FieldIntro:
  38791. m.ResetIntro()
  38792. return nil
  38793. }
  38794. return fmt.Errorf("unknown WxCard field %s", name)
  38795. }
  38796. // AddedEdges returns all edge names that were set/added in this mutation.
  38797. func (m *WxCardMutation) AddedEdges() []string {
  38798. edges := make([]string, 0, 0)
  38799. return edges
  38800. }
  38801. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38802. // name in this mutation.
  38803. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  38804. return nil
  38805. }
  38806. // RemovedEdges returns all edge names that were removed in this mutation.
  38807. func (m *WxCardMutation) RemovedEdges() []string {
  38808. edges := make([]string, 0, 0)
  38809. return edges
  38810. }
  38811. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38812. // the given name in this mutation.
  38813. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  38814. return nil
  38815. }
  38816. // ClearedEdges returns all edge names that were cleared in this mutation.
  38817. func (m *WxCardMutation) ClearedEdges() []string {
  38818. edges := make([]string, 0, 0)
  38819. return edges
  38820. }
  38821. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38822. // was cleared in this mutation.
  38823. func (m *WxCardMutation) EdgeCleared(name string) bool {
  38824. return false
  38825. }
  38826. // ClearEdge clears the value of the edge with the given name. It returns an error
  38827. // if that edge is not defined in the schema.
  38828. func (m *WxCardMutation) ClearEdge(name string) error {
  38829. return fmt.Errorf("unknown WxCard unique edge %s", name)
  38830. }
  38831. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38832. // It returns an error if the edge is not defined in the schema.
  38833. func (m *WxCardMutation) ResetEdge(name string) error {
  38834. return fmt.Errorf("unknown WxCard edge %s", name)
  38835. }
  38836. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  38837. type WxCardUserMutation struct {
  38838. config
  38839. op Op
  38840. typ string
  38841. id *uint64
  38842. created_at *time.Time
  38843. updated_at *time.Time
  38844. deleted_at *time.Time
  38845. wxid *string
  38846. account *string
  38847. avatar *string
  38848. nickname *string
  38849. remark *string
  38850. phone *string
  38851. open_id *string
  38852. union_id *string
  38853. session_key *string
  38854. is_vip *int
  38855. addis_vip *int
  38856. clearedFields map[string]struct{}
  38857. done bool
  38858. oldValue func(context.Context) (*WxCardUser, error)
  38859. predicates []predicate.WxCardUser
  38860. }
  38861. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  38862. // wxcarduserOption allows management of the mutation configuration using functional options.
  38863. type wxcarduserOption func(*WxCardUserMutation)
  38864. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  38865. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  38866. m := &WxCardUserMutation{
  38867. config: c,
  38868. op: op,
  38869. typ: TypeWxCardUser,
  38870. clearedFields: make(map[string]struct{}),
  38871. }
  38872. for _, opt := range opts {
  38873. opt(m)
  38874. }
  38875. return m
  38876. }
  38877. // withWxCardUserID sets the ID field of the mutation.
  38878. func withWxCardUserID(id uint64) wxcarduserOption {
  38879. return func(m *WxCardUserMutation) {
  38880. var (
  38881. err error
  38882. once sync.Once
  38883. value *WxCardUser
  38884. )
  38885. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  38886. once.Do(func() {
  38887. if m.done {
  38888. err = errors.New("querying old values post mutation is not allowed")
  38889. } else {
  38890. value, err = m.Client().WxCardUser.Get(ctx, id)
  38891. }
  38892. })
  38893. return value, err
  38894. }
  38895. m.id = &id
  38896. }
  38897. }
  38898. // withWxCardUser sets the old WxCardUser of the mutation.
  38899. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  38900. return func(m *WxCardUserMutation) {
  38901. m.oldValue = func(context.Context) (*WxCardUser, error) {
  38902. return node, nil
  38903. }
  38904. m.id = &node.ID
  38905. }
  38906. }
  38907. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38908. // executed in a transaction (ent.Tx), a transactional client is returned.
  38909. func (m WxCardUserMutation) Client() *Client {
  38910. client := &Client{config: m.config}
  38911. client.init()
  38912. return client
  38913. }
  38914. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38915. // it returns an error otherwise.
  38916. func (m WxCardUserMutation) Tx() (*Tx, error) {
  38917. if _, ok := m.driver.(*txDriver); !ok {
  38918. return nil, errors.New("ent: mutation is not running in a transaction")
  38919. }
  38920. tx := &Tx{config: m.config}
  38921. tx.init()
  38922. return tx, nil
  38923. }
  38924. // SetID sets the value of the id field. Note that this
  38925. // operation is only accepted on creation of WxCardUser entities.
  38926. func (m *WxCardUserMutation) SetID(id uint64) {
  38927. m.id = &id
  38928. }
  38929. // ID returns the ID value in the mutation. Note that the ID is only available
  38930. // if it was provided to the builder or after it was returned from the database.
  38931. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  38932. if m.id == nil {
  38933. return
  38934. }
  38935. return *m.id, true
  38936. }
  38937. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38938. // That means, if the mutation is applied within a transaction with an isolation level such
  38939. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38940. // or updated by the mutation.
  38941. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  38942. switch {
  38943. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38944. id, exists := m.ID()
  38945. if exists {
  38946. return []uint64{id}, nil
  38947. }
  38948. fallthrough
  38949. case m.op.Is(OpUpdate | OpDelete):
  38950. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  38951. default:
  38952. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38953. }
  38954. }
  38955. // SetCreatedAt sets the "created_at" field.
  38956. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  38957. m.created_at = &t
  38958. }
  38959. // CreatedAt returns the value of the "created_at" field in the mutation.
  38960. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  38961. v := m.created_at
  38962. if v == nil {
  38963. return
  38964. }
  38965. return *v, true
  38966. }
  38967. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  38968. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38970. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38971. if !m.op.Is(OpUpdateOne) {
  38972. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38973. }
  38974. if m.id == nil || m.oldValue == nil {
  38975. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38976. }
  38977. oldValue, err := m.oldValue(ctx)
  38978. if err != nil {
  38979. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38980. }
  38981. return oldValue.CreatedAt, nil
  38982. }
  38983. // ResetCreatedAt resets all changes to the "created_at" field.
  38984. func (m *WxCardUserMutation) ResetCreatedAt() {
  38985. m.created_at = nil
  38986. }
  38987. // SetUpdatedAt sets the "updated_at" field.
  38988. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  38989. m.updated_at = &t
  38990. }
  38991. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38992. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  38993. v := m.updated_at
  38994. if v == nil {
  38995. return
  38996. }
  38997. return *v, true
  38998. }
  38999. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  39000. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39002. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39003. if !m.op.Is(OpUpdateOne) {
  39004. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39005. }
  39006. if m.id == nil || m.oldValue == nil {
  39007. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39008. }
  39009. oldValue, err := m.oldValue(ctx)
  39010. if err != nil {
  39011. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39012. }
  39013. return oldValue.UpdatedAt, nil
  39014. }
  39015. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39016. func (m *WxCardUserMutation) ResetUpdatedAt() {
  39017. m.updated_at = nil
  39018. }
  39019. // SetDeletedAt sets the "deleted_at" field.
  39020. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  39021. m.deleted_at = &t
  39022. }
  39023. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39024. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  39025. v := m.deleted_at
  39026. if v == nil {
  39027. return
  39028. }
  39029. return *v, true
  39030. }
  39031. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  39032. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39034. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39035. if !m.op.Is(OpUpdateOne) {
  39036. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39037. }
  39038. if m.id == nil || m.oldValue == nil {
  39039. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39040. }
  39041. oldValue, err := m.oldValue(ctx)
  39042. if err != nil {
  39043. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39044. }
  39045. return oldValue.DeletedAt, nil
  39046. }
  39047. // ClearDeletedAt clears the value of the "deleted_at" field.
  39048. func (m *WxCardUserMutation) ClearDeletedAt() {
  39049. m.deleted_at = nil
  39050. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  39051. }
  39052. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39053. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  39054. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  39055. return ok
  39056. }
  39057. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39058. func (m *WxCardUserMutation) ResetDeletedAt() {
  39059. m.deleted_at = nil
  39060. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  39061. }
  39062. // SetWxid sets the "wxid" field.
  39063. func (m *WxCardUserMutation) SetWxid(s string) {
  39064. m.wxid = &s
  39065. }
  39066. // Wxid returns the value of the "wxid" field in the mutation.
  39067. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  39068. v := m.wxid
  39069. if v == nil {
  39070. return
  39071. }
  39072. return *v, true
  39073. }
  39074. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  39075. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39077. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  39078. if !m.op.Is(OpUpdateOne) {
  39079. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39080. }
  39081. if m.id == nil || m.oldValue == nil {
  39082. return v, errors.New("OldWxid requires an ID field in the mutation")
  39083. }
  39084. oldValue, err := m.oldValue(ctx)
  39085. if err != nil {
  39086. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39087. }
  39088. return oldValue.Wxid, nil
  39089. }
  39090. // ResetWxid resets all changes to the "wxid" field.
  39091. func (m *WxCardUserMutation) ResetWxid() {
  39092. m.wxid = nil
  39093. }
  39094. // SetAccount sets the "account" field.
  39095. func (m *WxCardUserMutation) SetAccount(s string) {
  39096. m.account = &s
  39097. }
  39098. // Account returns the value of the "account" field in the mutation.
  39099. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  39100. v := m.account
  39101. if v == nil {
  39102. return
  39103. }
  39104. return *v, true
  39105. }
  39106. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  39107. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39109. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  39110. if !m.op.Is(OpUpdateOne) {
  39111. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  39112. }
  39113. if m.id == nil || m.oldValue == nil {
  39114. return v, errors.New("OldAccount requires an ID field in the mutation")
  39115. }
  39116. oldValue, err := m.oldValue(ctx)
  39117. if err != nil {
  39118. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  39119. }
  39120. return oldValue.Account, nil
  39121. }
  39122. // ResetAccount resets all changes to the "account" field.
  39123. func (m *WxCardUserMutation) ResetAccount() {
  39124. m.account = nil
  39125. }
  39126. // SetAvatar sets the "avatar" field.
  39127. func (m *WxCardUserMutation) SetAvatar(s string) {
  39128. m.avatar = &s
  39129. }
  39130. // Avatar returns the value of the "avatar" field in the mutation.
  39131. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  39132. v := m.avatar
  39133. if v == nil {
  39134. return
  39135. }
  39136. return *v, true
  39137. }
  39138. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  39139. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39141. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39142. if !m.op.Is(OpUpdateOne) {
  39143. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39144. }
  39145. if m.id == nil || m.oldValue == nil {
  39146. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39147. }
  39148. oldValue, err := m.oldValue(ctx)
  39149. if err != nil {
  39150. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39151. }
  39152. return oldValue.Avatar, nil
  39153. }
  39154. // ResetAvatar resets all changes to the "avatar" field.
  39155. func (m *WxCardUserMutation) ResetAvatar() {
  39156. m.avatar = nil
  39157. }
  39158. // SetNickname sets the "nickname" field.
  39159. func (m *WxCardUserMutation) SetNickname(s string) {
  39160. m.nickname = &s
  39161. }
  39162. // Nickname returns the value of the "nickname" field in the mutation.
  39163. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  39164. v := m.nickname
  39165. if v == nil {
  39166. return
  39167. }
  39168. return *v, true
  39169. }
  39170. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  39171. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39173. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  39174. if !m.op.Is(OpUpdateOne) {
  39175. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39176. }
  39177. if m.id == nil || m.oldValue == nil {
  39178. return v, errors.New("OldNickname requires an ID field in the mutation")
  39179. }
  39180. oldValue, err := m.oldValue(ctx)
  39181. if err != nil {
  39182. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39183. }
  39184. return oldValue.Nickname, nil
  39185. }
  39186. // ResetNickname resets all changes to the "nickname" field.
  39187. func (m *WxCardUserMutation) ResetNickname() {
  39188. m.nickname = nil
  39189. }
  39190. // SetRemark sets the "remark" field.
  39191. func (m *WxCardUserMutation) SetRemark(s string) {
  39192. m.remark = &s
  39193. }
  39194. // Remark returns the value of the "remark" field in the mutation.
  39195. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  39196. v := m.remark
  39197. if v == nil {
  39198. return
  39199. }
  39200. return *v, true
  39201. }
  39202. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  39203. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39205. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  39206. if !m.op.Is(OpUpdateOne) {
  39207. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  39208. }
  39209. if m.id == nil || m.oldValue == nil {
  39210. return v, errors.New("OldRemark requires an ID field in the mutation")
  39211. }
  39212. oldValue, err := m.oldValue(ctx)
  39213. if err != nil {
  39214. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  39215. }
  39216. return oldValue.Remark, nil
  39217. }
  39218. // ResetRemark resets all changes to the "remark" field.
  39219. func (m *WxCardUserMutation) ResetRemark() {
  39220. m.remark = nil
  39221. }
  39222. // SetPhone sets the "phone" field.
  39223. func (m *WxCardUserMutation) SetPhone(s string) {
  39224. m.phone = &s
  39225. }
  39226. // Phone returns the value of the "phone" field in the mutation.
  39227. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  39228. v := m.phone
  39229. if v == nil {
  39230. return
  39231. }
  39232. return *v, true
  39233. }
  39234. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  39235. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39237. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  39238. if !m.op.Is(OpUpdateOne) {
  39239. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39240. }
  39241. if m.id == nil || m.oldValue == nil {
  39242. return v, errors.New("OldPhone requires an ID field in the mutation")
  39243. }
  39244. oldValue, err := m.oldValue(ctx)
  39245. if err != nil {
  39246. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39247. }
  39248. return oldValue.Phone, nil
  39249. }
  39250. // ResetPhone resets all changes to the "phone" field.
  39251. func (m *WxCardUserMutation) ResetPhone() {
  39252. m.phone = nil
  39253. }
  39254. // SetOpenID sets the "open_id" field.
  39255. func (m *WxCardUserMutation) SetOpenID(s string) {
  39256. m.open_id = &s
  39257. }
  39258. // OpenID returns the value of the "open_id" field in the mutation.
  39259. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  39260. v := m.open_id
  39261. if v == nil {
  39262. return
  39263. }
  39264. return *v, true
  39265. }
  39266. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  39267. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39269. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  39270. if !m.op.Is(OpUpdateOne) {
  39271. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  39272. }
  39273. if m.id == nil || m.oldValue == nil {
  39274. return v, errors.New("OldOpenID requires an ID field in the mutation")
  39275. }
  39276. oldValue, err := m.oldValue(ctx)
  39277. if err != nil {
  39278. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  39279. }
  39280. return oldValue.OpenID, nil
  39281. }
  39282. // ResetOpenID resets all changes to the "open_id" field.
  39283. func (m *WxCardUserMutation) ResetOpenID() {
  39284. m.open_id = nil
  39285. }
  39286. // SetUnionID sets the "union_id" field.
  39287. func (m *WxCardUserMutation) SetUnionID(s string) {
  39288. m.union_id = &s
  39289. }
  39290. // UnionID returns the value of the "union_id" field in the mutation.
  39291. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  39292. v := m.union_id
  39293. if v == nil {
  39294. return
  39295. }
  39296. return *v, true
  39297. }
  39298. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  39299. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39301. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  39302. if !m.op.Is(OpUpdateOne) {
  39303. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  39304. }
  39305. if m.id == nil || m.oldValue == nil {
  39306. return v, errors.New("OldUnionID requires an ID field in the mutation")
  39307. }
  39308. oldValue, err := m.oldValue(ctx)
  39309. if err != nil {
  39310. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  39311. }
  39312. return oldValue.UnionID, nil
  39313. }
  39314. // ResetUnionID resets all changes to the "union_id" field.
  39315. func (m *WxCardUserMutation) ResetUnionID() {
  39316. m.union_id = nil
  39317. }
  39318. // SetSessionKey sets the "session_key" field.
  39319. func (m *WxCardUserMutation) SetSessionKey(s string) {
  39320. m.session_key = &s
  39321. }
  39322. // SessionKey returns the value of the "session_key" field in the mutation.
  39323. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  39324. v := m.session_key
  39325. if v == nil {
  39326. return
  39327. }
  39328. return *v, true
  39329. }
  39330. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  39331. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39333. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  39334. if !m.op.Is(OpUpdateOne) {
  39335. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  39336. }
  39337. if m.id == nil || m.oldValue == nil {
  39338. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  39339. }
  39340. oldValue, err := m.oldValue(ctx)
  39341. if err != nil {
  39342. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  39343. }
  39344. return oldValue.SessionKey, nil
  39345. }
  39346. // ResetSessionKey resets all changes to the "session_key" field.
  39347. func (m *WxCardUserMutation) ResetSessionKey() {
  39348. m.session_key = nil
  39349. }
  39350. // SetIsVip sets the "is_vip" field.
  39351. func (m *WxCardUserMutation) SetIsVip(i int) {
  39352. m.is_vip = &i
  39353. m.addis_vip = nil
  39354. }
  39355. // IsVip returns the value of the "is_vip" field in the mutation.
  39356. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  39357. v := m.is_vip
  39358. if v == nil {
  39359. return
  39360. }
  39361. return *v, true
  39362. }
  39363. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  39364. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39366. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  39367. if !m.op.Is(OpUpdateOne) {
  39368. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  39369. }
  39370. if m.id == nil || m.oldValue == nil {
  39371. return v, errors.New("OldIsVip requires an ID field in the mutation")
  39372. }
  39373. oldValue, err := m.oldValue(ctx)
  39374. if err != nil {
  39375. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  39376. }
  39377. return oldValue.IsVip, nil
  39378. }
  39379. // AddIsVip adds i to the "is_vip" field.
  39380. func (m *WxCardUserMutation) AddIsVip(i int) {
  39381. if m.addis_vip != nil {
  39382. *m.addis_vip += i
  39383. } else {
  39384. m.addis_vip = &i
  39385. }
  39386. }
  39387. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  39388. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  39389. v := m.addis_vip
  39390. if v == nil {
  39391. return
  39392. }
  39393. return *v, true
  39394. }
  39395. // ResetIsVip resets all changes to the "is_vip" field.
  39396. func (m *WxCardUserMutation) ResetIsVip() {
  39397. m.is_vip = nil
  39398. m.addis_vip = nil
  39399. }
  39400. // Where appends a list predicates to the WxCardUserMutation builder.
  39401. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  39402. m.predicates = append(m.predicates, ps...)
  39403. }
  39404. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  39405. // users can use type-assertion to append predicates that do not depend on any generated package.
  39406. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  39407. p := make([]predicate.WxCardUser, len(ps))
  39408. for i := range ps {
  39409. p[i] = ps[i]
  39410. }
  39411. m.Where(p...)
  39412. }
  39413. // Op returns the operation name.
  39414. func (m *WxCardUserMutation) Op() Op {
  39415. return m.op
  39416. }
  39417. // SetOp allows setting the mutation operation.
  39418. func (m *WxCardUserMutation) SetOp(op Op) {
  39419. m.op = op
  39420. }
  39421. // Type returns the node type of this mutation (WxCardUser).
  39422. func (m *WxCardUserMutation) Type() string {
  39423. return m.typ
  39424. }
  39425. // Fields returns all fields that were changed during this mutation. Note that in
  39426. // order to get all numeric fields that were incremented/decremented, call
  39427. // AddedFields().
  39428. func (m *WxCardUserMutation) Fields() []string {
  39429. fields := make([]string, 0, 13)
  39430. if m.created_at != nil {
  39431. fields = append(fields, wxcarduser.FieldCreatedAt)
  39432. }
  39433. if m.updated_at != nil {
  39434. fields = append(fields, wxcarduser.FieldUpdatedAt)
  39435. }
  39436. if m.deleted_at != nil {
  39437. fields = append(fields, wxcarduser.FieldDeletedAt)
  39438. }
  39439. if m.wxid != nil {
  39440. fields = append(fields, wxcarduser.FieldWxid)
  39441. }
  39442. if m.account != nil {
  39443. fields = append(fields, wxcarduser.FieldAccount)
  39444. }
  39445. if m.avatar != nil {
  39446. fields = append(fields, wxcarduser.FieldAvatar)
  39447. }
  39448. if m.nickname != nil {
  39449. fields = append(fields, wxcarduser.FieldNickname)
  39450. }
  39451. if m.remark != nil {
  39452. fields = append(fields, wxcarduser.FieldRemark)
  39453. }
  39454. if m.phone != nil {
  39455. fields = append(fields, wxcarduser.FieldPhone)
  39456. }
  39457. if m.open_id != nil {
  39458. fields = append(fields, wxcarduser.FieldOpenID)
  39459. }
  39460. if m.union_id != nil {
  39461. fields = append(fields, wxcarduser.FieldUnionID)
  39462. }
  39463. if m.session_key != nil {
  39464. fields = append(fields, wxcarduser.FieldSessionKey)
  39465. }
  39466. if m.is_vip != nil {
  39467. fields = append(fields, wxcarduser.FieldIsVip)
  39468. }
  39469. return fields
  39470. }
  39471. // Field returns the value of a field with the given name. The second boolean
  39472. // return value indicates that this field was not set, or was not defined in the
  39473. // schema.
  39474. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  39475. switch name {
  39476. case wxcarduser.FieldCreatedAt:
  39477. return m.CreatedAt()
  39478. case wxcarduser.FieldUpdatedAt:
  39479. return m.UpdatedAt()
  39480. case wxcarduser.FieldDeletedAt:
  39481. return m.DeletedAt()
  39482. case wxcarduser.FieldWxid:
  39483. return m.Wxid()
  39484. case wxcarduser.FieldAccount:
  39485. return m.Account()
  39486. case wxcarduser.FieldAvatar:
  39487. return m.Avatar()
  39488. case wxcarduser.FieldNickname:
  39489. return m.Nickname()
  39490. case wxcarduser.FieldRemark:
  39491. return m.Remark()
  39492. case wxcarduser.FieldPhone:
  39493. return m.Phone()
  39494. case wxcarduser.FieldOpenID:
  39495. return m.OpenID()
  39496. case wxcarduser.FieldUnionID:
  39497. return m.UnionID()
  39498. case wxcarduser.FieldSessionKey:
  39499. return m.SessionKey()
  39500. case wxcarduser.FieldIsVip:
  39501. return m.IsVip()
  39502. }
  39503. return nil, false
  39504. }
  39505. // OldField returns the old value of the field from the database. An error is
  39506. // returned if the mutation operation is not UpdateOne, or the query to the
  39507. // database failed.
  39508. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39509. switch name {
  39510. case wxcarduser.FieldCreatedAt:
  39511. return m.OldCreatedAt(ctx)
  39512. case wxcarduser.FieldUpdatedAt:
  39513. return m.OldUpdatedAt(ctx)
  39514. case wxcarduser.FieldDeletedAt:
  39515. return m.OldDeletedAt(ctx)
  39516. case wxcarduser.FieldWxid:
  39517. return m.OldWxid(ctx)
  39518. case wxcarduser.FieldAccount:
  39519. return m.OldAccount(ctx)
  39520. case wxcarduser.FieldAvatar:
  39521. return m.OldAvatar(ctx)
  39522. case wxcarduser.FieldNickname:
  39523. return m.OldNickname(ctx)
  39524. case wxcarduser.FieldRemark:
  39525. return m.OldRemark(ctx)
  39526. case wxcarduser.FieldPhone:
  39527. return m.OldPhone(ctx)
  39528. case wxcarduser.FieldOpenID:
  39529. return m.OldOpenID(ctx)
  39530. case wxcarduser.FieldUnionID:
  39531. return m.OldUnionID(ctx)
  39532. case wxcarduser.FieldSessionKey:
  39533. return m.OldSessionKey(ctx)
  39534. case wxcarduser.FieldIsVip:
  39535. return m.OldIsVip(ctx)
  39536. }
  39537. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  39538. }
  39539. // SetField sets the value of a field with the given name. It returns an error if
  39540. // the field is not defined in the schema, or if the type mismatched the field
  39541. // type.
  39542. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  39543. switch name {
  39544. case wxcarduser.FieldCreatedAt:
  39545. v, ok := value.(time.Time)
  39546. if !ok {
  39547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39548. }
  39549. m.SetCreatedAt(v)
  39550. return nil
  39551. case wxcarduser.FieldUpdatedAt:
  39552. v, ok := value.(time.Time)
  39553. if !ok {
  39554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39555. }
  39556. m.SetUpdatedAt(v)
  39557. return nil
  39558. case wxcarduser.FieldDeletedAt:
  39559. v, ok := value.(time.Time)
  39560. if !ok {
  39561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39562. }
  39563. m.SetDeletedAt(v)
  39564. return nil
  39565. case wxcarduser.FieldWxid:
  39566. v, ok := value.(string)
  39567. if !ok {
  39568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39569. }
  39570. m.SetWxid(v)
  39571. return nil
  39572. case wxcarduser.FieldAccount:
  39573. v, ok := value.(string)
  39574. if !ok {
  39575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39576. }
  39577. m.SetAccount(v)
  39578. return nil
  39579. case wxcarduser.FieldAvatar:
  39580. v, ok := value.(string)
  39581. if !ok {
  39582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39583. }
  39584. m.SetAvatar(v)
  39585. return nil
  39586. case wxcarduser.FieldNickname:
  39587. v, ok := value.(string)
  39588. if !ok {
  39589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39590. }
  39591. m.SetNickname(v)
  39592. return nil
  39593. case wxcarduser.FieldRemark:
  39594. v, ok := value.(string)
  39595. if !ok {
  39596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39597. }
  39598. m.SetRemark(v)
  39599. return nil
  39600. case wxcarduser.FieldPhone:
  39601. v, ok := value.(string)
  39602. if !ok {
  39603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39604. }
  39605. m.SetPhone(v)
  39606. return nil
  39607. case wxcarduser.FieldOpenID:
  39608. v, ok := value.(string)
  39609. if !ok {
  39610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39611. }
  39612. m.SetOpenID(v)
  39613. return nil
  39614. case wxcarduser.FieldUnionID:
  39615. v, ok := value.(string)
  39616. if !ok {
  39617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39618. }
  39619. m.SetUnionID(v)
  39620. return nil
  39621. case wxcarduser.FieldSessionKey:
  39622. v, ok := value.(string)
  39623. if !ok {
  39624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39625. }
  39626. m.SetSessionKey(v)
  39627. return nil
  39628. case wxcarduser.FieldIsVip:
  39629. v, ok := value.(int)
  39630. if !ok {
  39631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39632. }
  39633. m.SetIsVip(v)
  39634. return nil
  39635. }
  39636. return fmt.Errorf("unknown WxCardUser field %s", name)
  39637. }
  39638. // AddedFields returns all numeric fields that were incremented/decremented during
  39639. // this mutation.
  39640. func (m *WxCardUserMutation) AddedFields() []string {
  39641. var fields []string
  39642. if m.addis_vip != nil {
  39643. fields = append(fields, wxcarduser.FieldIsVip)
  39644. }
  39645. return fields
  39646. }
  39647. // AddedField returns the numeric value that was incremented/decremented on a field
  39648. // with the given name. The second boolean return value indicates that this field
  39649. // was not set, or was not defined in the schema.
  39650. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  39651. switch name {
  39652. case wxcarduser.FieldIsVip:
  39653. return m.AddedIsVip()
  39654. }
  39655. return nil, false
  39656. }
  39657. // AddField adds the value to the field with the given name. It returns an error if
  39658. // the field is not defined in the schema, or if the type mismatched the field
  39659. // type.
  39660. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  39661. switch name {
  39662. case wxcarduser.FieldIsVip:
  39663. v, ok := value.(int)
  39664. if !ok {
  39665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39666. }
  39667. m.AddIsVip(v)
  39668. return nil
  39669. }
  39670. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  39671. }
  39672. // ClearedFields returns all nullable fields that were cleared during this
  39673. // mutation.
  39674. func (m *WxCardUserMutation) ClearedFields() []string {
  39675. var fields []string
  39676. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  39677. fields = append(fields, wxcarduser.FieldDeletedAt)
  39678. }
  39679. return fields
  39680. }
  39681. // FieldCleared returns a boolean indicating if a field with the given name was
  39682. // cleared in this mutation.
  39683. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  39684. _, ok := m.clearedFields[name]
  39685. return ok
  39686. }
  39687. // ClearField clears the value of the field with the given name. It returns an
  39688. // error if the field is not defined in the schema.
  39689. func (m *WxCardUserMutation) ClearField(name string) error {
  39690. switch name {
  39691. case wxcarduser.FieldDeletedAt:
  39692. m.ClearDeletedAt()
  39693. return nil
  39694. }
  39695. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  39696. }
  39697. // ResetField resets all changes in the mutation for the field with the given name.
  39698. // It returns an error if the field is not defined in the schema.
  39699. func (m *WxCardUserMutation) ResetField(name string) error {
  39700. switch name {
  39701. case wxcarduser.FieldCreatedAt:
  39702. m.ResetCreatedAt()
  39703. return nil
  39704. case wxcarduser.FieldUpdatedAt:
  39705. m.ResetUpdatedAt()
  39706. return nil
  39707. case wxcarduser.FieldDeletedAt:
  39708. m.ResetDeletedAt()
  39709. return nil
  39710. case wxcarduser.FieldWxid:
  39711. m.ResetWxid()
  39712. return nil
  39713. case wxcarduser.FieldAccount:
  39714. m.ResetAccount()
  39715. return nil
  39716. case wxcarduser.FieldAvatar:
  39717. m.ResetAvatar()
  39718. return nil
  39719. case wxcarduser.FieldNickname:
  39720. m.ResetNickname()
  39721. return nil
  39722. case wxcarduser.FieldRemark:
  39723. m.ResetRemark()
  39724. return nil
  39725. case wxcarduser.FieldPhone:
  39726. m.ResetPhone()
  39727. return nil
  39728. case wxcarduser.FieldOpenID:
  39729. m.ResetOpenID()
  39730. return nil
  39731. case wxcarduser.FieldUnionID:
  39732. m.ResetUnionID()
  39733. return nil
  39734. case wxcarduser.FieldSessionKey:
  39735. m.ResetSessionKey()
  39736. return nil
  39737. case wxcarduser.FieldIsVip:
  39738. m.ResetIsVip()
  39739. return nil
  39740. }
  39741. return fmt.Errorf("unknown WxCardUser field %s", name)
  39742. }
  39743. // AddedEdges returns all edge names that were set/added in this mutation.
  39744. func (m *WxCardUserMutation) AddedEdges() []string {
  39745. edges := make([]string, 0, 0)
  39746. return edges
  39747. }
  39748. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39749. // name in this mutation.
  39750. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  39751. return nil
  39752. }
  39753. // RemovedEdges returns all edge names that were removed in this mutation.
  39754. func (m *WxCardUserMutation) RemovedEdges() []string {
  39755. edges := make([]string, 0, 0)
  39756. return edges
  39757. }
  39758. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39759. // the given name in this mutation.
  39760. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  39761. return nil
  39762. }
  39763. // ClearedEdges returns all edge names that were cleared in this mutation.
  39764. func (m *WxCardUserMutation) ClearedEdges() []string {
  39765. edges := make([]string, 0, 0)
  39766. return edges
  39767. }
  39768. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39769. // was cleared in this mutation.
  39770. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  39771. return false
  39772. }
  39773. // ClearEdge clears the value of the edge with the given name. It returns an error
  39774. // if that edge is not defined in the schema.
  39775. func (m *WxCardUserMutation) ClearEdge(name string) error {
  39776. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  39777. }
  39778. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39779. // It returns an error if the edge is not defined in the schema.
  39780. func (m *WxCardUserMutation) ResetEdge(name string) error {
  39781. return fmt.Errorf("unknown WxCardUser edge %s", name)
  39782. }
  39783. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  39784. type WxCardVisitMutation struct {
  39785. config
  39786. op Op
  39787. typ string
  39788. id *uint64
  39789. created_at *time.Time
  39790. updated_at *time.Time
  39791. deleted_at *time.Time
  39792. user_id *uint64
  39793. adduser_id *int64
  39794. bot_id *uint64
  39795. addbot_id *int64
  39796. bot_type *uint8
  39797. addbot_type *int8
  39798. clearedFields map[string]struct{}
  39799. done bool
  39800. oldValue func(context.Context) (*WxCardVisit, error)
  39801. predicates []predicate.WxCardVisit
  39802. }
  39803. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  39804. // wxcardvisitOption allows management of the mutation configuration using functional options.
  39805. type wxcardvisitOption func(*WxCardVisitMutation)
  39806. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  39807. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  39808. m := &WxCardVisitMutation{
  39809. config: c,
  39810. op: op,
  39811. typ: TypeWxCardVisit,
  39812. clearedFields: make(map[string]struct{}),
  39813. }
  39814. for _, opt := range opts {
  39815. opt(m)
  39816. }
  39817. return m
  39818. }
  39819. // withWxCardVisitID sets the ID field of the mutation.
  39820. func withWxCardVisitID(id uint64) wxcardvisitOption {
  39821. return func(m *WxCardVisitMutation) {
  39822. var (
  39823. err error
  39824. once sync.Once
  39825. value *WxCardVisit
  39826. )
  39827. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  39828. once.Do(func() {
  39829. if m.done {
  39830. err = errors.New("querying old values post mutation is not allowed")
  39831. } else {
  39832. value, err = m.Client().WxCardVisit.Get(ctx, id)
  39833. }
  39834. })
  39835. return value, err
  39836. }
  39837. m.id = &id
  39838. }
  39839. }
  39840. // withWxCardVisit sets the old WxCardVisit of the mutation.
  39841. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  39842. return func(m *WxCardVisitMutation) {
  39843. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  39844. return node, nil
  39845. }
  39846. m.id = &node.ID
  39847. }
  39848. }
  39849. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39850. // executed in a transaction (ent.Tx), a transactional client is returned.
  39851. func (m WxCardVisitMutation) Client() *Client {
  39852. client := &Client{config: m.config}
  39853. client.init()
  39854. return client
  39855. }
  39856. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39857. // it returns an error otherwise.
  39858. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  39859. if _, ok := m.driver.(*txDriver); !ok {
  39860. return nil, errors.New("ent: mutation is not running in a transaction")
  39861. }
  39862. tx := &Tx{config: m.config}
  39863. tx.init()
  39864. return tx, nil
  39865. }
  39866. // SetID sets the value of the id field. Note that this
  39867. // operation is only accepted on creation of WxCardVisit entities.
  39868. func (m *WxCardVisitMutation) SetID(id uint64) {
  39869. m.id = &id
  39870. }
  39871. // ID returns the ID value in the mutation. Note that the ID is only available
  39872. // if it was provided to the builder or after it was returned from the database.
  39873. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  39874. if m.id == nil {
  39875. return
  39876. }
  39877. return *m.id, true
  39878. }
  39879. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39880. // That means, if the mutation is applied within a transaction with an isolation level such
  39881. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39882. // or updated by the mutation.
  39883. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  39884. switch {
  39885. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39886. id, exists := m.ID()
  39887. if exists {
  39888. return []uint64{id}, nil
  39889. }
  39890. fallthrough
  39891. case m.op.Is(OpUpdate | OpDelete):
  39892. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  39893. default:
  39894. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39895. }
  39896. }
  39897. // SetCreatedAt sets the "created_at" field.
  39898. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  39899. m.created_at = &t
  39900. }
  39901. // CreatedAt returns the value of the "created_at" field in the mutation.
  39902. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  39903. v := m.created_at
  39904. if v == nil {
  39905. return
  39906. }
  39907. return *v, true
  39908. }
  39909. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  39910. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39912. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39913. if !m.op.Is(OpUpdateOne) {
  39914. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39915. }
  39916. if m.id == nil || m.oldValue == nil {
  39917. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39918. }
  39919. oldValue, err := m.oldValue(ctx)
  39920. if err != nil {
  39921. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39922. }
  39923. return oldValue.CreatedAt, nil
  39924. }
  39925. // ResetCreatedAt resets all changes to the "created_at" field.
  39926. func (m *WxCardVisitMutation) ResetCreatedAt() {
  39927. m.created_at = nil
  39928. }
  39929. // SetUpdatedAt sets the "updated_at" field.
  39930. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  39931. m.updated_at = &t
  39932. }
  39933. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39934. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  39935. v := m.updated_at
  39936. if v == nil {
  39937. return
  39938. }
  39939. return *v, true
  39940. }
  39941. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  39942. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39944. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39945. if !m.op.Is(OpUpdateOne) {
  39946. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39947. }
  39948. if m.id == nil || m.oldValue == nil {
  39949. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39950. }
  39951. oldValue, err := m.oldValue(ctx)
  39952. if err != nil {
  39953. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39954. }
  39955. return oldValue.UpdatedAt, nil
  39956. }
  39957. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39958. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  39959. m.updated_at = nil
  39960. }
  39961. // SetDeletedAt sets the "deleted_at" field.
  39962. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  39963. m.deleted_at = &t
  39964. }
  39965. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39966. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  39967. v := m.deleted_at
  39968. if v == nil {
  39969. return
  39970. }
  39971. return *v, true
  39972. }
  39973. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  39974. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39976. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39977. if !m.op.Is(OpUpdateOne) {
  39978. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39979. }
  39980. if m.id == nil || m.oldValue == nil {
  39981. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39982. }
  39983. oldValue, err := m.oldValue(ctx)
  39984. if err != nil {
  39985. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39986. }
  39987. return oldValue.DeletedAt, nil
  39988. }
  39989. // ClearDeletedAt clears the value of the "deleted_at" field.
  39990. func (m *WxCardVisitMutation) ClearDeletedAt() {
  39991. m.deleted_at = nil
  39992. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  39993. }
  39994. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39995. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  39996. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  39997. return ok
  39998. }
  39999. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40000. func (m *WxCardVisitMutation) ResetDeletedAt() {
  40001. m.deleted_at = nil
  40002. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  40003. }
  40004. // SetUserID sets the "user_id" field.
  40005. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  40006. m.user_id = &u
  40007. m.adduser_id = nil
  40008. }
  40009. // UserID returns the value of the "user_id" field in the mutation.
  40010. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  40011. v := m.user_id
  40012. if v == nil {
  40013. return
  40014. }
  40015. return *v, true
  40016. }
  40017. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  40018. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  40019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40020. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  40021. if !m.op.Is(OpUpdateOne) {
  40022. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  40023. }
  40024. if m.id == nil || m.oldValue == nil {
  40025. return v, errors.New("OldUserID requires an ID field in the mutation")
  40026. }
  40027. oldValue, err := m.oldValue(ctx)
  40028. if err != nil {
  40029. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  40030. }
  40031. return oldValue.UserID, nil
  40032. }
  40033. // AddUserID adds u to the "user_id" field.
  40034. func (m *WxCardVisitMutation) AddUserID(u int64) {
  40035. if m.adduser_id != nil {
  40036. *m.adduser_id += u
  40037. } else {
  40038. m.adduser_id = &u
  40039. }
  40040. }
  40041. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  40042. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  40043. v := m.adduser_id
  40044. if v == nil {
  40045. return
  40046. }
  40047. return *v, true
  40048. }
  40049. // ClearUserID clears the value of the "user_id" field.
  40050. func (m *WxCardVisitMutation) ClearUserID() {
  40051. m.user_id = nil
  40052. m.adduser_id = nil
  40053. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  40054. }
  40055. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  40056. func (m *WxCardVisitMutation) UserIDCleared() bool {
  40057. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  40058. return ok
  40059. }
  40060. // ResetUserID resets all changes to the "user_id" field.
  40061. func (m *WxCardVisitMutation) ResetUserID() {
  40062. m.user_id = nil
  40063. m.adduser_id = nil
  40064. delete(m.clearedFields, wxcardvisit.FieldUserID)
  40065. }
  40066. // SetBotID sets the "bot_id" field.
  40067. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  40068. m.bot_id = &u
  40069. m.addbot_id = nil
  40070. }
  40071. // BotID returns the value of the "bot_id" field in the mutation.
  40072. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  40073. v := m.bot_id
  40074. if v == nil {
  40075. return
  40076. }
  40077. return *v, true
  40078. }
  40079. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  40080. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  40081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40082. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  40083. if !m.op.Is(OpUpdateOne) {
  40084. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  40085. }
  40086. if m.id == nil || m.oldValue == nil {
  40087. return v, errors.New("OldBotID requires an ID field in the mutation")
  40088. }
  40089. oldValue, err := m.oldValue(ctx)
  40090. if err != nil {
  40091. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  40092. }
  40093. return oldValue.BotID, nil
  40094. }
  40095. // AddBotID adds u to the "bot_id" field.
  40096. func (m *WxCardVisitMutation) AddBotID(u int64) {
  40097. if m.addbot_id != nil {
  40098. *m.addbot_id += u
  40099. } else {
  40100. m.addbot_id = &u
  40101. }
  40102. }
  40103. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  40104. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  40105. v := m.addbot_id
  40106. if v == nil {
  40107. return
  40108. }
  40109. return *v, true
  40110. }
  40111. // ResetBotID resets all changes to the "bot_id" field.
  40112. func (m *WxCardVisitMutation) ResetBotID() {
  40113. m.bot_id = nil
  40114. m.addbot_id = nil
  40115. }
  40116. // SetBotType sets the "bot_type" field.
  40117. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  40118. m.bot_type = &u
  40119. m.addbot_type = nil
  40120. }
  40121. // BotType returns the value of the "bot_type" field in the mutation.
  40122. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  40123. v := m.bot_type
  40124. if v == nil {
  40125. return
  40126. }
  40127. return *v, true
  40128. }
  40129. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  40130. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  40131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40132. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  40133. if !m.op.Is(OpUpdateOne) {
  40134. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  40135. }
  40136. if m.id == nil || m.oldValue == nil {
  40137. return v, errors.New("OldBotType requires an ID field in the mutation")
  40138. }
  40139. oldValue, err := m.oldValue(ctx)
  40140. if err != nil {
  40141. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  40142. }
  40143. return oldValue.BotType, nil
  40144. }
  40145. // AddBotType adds u to the "bot_type" field.
  40146. func (m *WxCardVisitMutation) AddBotType(u int8) {
  40147. if m.addbot_type != nil {
  40148. *m.addbot_type += u
  40149. } else {
  40150. m.addbot_type = &u
  40151. }
  40152. }
  40153. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  40154. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  40155. v := m.addbot_type
  40156. if v == nil {
  40157. return
  40158. }
  40159. return *v, true
  40160. }
  40161. // ResetBotType resets all changes to the "bot_type" field.
  40162. func (m *WxCardVisitMutation) ResetBotType() {
  40163. m.bot_type = nil
  40164. m.addbot_type = nil
  40165. }
  40166. // Where appends a list predicates to the WxCardVisitMutation builder.
  40167. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  40168. m.predicates = append(m.predicates, ps...)
  40169. }
  40170. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  40171. // users can use type-assertion to append predicates that do not depend on any generated package.
  40172. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  40173. p := make([]predicate.WxCardVisit, len(ps))
  40174. for i := range ps {
  40175. p[i] = ps[i]
  40176. }
  40177. m.Where(p...)
  40178. }
  40179. // Op returns the operation name.
  40180. func (m *WxCardVisitMutation) Op() Op {
  40181. return m.op
  40182. }
  40183. // SetOp allows setting the mutation operation.
  40184. func (m *WxCardVisitMutation) SetOp(op Op) {
  40185. m.op = op
  40186. }
  40187. // Type returns the node type of this mutation (WxCardVisit).
  40188. func (m *WxCardVisitMutation) Type() string {
  40189. return m.typ
  40190. }
  40191. // Fields returns all fields that were changed during this mutation. Note that in
  40192. // order to get all numeric fields that were incremented/decremented, call
  40193. // AddedFields().
  40194. func (m *WxCardVisitMutation) Fields() []string {
  40195. fields := make([]string, 0, 6)
  40196. if m.created_at != nil {
  40197. fields = append(fields, wxcardvisit.FieldCreatedAt)
  40198. }
  40199. if m.updated_at != nil {
  40200. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  40201. }
  40202. if m.deleted_at != nil {
  40203. fields = append(fields, wxcardvisit.FieldDeletedAt)
  40204. }
  40205. if m.user_id != nil {
  40206. fields = append(fields, wxcardvisit.FieldUserID)
  40207. }
  40208. if m.bot_id != nil {
  40209. fields = append(fields, wxcardvisit.FieldBotID)
  40210. }
  40211. if m.bot_type != nil {
  40212. fields = append(fields, wxcardvisit.FieldBotType)
  40213. }
  40214. return fields
  40215. }
  40216. // Field returns the value of a field with the given name. The second boolean
  40217. // return value indicates that this field was not set, or was not defined in the
  40218. // schema.
  40219. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  40220. switch name {
  40221. case wxcardvisit.FieldCreatedAt:
  40222. return m.CreatedAt()
  40223. case wxcardvisit.FieldUpdatedAt:
  40224. return m.UpdatedAt()
  40225. case wxcardvisit.FieldDeletedAt:
  40226. return m.DeletedAt()
  40227. case wxcardvisit.FieldUserID:
  40228. return m.UserID()
  40229. case wxcardvisit.FieldBotID:
  40230. return m.BotID()
  40231. case wxcardvisit.FieldBotType:
  40232. return m.BotType()
  40233. }
  40234. return nil, false
  40235. }
  40236. // OldField returns the old value of the field from the database. An error is
  40237. // returned if the mutation operation is not UpdateOne, or the query to the
  40238. // database failed.
  40239. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40240. switch name {
  40241. case wxcardvisit.FieldCreatedAt:
  40242. return m.OldCreatedAt(ctx)
  40243. case wxcardvisit.FieldUpdatedAt:
  40244. return m.OldUpdatedAt(ctx)
  40245. case wxcardvisit.FieldDeletedAt:
  40246. return m.OldDeletedAt(ctx)
  40247. case wxcardvisit.FieldUserID:
  40248. return m.OldUserID(ctx)
  40249. case wxcardvisit.FieldBotID:
  40250. return m.OldBotID(ctx)
  40251. case wxcardvisit.FieldBotType:
  40252. return m.OldBotType(ctx)
  40253. }
  40254. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  40255. }
  40256. // SetField sets the value of a field with the given name. It returns an error if
  40257. // the field is not defined in the schema, or if the type mismatched the field
  40258. // type.
  40259. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  40260. switch name {
  40261. case wxcardvisit.FieldCreatedAt:
  40262. v, ok := value.(time.Time)
  40263. if !ok {
  40264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40265. }
  40266. m.SetCreatedAt(v)
  40267. return nil
  40268. case wxcardvisit.FieldUpdatedAt:
  40269. v, ok := value.(time.Time)
  40270. if !ok {
  40271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40272. }
  40273. m.SetUpdatedAt(v)
  40274. return nil
  40275. case wxcardvisit.FieldDeletedAt:
  40276. v, ok := value.(time.Time)
  40277. if !ok {
  40278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40279. }
  40280. m.SetDeletedAt(v)
  40281. return nil
  40282. case wxcardvisit.FieldUserID:
  40283. v, ok := value.(uint64)
  40284. if !ok {
  40285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40286. }
  40287. m.SetUserID(v)
  40288. return nil
  40289. case wxcardvisit.FieldBotID:
  40290. v, ok := value.(uint64)
  40291. if !ok {
  40292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40293. }
  40294. m.SetBotID(v)
  40295. return nil
  40296. case wxcardvisit.FieldBotType:
  40297. v, ok := value.(uint8)
  40298. if !ok {
  40299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40300. }
  40301. m.SetBotType(v)
  40302. return nil
  40303. }
  40304. return fmt.Errorf("unknown WxCardVisit field %s", name)
  40305. }
  40306. // AddedFields returns all numeric fields that were incremented/decremented during
  40307. // this mutation.
  40308. func (m *WxCardVisitMutation) AddedFields() []string {
  40309. var fields []string
  40310. if m.adduser_id != nil {
  40311. fields = append(fields, wxcardvisit.FieldUserID)
  40312. }
  40313. if m.addbot_id != nil {
  40314. fields = append(fields, wxcardvisit.FieldBotID)
  40315. }
  40316. if m.addbot_type != nil {
  40317. fields = append(fields, wxcardvisit.FieldBotType)
  40318. }
  40319. return fields
  40320. }
  40321. // AddedField returns the numeric value that was incremented/decremented on a field
  40322. // with the given name. The second boolean return value indicates that this field
  40323. // was not set, or was not defined in the schema.
  40324. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  40325. switch name {
  40326. case wxcardvisit.FieldUserID:
  40327. return m.AddedUserID()
  40328. case wxcardvisit.FieldBotID:
  40329. return m.AddedBotID()
  40330. case wxcardvisit.FieldBotType:
  40331. return m.AddedBotType()
  40332. }
  40333. return nil, false
  40334. }
  40335. // AddField adds the value to the field with the given name. It returns an error if
  40336. // the field is not defined in the schema, or if the type mismatched the field
  40337. // type.
  40338. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  40339. switch name {
  40340. case wxcardvisit.FieldUserID:
  40341. v, ok := value.(int64)
  40342. if !ok {
  40343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40344. }
  40345. m.AddUserID(v)
  40346. return nil
  40347. case wxcardvisit.FieldBotID:
  40348. v, ok := value.(int64)
  40349. if !ok {
  40350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40351. }
  40352. m.AddBotID(v)
  40353. return nil
  40354. case wxcardvisit.FieldBotType:
  40355. v, ok := value.(int8)
  40356. if !ok {
  40357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40358. }
  40359. m.AddBotType(v)
  40360. return nil
  40361. }
  40362. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  40363. }
  40364. // ClearedFields returns all nullable fields that were cleared during this
  40365. // mutation.
  40366. func (m *WxCardVisitMutation) ClearedFields() []string {
  40367. var fields []string
  40368. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  40369. fields = append(fields, wxcardvisit.FieldDeletedAt)
  40370. }
  40371. if m.FieldCleared(wxcardvisit.FieldUserID) {
  40372. fields = append(fields, wxcardvisit.FieldUserID)
  40373. }
  40374. return fields
  40375. }
  40376. // FieldCleared returns a boolean indicating if a field with the given name was
  40377. // cleared in this mutation.
  40378. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  40379. _, ok := m.clearedFields[name]
  40380. return ok
  40381. }
  40382. // ClearField clears the value of the field with the given name. It returns an
  40383. // error if the field is not defined in the schema.
  40384. func (m *WxCardVisitMutation) ClearField(name string) error {
  40385. switch name {
  40386. case wxcardvisit.FieldDeletedAt:
  40387. m.ClearDeletedAt()
  40388. return nil
  40389. case wxcardvisit.FieldUserID:
  40390. m.ClearUserID()
  40391. return nil
  40392. }
  40393. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  40394. }
  40395. // ResetField resets all changes in the mutation for the field with the given name.
  40396. // It returns an error if the field is not defined in the schema.
  40397. func (m *WxCardVisitMutation) ResetField(name string) error {
  40398. switch name {
  40399. case wxcardvisit.FieldCreatedAt:
  40400. m.ResetCreatedAt()
  40401. return nil
  40402. case wxcardvisit.FieldUpdatedAt:
  40403. m.ResetUpdatedAt()
  40404. return nil
  40405. case wxcardvisit.FieldDeletedAt:
  40406. m.ResetDeletedAt()
  40407. return nil
  40408. case wxcardvisit.FieldUserID:
  40409. m.ResetUserID()
  40410. return nil
  40411. case wxcardvisit.FieldBotID:
  40412. m.ResetBotID()
  40413. return nil
  40414. case wxcardvisit.FieldBotType:
  40415. m.ResetBotType()
  40416. return nil
  40417. }
  40418. return fmt.Errorf("unknown WxCardVisit field %s", name)
  40419. }
  40420. // AddedEdges returns all edge names that were set/added in this mutation.
  40421. func (m *WxCardVisitMutation) AddedEdges() []string {
  40422. edges := make([]string, 0, 0)
  40423. return edges
  40424. }
  40425. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40426. // name in this mutation.
  40427. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  40428. return nil
  40429. }
  40430. // RemovedEdges returns all edge names that were removed in this mutation.
  40431. func (m *WxCardVisitMutation) RemovedEdges() []string {
  40432. edges := make([]string, 0, 0)
  40433. return edges
  40434. }
  40435. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40436. // the given name in this mutation.
  40437. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  40438. return nil
  40439. }
  40440. // ClearedEdges returns all edge names that were cleared in this mutation.
  40441. func (m *WxCardVisitMutation) ClearedEdges() []string {
  40442. edges := make([]string, 0, 0)
  40443. return edges
  40444. }
  40445. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40446. // was cleared in this mutation.
  40447. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  40448. return false
  40449. }
  40450. // ClearEdge clears the value of the edge with the given name. It returns an error
  40451. // if that edge is not defined in the schema.
  40452. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  40453. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  40454. }
  40455. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40456. // It returns an error if the edge is not defined in the schema.
  40457. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  40458. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  40459. }